|
14 | 14 | import struct |
15 | 15 | import subprocess |
16 | 16 | import sys |
| 17 | +import sysconfig |
17 | 18 | import warnings |
18 | 19 |
|
19 | 20 | from setuptools import Extension, setup |
20 | 21 | from setuptools.command.build_ext import build_ext |
21 | 22 |
|
22 | 23 |
|
| 24 | +EXT_SUFFIX, _, _ = sysconfig.get_config_var("EXT_SUFFIX").rpartition(".") |
| 25 | + |
| 26 | + |
23 | 27 | def get_version(): |
24 | 28 | version_file = "src/PIL/_version.py" |
25 | 29 | with open(version_file, encoding="utf-8") as f: |
@@ -411,7 +415,7 @@ def _update_extension(self, name, libraries, define_macros=None, sources=None): |
411 | 415 | if FUZZING_BUILD: |
412 | 416 | extension.language = "c++" |
413 | 417 | extension.extra_link_args = ["--stdlib=libc++"] |
414 | | - break |
| 418 | + return extension |
415 | 419 |
|
416 | 420 | def _remove_extension(self, name): |
417 | 421 | for extension in self.extensions: |
@@ -854,7 +858,7 @@ def build_extensions(self): |
854 | 858 |
|
855 | 859 | defs.append(("PILLOW_VERSION", f'"{PILLOW_VERSION}"')) |
856 | 860 |
|
857 | | - self._update_extension("PIL._imaging", libs, defs) |
| 861 | + self._update_extension("PIL.lib_imaging", libs, defs) |
858 | 862 |
|
859 | 863 | # |
860 | 864 | # additional libraries |
@@ -891,8 +895,15 @@ def build_extensions(self): |
891 | 895 | self._remove_extension("PIL._imagingcms") |
892 | 896 |
|
893 | 897 | if feature.webp: |
894 | | - libs = [feature.webp, feature.webp + "mux", feature.webp + "demux"] |
895 | | - self._update_extension("PIL._webp", libs) |
| 898 | + libs = [ |
| 899 | + f"_imaging{EXT_SUFFIX}", |
| 900 | + feature.webp, |
| 901 | + feature.webp + "mux", |
| 902 | + feature.webp + "demux", |
| 903 | + ] |
| 904 | + ext = self._update_extension("PIL._webp", libs) |
| 905 | + ext.library_dirs.append(f"{self.build_lib}/PIL/") |
| 906 | + ext.runtime_library_dirs.append("$ORIGIN") |
896 | 907 | else: |
897 | 908 | self._remove_extension("PIL._webp") |
898 | 909 |
|
@@ -972,7 +983,7 @@ def debug_build(): |
972 | 983 | for src_file in _LIB_IMAGING: |
973 | 984 | files.append(os.path.join("src/libImaging", src_file + ".c")) |
974 | 985 | ext_modules = [ |
975 | | - Extension("PIL._imaging", files), |
| 986 | + Extension("PIL.lib_imaging", files), |
976 | 987 | Extension("PIL._imagingft", ["src/_imagingft.c"]), |
977 | 988 | Extension("PIL._imagingcms", ["src/_imagingcms.c"]), |
978 | 989 | Extension("PIL._webp", ["src/_webp.c"]), |
|
0 commit comments