This commit is contained in:
wiredfool 2025-07-09 17:00:19 +10:00 committed by GitHub
commit cc52762b2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 14 deletions

View File

@ -5,6 +5,7 @@ ipython
numpy
packaging
pyarrow-stubs
pybind11
pytest
sphinx
types-atheris

View File

@ -276,10 +276,9 @@ Build options
* Config setting: ``-C parallel=n``. Can also be given
with environment variable: ``MAX_CONCURRENCY=n``. Pillow can use
multiprocessing to build the extension. Setting ``-C parallel=n``
multiprocessing to build the extensions. Setting ``-C parallel=n``
sets the number of CPUs to use to ``n``, or can disable parallel building by
using a setting of 1. By default, it uses 4 CPUs, or if 4 are not
available, as many as are present.
using a setting of 1. By default, it uses as many CPUs as are present.
* Config settings: ``-C zlib=disable``, ``-C jpeg=disable``,
``-C tiff=disable``, ``-C freetype=disable``, ``-C raqm=disable``,

View File

@ -1,6 +1,7 @@
[build-system]
build-backend = "backend"
requires = [
"pybind11",
"setuptools>=77",
]
backend-path = [

View File

@ -17,9 +17,20 @@ import sys
import warnings
from collections.abc import Iterator
from pybind11.setup_helpers import ParallelCompile
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
configuration: dict[str, list[str]] = {}
# parse configuration from _custom_build/backend.py
while sys.argv[-1].startswith("--pillow-configuration="):
_, key, value = sys.argv.pop().split("=", 2)
configuration.setdefault(key, []).append(value)
default = int(configuration.get("parallel", ["0"])[-1])
ParallelCompile("MAX_CONCURRENCY", default).install()
def get_version() -> str:
version_file = "src/PIL/_version.py"
@ -27,9 +38,6 @@ def get_version() -> str:
return f.read().split('"')[1]
configuration: dict[str, list[str]] = {}
PILLOW_VERSION = get_version()
AVIF_ROOT = None
FREETYPE_ROOT = None
@ -386,9 +394,7 @@ class pil_build_ext(build_ext):
cpu_count = os.cpu_count()
if cpu_count is not None:
try:
self.parallel = int(
os.environ.get("MAX_CONCURRENCY", min(4, cpu_count))
)
self.parallel = int(os.environ.get("MAX_CONCURRENCY", cpu_count))
except TypeError:
pass
for x in self.feature:
@ -1083,11 +1089,6 @@ ext_modules = [
]
# parse configuration from _custom_build/backend.py
while sys.argv[-1].startswith("--pillow-configuration="):
_, key, value = sys.argv.pop().split("=", 2)
configuration.setdefault(key, []).append(value)
try:
setup(
cmdclass={"build_ext": pil_build_ext},