Skip to content

Commit

Permalink
support multiple --config-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nulano committed Jan 2, 2024
1 parent b4e6900 commit f27b838
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
12 changes: 5 additions & 7 deletions _custom_build/backend.py
Expand Up @@ -12,13 +12,11 @@ class _CustomBuildMetaBackend(backend_class):
def run_setup(self, setup_script="setup.py"):
if self.config_settings:
params = []
for k, v in self.config_settings.items():
if isinstance(v, list):
msg = "Conflicting options: " + ", ".join(
f"'--config-setting {k}={v_}'" for v_ in v
)
raise ValueError(msg)
params.append(f"--pillow-configuration={k}={v}")
for key, values in self.config_settings.items():
if not isinstance(values, list):
values = [values]
for value in values:
params.append(f"--pillow-configuration={key}={value}")

sys.argv = sys.argv[:1] + params + sys.argv[1:]
return super().run_setup(setup_script)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -92,7 +92,7 @@ version = {attr = "PIL.__version__"}
[tool.cibuildwheel]
before-all = ".github/workflows/wheels-dependencies.sh"
build-verbosity = 1
config-settings = "raqm=vendor fribidi=vendor imagequant=disable"
config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable"
test-command = "cd {project} && .github/workflows/wheels-test.sh"
test-extras = "tests"

Expand Down
13 changes: 3 additions & 10 deletions setup.py
Expand Up @@ -339,7 +339,7 @@ def __iter__(self):

@staticmethod
def check_configuration(option, value):
return True if configuration.get(option) == value else None
return True if value in configuration.get(option, []) else None

def initialize_options(self):
self.disable_platform_guessing = self.check_configuration(
Expand All @@ -354,7 +354,7 @@ def initialize_options(self):
setattr(self, f"vendor_{x}", self.check_configuration(x, "vendor"))
if self.check_configuration("debug", "true"):
self.debug = True
self.parallel = configuration.get("parallel")
self.parallel = configuration.get("parallel", [None])[-1]

def finalize_options(self):
build_ext.finalize_options(self)
Expand Down Expand Up @@ -402,9 +402,6 @@ def finalize_options(self):
raise ValueError(msg)
_dbg("Using vendored version of %s", x)
self.feature.vendor.add(x)
if x == "raqm":
_dbg("--vendor-raqm implies --enable-raqm")
self.feature.required.add(x)

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

try:
Expand Down

0 comments on commit f27b838

Please sign in to comment.