mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-11 00:32:27 +03:00
Merge 90e6f9c163
into 3e5df07b34
This commit is contained in:
commit
ef1e290ebb
121
setup.py
121
setup.py
|
@ -234,11 +234,18 @@ def _find_include_file(self: pil_build_ext, include: str) -> str | None:
|
||||||
|
|
||||||
|
|
||||||
def _find_library_file(self: pil_build_ext, library: str) -> str | None:
|
def _find_library_file(self: pil_build_ext, library: str) -> str | None:
|
||||||
ret = self.compiler.find_library_file(self.compiler.library_dirs, library)
|
ret = self.compiler.find_library_file(
|
||||||
|
self.compiler.library_dirs, library, debug=debug_build()
|
||||||
|
)
|
||||||
if ret:
|
if ret:
|
||||||
_dbg("Found library %s at %s", (library, ret))
|
_dbg("Found library %s at %s", (library, ret))
|
||||||
else:
|
# we are only interested in the library name including a possible debug suffix
|
||||||
_dbg("Couldn't find library %s in %s", (library, self.compiler.library_dirs))
|
lib_name_base = os.path.basename(ret).split(".")[0]
|
||||||
|
# as the library prefix differs depending on library type and platform,
|
||||||
|
# we ignore it by looking for the actual library name
|
||||||
|
start_index = lib_name_base.find(library)
|
||||||
|
return lib_name_base[start_index:]
|
||||||
|
_dbg("Couldn't find library %s in %s", (library, self.compiler.library_dirs))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -716,20 +723,23 @@ class pil_build_ext(build_ext):
|
||||||
if feature.want("zlib"):
|
if feature.want("zlib"):
|
||||||
_dbg("Looking for zlib")
|
_dbg("Looking for zlib")
|
||||||
if _find_include_file(self, "zlib.h"):
|
if _find_include_file(self, "zlib.h"):
|
||||||
if _find_library_file(self, "z"):
|
lib_zlib = _find_library_file(self, "z")
|
||||||
feature.set("zlib", "z")
|
if lib_zlib is None and sys.platform == "win32":
|
||||||
elif sys.platform == "win32" and _find_library_file(self, "zlib"):
|
# alternative name
|
||||||
feature.set("zlib", "zlib") # alternative name
|
lib_zlib = _find_library_file(self, "zlib")
|
||||||
elif sys.platform == "win32" and _find_library_file(self, "zdll"):
|
if lib_zlib is None:
|
||||||
feature.set("zlib", "zdll") # dll import library
|
# dll import library
|
||||||
|
lib_zlib = _find_library_file(self, "zdll")
|
||||||
|
feature.set("zlib", lib_zlib)
|
||||||
|
|
||||||
if feature.want("jpeg"):
|
if feature.want("jpeg"):
|
||||||
_dbg("Looking for jpeg")
|
_dbg("Looking for jpeg")
|
||||||
if _find_include_file(self, "jpeglib.h"):
|
if _find_include_file(self, "jpeglib.h"):
|
||||||
if _find_library_file(self, "jpeg"):
|
lib_jpeg = _find_library_file(self, "jpeg")
|
||||||
feature.set("jpeg", "jpeg")
|
if lib_jpeg is None and sys.platform == "win32":
|
||||||
elif sys.platform == "win32" and _find_library_file(self, "libjpeg"):
|
# alternative name
|
||||||
feature.set("jpeg", "libjpeg") # alternative name
|
lib_jpeg = _find_library_file(self, "libjpeg")
|
||||||
|
feature.set("jpeg", lib_jpeg)
|
||||||
|
|
||||||
feature.set("openjpeg_version", None)
|
feature.set("openjpeg_version", None)
|
||||||
if feature.want("jpeg2000"):
|
if feature.want("jpeg2000"):
|
||||||
|
@ -759,35 +769,40 @@ class pil_build_ext(build_ext):
|
||||||
(str(best_version), best_path),
|
(str(best_version), best_path),
|
||||||
)
|
)
|
||||||
|
|
||||||
if best_version and _find_library_file(self, "openjp2"):
|
if best_version:
|
||||||
# Add the directory to the include path so we can include
|
lib_jpeg2k = _find_library_file(self, "openjp2")
|
||||||
# <openjpeg.h> rather than having to cope with the versioned
|
if lib_jpeg2k is not None:
|
||||||
# include path
|
# Add the directory to the include path so we can include
|
||||||
_add_directory(self.compiler.include_dirs, best_path, 0)
|
# <openjpeg.h> rather than having to cope with the versioned
|
||||||
feature.set("jpeg2000", "openjp2")
|
# include path
|
||||||
|
_add_directory(self.compiler.include_dirs, best_path, 0)
|
||||||
|
feature.set("jpeg2000", lib_jpeg2k)
|
||||||
feature.set("openjpeg_version", ".".join(str(x) for x in best_version))
|
feature.set("openjpeg_version", ".".join(str(x) for x in best_version))
|
||||||
|
|
||||||
if feature.want("imagequant"):
|
if feature.want("imagequant"):
|
||||||
_dbg("Looking for imagequant")
|
_dbg("Looking for imagequant")
|
||||||
if _find_include_file(self, "libimagequant.h"):
|
if _find_include_file(self, "libimagequant.h"):
|
||||||
if _find_library_file(self, "imagequant"):
|
lib_imagequant = _find_library_file(
|
||||||
feature.set("imagequant", "imagequant")
|
self, "imagequant"
|
||||||
elif _find_library_file(self, "libimagequant"):
|
) or _find_library_file(self, "libimagequant")
|
||||||
feature.set("imagequant", "libimagequant")
|
if lib_imagequant is not None:
|
||||||
|
feature.set("imagequant", lib_imagequant)
|
||||||
|
|
||||||
if feature.want("tiff"):
|
if feature.want("tiff"):
|
||||||
_dbg("Looking for tiff")
|
_dbg("Looking for tiff")
|
||||||
if _find_include_file(self, "tiff.h"):
|
if _find_include_file(self, "tiff.h"):
|
||||||
if sys.platform in ["win32", "darwin"] and _find_library_file(
|
lib_tiff = None
|
||||||
self, "libtiff"
|
if sys.platform in ["win32", "darwin"]:
|
||||||
):
|
lib_tiff = _find_library_file(self, "libtiff")
|
||||||
feature.set("tiff", "libtiff")
|
if lib_tiff is None:
|
||||||
elif _find_library_file(self, "tiff"):
|
lib_tiff = _find_library_file(self, "tiff")
|
||||||
feature.set("tiff", "tiff")
|
if lib_tiff is not None:
|
||||||
|
feature.set("tiff", lib_tiff)
|
||||||
|
|
||||||
if feature.want("freetype"):
|
if feature.want("freetype"):
|
||||||
_dbg("Looking for freetype")
|
_dbg("Looking for freetype")
|
||||||
if _find_library_file(self, "freetype"):
|
lib_freetype = _find_library_file(self, "freetype")
|
||||||
|
if lib_freetype is not None:
|
||||||
# look for freetype2 include files
|
# look for freetype2 include files
|
||||||
freetype_version = 0
|
freetype_version = 0
|
||||||
for subdir in self.compiler.include_dirs:
|
for subdir in self.compiler.include_dirs:
|
||||||
|
@ -804,7 +819,7 @@ class pil_build_ext(build_ext):
|
||||||
freetype_version = 21
|
freetype_version = 21
|
||||||
break
|
break
|
||||||
if freetype_version:
|
if freetype_version:
|
||||||
feature.set("freetype", "freetype")
|
feature.set("freetype", lib_freetype)
|
||||||
if subdir:
|
if subdir:
|
||||||
_add_directory(self.compiler.include_dirs, subdir, 0)
|
_add_directory(self.compiler.include_dirs, subdir, 0)
|
||||||
|
|
||||||
|
@ -812,10 +827,11 @@ class pil_build_ext(build_ext):
|
||||||
if not feature.want_vendor("raqm"): # want system Raqm
|
if not feature.want_vendor("raqm"): # want system Raqm
|
||||||
_dbg("Looking for Raqm")
|
_dbg("Looking for Raqm")
|
||||||
if _find_include_file(self, "raqm.h"):
|
if _find_include_file(self, "raqm.h"):
|
||||||
if _find_library_file(self, "raqm"):
|
lib_raqm = _find_library_file(self, "raqm") or _find_library_file(
|
||||||
feature.set("raqm", "raqm")
|
self, "libraqm"
|
||||||
elif _find_library_file(self, "libraqm"):
|
)
|
||||||
feature.set("raqm", "libraqm")
|
if lib_raqm is not None:
|
||||||
|
feature.set("raqm", lib_raqm)
|
||||||
else: # want to build Raqm from src/thirdparty
|
else: # want to build Raqm from src/thirdparty
|
||||||
_dbg("Looking for HarfBuzz")
|
_dbg("Looking for HarfBuzz")
|
||||||
feature.set("harfbuzz", None)
|
feature.set("harfbuzz", None)
|
||||||
|
@ -823,8 +839,9 @@ class pil_build_ext(build_ext):
|
||||||
if hb_dir:
|
if hb_dir:
|
||||||
if isinstance(hb_dir, str):
|
if isinstance(hb_dir, str):
|
||||||
_add_directory(self.compiler.include_dirs, hb_dir, 0)
|
_add_directory(self.compiler.include_dirs, hb_dir, 0)
|
||||||
if _find_library_file(self, "harfbuzz"):
|
lib_harfbuzz = _find_library_file(self, "harfbuzz")
|
||||||
feature.set("harfbuzz", "harfbuzz")
|
if lib_harfbuzz is not None:
|
||||||
|
feature.set("harfbuzz", lib_harfbuzz)
|
||||||
if feature.get("harfbuzz"):
|
if feature.get("harfbuzz"):
|
||||||
if not feature.want_vendor("fribidi"): # want system FriBiDi
|
if not feature.want_vendor("fribidi"): # want system FriBiDi
|
||||||
_dbg("Looking for FriBiDi")
|
_dbg("Looking for FriBiDi")
|
||||||
|
@ -835,8 +852,9 @@ class pil_build_ext(build_ext):
|
||||||
_add_directory(
|
_add_directory(
|
||||||
self.compiler.include_dirs, fribidi_dir, 0
|
self.compiler.include_dirs, fribidi_dir, 0
|
||||||
)
|
)
|
||||||
if _find_library_file(self, "fribidi"):
|
lib_fribidi = _find_library_file(self, "fribidi")
|
||||||
feature.set("fribidi", "fribidi")
|
if lib_fribidi is not None:
|
||||||
|
feature.set("fribidi", lib_fribidi)
|
||||||
feature.set("raqm", True)
|
feature.set("raqm", True)
|
||||||
else: # want to build FriBiDi shim from src/thirdparty
|
else: # want to build FriBiDi shim from src/thirdparty
|
||||||
feature.set("raqm", True)
|
feature.set("raqm", True)
|
||||||
|
@ -844,11 +862,11 @@ class pil_build_ext(build_ext):
|
||||||
if feature.want("lcms"):
|
if feature.want("lcms"):
|
||||||
_dbg("Looking for lcms")
|
_dbg("Looking for lcms")
|
||||||
if _find_include_file(self, "lcms2.h"):
|
if _find_include_file(self, "lcms2.h"):
|
||||||
if _find_library_file(self, "lcms2"):
|
lib_lcms2 = _find_library_file(self, "lcms2") or _find_library_file(
|
||||||
feature.set("lcms", "lcms2")
|
self, "lcms2_static" # alternate Windows name
|
||||||
elif _find_library_file(self, "lcms2_static"):
|
)
|
||||||
# alternate Windows name.
|
if lib_lcms2 is not None:
|
||||||
feature.set("lcms", "lcms2_static")
|
feature.set("lcms", lib_lcms2)
|
||||||
|
|
||||||
if feature.want("webp"):
|
if feature.want("webp"):
|
||||||
_dbg("Looking for webp")
|
_dbg("Looking for webp")
|
||||||
|
@ -862,14 +880,15 @@ class pil_build_ext(build_ext):
|
||||||
_find_library_file(self, prefix + library)
|
_find_library_file(self, prefix + library)
|
||||||
for library in ("webp", "webpmux", "webpdemux")
|
for library in ("webp", "webpmux", "webpdemux")
|
||||||
):
|
):
|
||||||
feature.set("webp", prefix + "webp")
|
feature.set("webp", _find_library_file(self, prefix + "webp"))
|
||||||
break
|
break
|
||||||
|
|
||||||
if feature.want("xcb"):
|
if feature.want("xcb"):
|
||||||
_dbg("Looking for xcb")
|
_dbg("Looking for xcb")
|
||||||
if _find_include_file(self, "xcb/xcb.h"):
|
if _find_include_file(self, "xcb/xcb.h"):
|
||||||
if _find_library_file(self, "xcb"):
|
lib_xcb = _find_library_file(self, "xcb")
|
||||||
feature.set("xcb", "xcb")
|
if lib_xcb is not None:
|
||||||
|
feature.set("xcb", lib_xcb)
|
||||||
|
|
||||||
if feature.want("avif"):
|
if feature.want("avif"):
|
||||||
_dbg("Looking for avif")
|
_dbg("Looking for avif")
|
||||||
|
@ -878,8 +897,10 @@ class pil_build_ext(build_ext):
|
||||||
major_version = int(
|
major_version = int(
|
||||||
fp.read().split(b"#define AVIF_VERSION_MAJOR ")[1].split()[0]
|
fp.read().split(b"#define AVIF_VERSION_MAJOR ")[1].split()[0]
|
||||||
)
|
)
|
||||||
if major_version >= 1 and _find_library_file(self, "avif"):
|
if major_version >= 1:
|
||||||
feature.set("avif", "avif")
|
lib_avif = _find_library_file(self, "avif")
|
||||||
|
if lib_avif is not None:
|
||||||
|
feature.set("avif", lib_avif)
|
||||||
|
|
||||||
for f in feature:
|
for f in feature:
|
||||||
if not feature.get(f) and feature.require(f):
|
if not feature.get(f) and feature.require(f):
|
||||||
|
@ -939,7 +960,7 @@ class pil_build_ext(build_ext):
|
||||||
|
|
||||||
if feature.get("freetype"):
|
if feature.get("freetype"):
|
||||||
srcs = []
|
srcs = []
|
||||||
libs = ["freetype"]
|
libs = [feature.get("freetype")]
|
||||||
defs = []
|
defs = []
|
||||||
if feature.get("raqm"):
|
if feature.get("raqm"):
|
||||||
if not feature.want_vendor("raqm"): # using system Raqm
|
if not feature.want_vendor("raqm"): # using system Raqm
|
||||||
|
|
Loading…
Reference in New Issue
Block a user