|
17 | 17 | import warnings |
18 | 18 | from collections.abc import Iterator |
19 | 19 |
|
| 20 | +from pybind11.setup_helpers import ParallelCompile |
20 | 21 | from setuptools import Extension, setup |
21 | 22 | from setuptools.command.build_ext import build_ext |
22 | 23 |
|
| 24 | +configuration: dict[str, list[str]] = {} |
| 25 | + |
| 26 | +# parse configuration from _custom_build/backend.py |
| 27 | +while sys.argv[-1].startswith("--pillow-configuration="): |
| 28 | + _, key, value = sys.argv.pop().split("=", 2) |
| 29 | + configuration.setdefault(key, []).append(value) |
| 30 | + |
| 31 | +default = int(configuration.get("parallel", ["0"])[-1]) |
| 32 | +ParallelCompile("MAX_CONCURRENCY", default).install() |
| 33 | + |
23 | 34 |
|
24 | 35 | def get_version() -> str: |
25 | 36 | version_file = "src/PIL/_version.py" |
26 | 37 | with open(version_file, encoding="utf-8") as f: |
27 | 38 | return f.read().split('"')[1] |
28 | 39 |
|
29 | 40 |
|
30 | | -configuration: dict[str, list[str]] = {} |
31 | | - |
32 | | - |
33 | 41 | PILLOW_VERSION = get_version() |
34 | 42 | AVIF_ROOT = None |
35 | 43 | FREETYPE_ROOT = None |
@@ -386,9 +394,7 @@ def finalize_options(self) -> None: |
386 | 394 | cpu_count = os.cpu_count() |
387 | 395 | if cpu_count is not None: |
388 | 396 | try: |
389 | | - self.parallel = int( |
390 | | - os.environ.get("MAX_CONCURRENCY", min(4, cpu_count)) |
391 | | - ) |
| 397 | + self.parallel = int(os.environ.get("MAX_CONCURRENCY", cpu_count)) |
392 | 398 | except TypeError: |
393 | 399 | pass |
394 | 400 | for x in self.feature: |
@@ -1083,11 +1089,6 @@ def debug_build() -> bool: |
1083 | 1089 | ] |
1084 | 1090 |
|
1085 | 1091 |
|
1086 | | -# parse configuration from _custom_build/backend.py |
1087 | | -while sys.argv[-1].startswith("--pillow-configuration="): |
1088 | | - _, key, value = sys.argv.pop().split("=", 2) |
1089 | | - configuration.setdefault(key, []).append(value) |
1090 | | - |
1091 | 1092 | try: |
1092 | 1093 | setup( |
1093 | 1094 | cmdclass={"build_ext": pil_build_ext}, |
|
0 commit comments