mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
Merge pull request #4305 from radarhere/remove_distutils
Replaced distutils with C version check
This commit is contained in:
commit
f72e866b5e
|
@ -1,5 +1,4 @@
|
|||
import base64
|
||||
import distutils.version
|
||||
import io
|
||||
import itertools
|
||||
import logging
|
||||
|
@ -272,12 +271,8 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
)
|
||||
}
|
||||
|
||||
libtiff_version = TiffImagePlugin._libtiff_version()
|
||||
|
||||
libtiffs = [False]
|
||||
if distutils.version.StrictVersion(
|
||||
libtiff_version
|
||||
) >= distutils.version.StrictVersion("4.0"):
|
||||
if Image.core.libtiff_support_custom_tags:
|
||||
libtiffs.append(True)
|
||||
|
||||
for libtiff in libtiffs:
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#
|
||||
# See the README file for information on usage and redistribution.
|
||||
#
|
||||
import distutils.version
|
||||
import io
|
||||
import itertools
|
||||
import os
|
||||
|
@ -264,10 +263,6 @@ def _limit_rational(val, max_val):
|
|||
return n_d[::-1] if inv else n_d
|
||||
|
||||
|
||||
def _libtiff_version():
|
||||
return Image.core.libtiff_version.split("\n")[0].split("Version ")[1]
|
||||
|
||||
|
||||
##
|
||||
# Wrapper for TIFF IFDs.
|
||||
|
||||
|
@ -1559,11 +1554,10 @@ def _save(im, fp, filename):
|
|||
# Custom items are supported for int, float, unicode, string and byte
|
||||
# values. Other types and tuples require a tagtype.
|
||||
if tag not in TiffTags.LIBTIFF_CORE:
|
||||
if TiffTags.lookup(tag).type == TiffTags.UNDEFINED:
|
||||
continue
|
||||
if distutils.version.StrictVersion(
|
||||
_libtiff_version()
|
||||
) < distutils.version.StrictVersion("4.0"):
|
||||
if (
|
||||
TiffTags.lookup(tag).type == TiffTags.UNDEFINED
|
||||
or not Image.core.libtiff_support_custom_tags
|
||||
):
|
||||
continue
|
||||
|
||||
if tag in ifd.tagtype:
|
||||
|
|
|
@ -82,6 +82,12 @@
|
|||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBTIFF
|
||||
#ifndef _TIFFIO_
|
||||
#include <tiffio.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "Imaging.h"
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
|
@ -3961,6 +3967,15 @@ setup_module(PyObject* m) {
|
|||
{
|
||||
extern const char * ImagingTiffVersion(void);
|
||||
PyDict_SetItemString(d, "libtiff_version", PyUnicode_FromString(ImagingTiffVersion()));
|
||||
|
||||
// Test for libtiff 4.0 or later, excluding libtiff 3.9.6 and 3.9.7
|
||||
PyObject* support_custom_tags;
|
||||
#if TIFFLIB_VERSION >= 20111221 && TIFFLIB_VERSION != 20120218 && TIFFLIB_VERSION != 20120922
|
||||
support_custom_tags = Py_True;
|
||||
#else
|
||||
support_custom_tags = Py_False;
|
||||
#endif
|
||||
PyDict_SetItemString(d, "libtiff_support_custom_tags", support_custom_tags);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user