1- --- Pillow-7.0.0/setup.py.orig 2020-01-02 06:19:26.000000000 +0100
2- +++ Pillow-7.0.0/setup.py 2020-07-05 12:26:18.882948858 +0200
3- @@ -29,13 +29,13 @@ def get_version():
4-
5- NAME = "Pillow"
6- PILLOW_VERSION = get_version()
7- - FREETYPE_ROOT = None
8- + FREETYPE_ROOT = tuple(os.environ['FREETYPE_ROOT'].split('|')) if 'FREETYPE_ROOT' in os.environ else None
9- IMAGEQUANT_ROOT = None
10- JPEG2K_ROOT = None
11- - JPEG_ROOT = None
12- + JPEG_ROOT = tuple(os.environ['JPEG_ROOT'].split('|')) if 'JPEG_ROOT' in os.environ else None
13- LCMS_ROOT = None
14- TIFF_ROOT = None
15- - ZLIB_ROOT = None
16- + ZLIB_ROOT = tuple(os.environ['ZLIB_ROOT'].split('|')) if 'ZLIB_ROOT' in os.environ else None
17-
18-
19- if sys.platform == "win32" and sys.version_info >= (3, 9):
20- @@ -317,7 +317,7 @@ class pil_build_ext(build_ext):
21- )
22-
23- def initialize_options(self):
24- - self.disable_platform_guessing = None
25- + self.disable_platform_guessing = True
26- self.add_imaging_libs = ""
27- build_ext.initialize_options(self)
28- for x in self.feature:
29- @@ -567,62 +567,6 @@ class pil_build_ext(build_ext):
30- feature.jpeg = "libjpeg" # alternative name
31-
32- feature.openjpeg_version = None
33- - if feature.want("jpeg2000"):
34- - _dbg("Looking for jpeg2000")
35- - best_version = None
36- - best_path = None
1+ --- Pillow.orig/setup.py 2021-11-01 14:50:48.000000000 +0100
2+ +++ Pillow/setup.py 2021-11-01 14:51:31.000000000 +0100
3+ @@ -125,7 +125,7 @@
4+ "codec_fd",
5+ )
6+
7+ - DEBUG = False
8+ + DEBUG = True # So we can easely triage user issues.
9+
10+
11+ class DependencyException(Exception):
12+ @@ -411,46 +411,6 @@
13+ include_dirs = []
14+
15+ pkg_config = None
16+ - if _cmd_exists(os.environ.get("PKG_CONFIG", "pkg-config")):
17+ - pkg_config = _pkg_config
18+ -
19+ - #
20+ - # add configured kits
21+ - for root_name, lib_name in dict(
22+ - JPEG_ROOT="libjpeg",
23+ - JPEG2K_ROOT="libopenjp2",
24+ - TIFF_ROOT=("libtiff-5", "libtiff-4"),
25+ - ZLIB_ROOT="zlib",
26+ - FREETYPE_ROOT="freetype2",
27+ - HARFBUZZ_ROOT="harfbuzz",
28+ - FRIBIDI_ROOT="fribidi",
29+ - LCMS_ROOT="lcms2",
30+ - IMAGEQUANT_ROOT="libimagequant",
31+ - ).items():
32+ - root = globals()[root_name]
33+ -
34+ - if root is None and root_name in os.environ:
35+ - prefix = os.environ[root_name]
36+ - root = (os.path.join(prefix, "lib"), os.path.join(prefix, "include"))
37+ -
38+ - if root is None and pkg_config:
39+ - if isinstance(lib_name, tuple):
40+ - for lib_name2 in lib_name:
41+ - _dbg(f"Looking for `{lib_name2}` using pkg-config.")
42+ - root = pkg_config(lib_name2)
43+ - if root:
44+ - break
45+ - else:
46+ - _dbg(f"Looking for `{lib_name}` using pkg-config.")
47+ - root = pkg_config(lib_name)
48+ -
49+ - if isinstance(root, tuple):
50+ - lib_root, include_root = root
51+ - else:
52+ - lib_root = include_root = root
53+ -
54+ - _add_directory(library_dirs, lib_root)
55+ - _add_directory(include_dirs, include_root)
56+
57+ # respect CFLAGS/CPPFLAGS/LDFLAGS
58+ for k in ("CFLAGS", "CPPFLAGS", "LDFLAGS"):
59+ @@ -471,137 +431,6 @@
60+ for d in os.environ[k].split(os.path.pathsep):
61+ _add_directory(library_dirs, d)
62+
63+ - _add_directory(library_dirs, os.path.join(sys.prefix, "lib"))
64+ - _add_directory(include_dirs, os.path.join(sys.prefix, "include"))
65+ -
66+ - #
67+ - # add platform directories
68+ -
69+ - if self.disable_platform_guessing:
70+ - pass
71+ -
72+ - elif sys.platform == "cygwin":
73+ - # pythonX.Y.dll.a is in the /usr/lib/pythonX.Y/config directory
74+ - _add_directory(
75+ - library_dirs,
76+ - os.path.join(
77+ - "/usr/lib", "python{}.{}".format(*sys.version_info), "config"
78+ - ),
79+ - )
80+ -
81+ - elif sys.platform == "darwin":
82+ - # attempt to make sure we pick freetype2 over other versions
83+ - _add_directory(include_dirs, "/sw/include/freetype2")
84+ - _add_directory(include_dirs, "/sw/lib/freetype2/include")
85+ - # fink installation directories
86+ - _add_directory(library_dirs, "/sw/lib")
87+ - _add_directory(include_dirs, "/sw/include")
88+ - # darwin ports installation directories
89+ - _add_directory(library_dirs, "/opt/local/lib")
90+ - _add_directory(include_dirs, "/opt/local/include")
91+ -
92+ - # if Homebrew is installed, use its lib and include directories
93+ - try:
94+ - prefix = (
95+ - subprocess.check_output(["brew", "--prefix"])
96+ - .strip()
97+ - .decode("latin1")
98+ - )
99+ - except Exception:
100+ - # Homebrew not installed
101+ - prefix = None
37102-
38- - # Find the best version
39- - for directory in self.compiler.include_dirs:
40- - _dbg("Checking for openjpeg-#.# in %s", directory)
103+ - ft_prefix = None
104+ -
105+ - if prefix:
106+ - # add Homebrew's include and lib directories
107+ - _add_directory(library_dirs, os.path.join(prefix, "lib"))
108+ - _add_directory(include_dirs, os.path.join(prefix, "include"))
109+ - _add_directory(
110+ - include_dirs, os.path.join(prefix, "opt", "zlib", "include")
111+ - )
112+ - ft_prefix = os.path.join(prefix, "opt", "freetype")
113+ -
114+ - if ft_prefix and os.path.isdir(ft_prefix):
115+ - # freetype might not be linked into Homebrew's prefix
116+ - _add_directory(library_dirs, os.path.join(ft_prefix, "lib"))
117+ - _add_directory(include_dirs, os.path.join(ft_prefix, "include"))
118+ - else:
119+ - # fall back to freetype from XQuartz if
120+ - # Homebrew's freetype is missing
121+ - _add_directory(library_dirs, "/usr/X11/lib")
122+ - _add_directory(include_dirs, "/usr/X11/include")
123+ -
124+ - # SDK install path
125+ - sdk_path = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
126+ - if not os.path.exists(sdk_path):
41127- try:
42- - listdir = os.listdir(directory)
128+ - sdk_path = (
129+ - subprocess.check_output(["xcrun", "--show-sdk-path"])
130+ - .strip()
131+ - .decode("latin1")
132+ - )
43133- except Exception:
44- - # WindowsError, FileNotFoundError
45- - continue
46- - for name in listdir:
47- - if name.startswith("openjpeg-") and os.path.isfile(
48- - os.path.join(directory, name, "openjpeg.h")
49- - ):
50- - _dbg("Found openjpeg.h in %s/%s", (directory, name))
51- - version = tuple(int(x) for x in name[9:].split("."))
52- - if best_version is None or version > best_version:
53- - best_version = version
54- - best_path = os.path.join(directory, name)
55- - _dbg(
56- - "Best openjpeg version %s so far in %s",
57- - (best_version, best_path),
58- - )
59- -
60- - if best_version and _find_library_file(self, "openjp2"):
61- - # Add the directory to the include path so we can include
62- - # <openjpeg.h> rather than having to cope with the versioned
63- - # include path
64- - # FIXME (melvyn-sopacua):
65- - # At this point it's possible that best_path is already in
66- - # self.compiler.include_dirs. Should investigate how that is
67- - # possible.
68- - _add_directory(self.compiler.include_dirs, best_path, 0)
69- - feature.jpeg2000 = "openjp2"
70- - feature.openjpeg_version = ".".join(str(x) for x in best_version)
71- -
72- - if feature.want("imagequant"):
73- - _dbg("Looking for imagequant")
74- - if _find_include_file(self, "libimagequant.h"):
75- - if _find_library_file(self, "imagequant"):
76- - feature.imagequant = "imagequant"
77- - elif _find_library_file(self, "libimagequant"):
78- - feature.imagequant = "libimagequant"
79- -
80- - if feature.want("tiff"):
81- - _dbg("Looking for tiff")
82- - if _find_include_file(self, "tiff.h"):
83- - if _find_library_file(self, "tiff"):
84- - feature.tiff = "tiff"
85- - if sys.platform in ["win32", "darwin"] and _find_library_file(
86- - self, "libtiff"
87- - ):
88- - feature.tiff = "libtiff"
89-
90- if feature.want("freetype"):
91- _dbg("Looking for freetype")
92- @@ -647,15 +591,6 @@ class pil_build_ext(build_ext):
93- if subdir:
94- _add_directory(self.compiler.include_dirs, subdir, 0)
95-
96- - if feature.want("lcms"):
97- - _dbg("Looking for lcms")
98- - if _find_include_file(self, "lcms2.h"):
99- - if _find_library_file(self, "lcms2"):
100- - feature.lcms = "lcms2"
101- - elif _find_library_file(self, "lcms2_static"):
102- - # alternate Windows name.
103- - feature.lcms = "lcms2_static"
104- -
105- if feature.want("webp"):
106- _dbg("Looking for webp")
107- if _find_include_file(self, "webp/encode.h") and _find_include_file(
108- @@ -717,8 +652,8 @@ class pil_build_ext(build_ext):
109- defs.append(("HAVE_LIBTIFF", None))
110- if sys.platform == "win32":
111- libs.extend(["kernel32", "user32", "gdi32"])
112- - if struct.unpack("h", b"\0\1")[0] == 1:
113- - defs.append(("WORDS_BIGENDIAN", None))
114- + # if struct.unpack("h", b"\0\1")[0] == 1:
115- + # defs.append(("WORDS_BIGENDIAN", None))
116-
117- if sys.platform == "win32" and not (PLATFORM_PYPY or PLATFORM_MINGW):
118- defs.append(("PILLOW_VERSION", '"\\"%s\\""' % PILLOW_VERSION))
119- @@ -769,16 +704,6 @@ class pil_build_ext(build_ext):
120- )
121- )
122-
123- - tk_libs = ["psapi"] if sys.platform == "win32" else []
124- - exts.append(
125- - Extension(
126- - "PIL._imagingtk",
127- - ["src/_imagingtk.c", "src/Tk/tkImaging.c"],
128- - include_dirs=["src/Tk"],
129- - libraries=tk_libs,
130- - )
131- - )
134+ - sdk_path = None
135+ - if sdk_path:
136+ - _add_directory(library_dirs, os.path.join(sdk_path, "usr", "lib"))
137+ - _add_directory(include_dirs, os.path.join(sdk_path, "usr", "include"))
138+ - elif (
139+ - sys.platform.startswith("linux")
140+ - or sys.platform.startswith("gnu")
141+ - or sys.platform.startswith("freebsd")
142+ - ):
143+ - for dirname in _find_library_dirs_ldconfig():
144+ - _add_directory(library_dirs, dirname)
145+ - if sys.platform.startswith("linux") and os.environ.get(
146+ - "ANDROID_ROOT", None
147+ - ):
148+ - # termux support for android.
149+ - # system libraries (zlib) are installed in /system/lib
150+ - # headers are at $PREFIX/include
151+ - # user libs are at $PREFIX/lib
152+ - _add_directory(
153+ - library_dirs, os.path.join(os.environ["ANDROID_ROOT"], "lib")
154+ - )
155+ -
156+ - elif sys.platform.startswith("netbsd"):
157+ - _add_directory(library_dirs, "/usr/pkg/lib")
158+ - _add_directory(include_dirs, "/usr/pkg/include")
159+ -
160+ - elif sys.platform.startswith("sunos5"):
161+ - _add_directory(library_dirs, "/opt/local/lib")
162+ - _add_directory(include_dirs, "/opt/local/include")
163+ -
164+ - # FIXME: check /opt/stuff directories here?
165+ -
166+ - # standard locations
167+ - if not self.disable_platform_guessing:
168+ - _add_directory(library_dirs, "/usr/local/lib")
169+ - _add_directory(include_dirs, "/usr/local/include")
170+ -
171+ - _add_directory(library_dirs, "/usr/lib")
172+ - _add_directory(include_dirs, "/usr/include")
173+ - # alpine, at least
174+ - _add_directory(library_dirs, "/lib")
175+ -
176+ - if sys.platform == "win32":
177+ - # on Windows, look for the OpenJPEG libraries in the location that
178+ - # the official installer puts them
179+ - program_files = os.environ.get("ProgramFiles", "")
180+ - best_version = (0, 0)
181+ - best_path = None
182+ - for name in os.listdir(program_files):
183+ - if name.startswith("OpenJPEG "):
184+ - version = tuple(int(x) for x in name[9:].strip().split("."))
185+ - if version > best_version:
186+ - best_version = version
187+ - best_path = os.path.join(program_files, name)
188+ -
189+ - if best_path:
190+ - _dbg("Adding %s to search list", best_path)
191+ - _add_directory(library_dirs, os.path.join(best_path, "lib"))
192+ - _add_directory(include_dirs, os.path.join(best_path, "include"))
132193-
133- exts.append(Extension("PIL._imagingmath", ["src/_imagingmath.c"]))
134- exts.append(Extension("PIL._imagingmorph", ["src/_imagingmorph.c"]))
135-
194+ #
195+ # insert new dirs *before* default libs, to avoid conflicts
196+ # between Python PYD stub libs and real libraries
0 commit comments