Skip to content

Commit aa88528

Browse files
committed
support multiple --config-settings
1 parent b4e6900 commit aa88528

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

_custom_build/backend.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ class _CustomBuildMetaBackend(backend_class):
1212
def run_setup(self, setup_script="setup.py"):
1313
if self.config_settings:
1414
params = []
15-
for k, v in self.config_settings.items():
16-
if isinstance(v, list):
17-
msg = "Conflicting options: " + ", ".join(
18-
f"'--config-setting {k}={v_}'" for v_ in v
19-
)
20-
raise ValueError(msg)
21-
params.append(f"--pillow-configuration={k}={v}")
15+
for key, values in self.config_settings.items():
16+
if not isinstance(values, list):
17+
values = [values]
18+
for value in values:
19+
params.append(f"--pillow-configuration={key}={value}")
2220

2321
sys.argv = sys.argv[:1] + params + sys.argv[1:]
2422
return super().run_setup(setup_script)

setup.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def __iter__(self):
339339

340340
@staticmethod
341341
def check_configuration(option, value):
342-
return True if configuration.get(option) == value else None
342+
return True if value in configuration.get(option, []) else None
343343

344344
def initialize_options(self):
345345
self.disable_platform_guessing = self.check_configuration(
@@ -354,7 +354,7 @@ def initialize_options(self):
354354
setattr(self, f"vendor_{x}", self.check_configuration(x, "vendor"))
355355
if self.check_configuration("debug", "true"):
356356
self.debug = True
357-
self.parallel = configuration.get("parallel")
357+
self.parallel = configuration.get("parallel", [None])[-1]
358358

359359
def finalize_options(self):
360360
build_ext.finalize_options(self)
@@ -402,9 +402,6 @@ def finalize_options(self):
402402
raise ValueError(msg)
403403
_dbg("Using vendored version of %s", x)
404404
self.feature.vendor.add(x)
405-
if x == "raqm":
406-
_dbg("--vendor-raqm implies --enable-raqm")
407-
self.feature.required.add(x)
408405

409406
def _update_extension(self, name, libraries, define_macros=None, sources=None):
410407
for extension in self.extensions:
@@ -1004,11 +1001,7 @@ def debug_build():
10041001
# parse configuration from _custom_build/backend.py
10051002
while len(sys.argv[1]) >= 2 and sys.argv[1].startswith("--pillow-configuration="):
10061003
_, key, value = sys.argv[1].split("=", 2)
1007-
old = configuration.get(key)
1008-
if old is not None:
1009-
msg = f"Conflicting options: '-C {key}={old}' and '-C {key}={value}'"
1010-
raise ValueError(msg)
1011-
configuration[key] = value
1004+
configuration.setdefault(key, []).append(value)
10121005
del sys.argv[1]
10131006

10141007
try:

0 commit comments

Comments
 (0)