Skip to content

Commit 3b584f7

Browse files
committed
allow to force ninja
1 parent fad4c68 commit 3b584f7

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

_build_backend/backend.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,25 @@
1212
get_requires_for_build_editable = _orig.get_requires_for_build_editable
1313
get_requires_for_build_sdist = _orig.get_requires_for_build_sdist
1414

15+
16+
def strtobool(value: str) -> bool:
17+
"""
18+
Converts a environment variable string into a boolean value.
19+
"""
20+
if not value:
21+
return False
22+
value = value.lower()
23+
if value.isdigit():
24+
return bool(int(value))
25+
return value not in {"n", "no", "off", "false", "f"}
26+
27+
1528
def get_requires_for_build_wheel(config_settings=None):
1629
packages_orig = _orig.get_requires_for_build_wheel(config_settings)
17-
allow_ninja = os.environ.get("CMAKE_PYTHON_DIST_ALLOW_NINJA_DEP", "0") != "0"
30+
allow_ninja = any(
31+
strtobool(os.environ.get(var, ""))
32+
for var in ("CMAKE_PYTHON_DIST_FORCE_NINJA_DEP", "CMAKE_PYTHON_DIST_ALLOW_NINJA_DEP")
33+
)
1834
packages = []
1935
for package in packages_orig:
2036
package_name = package.lower().split(">")[0].strip()

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,18 @@ template = '''
6666
version = "${version}"
6767
'''
6868

69+
[[tool.scikit-build.overrides]]
70+
if.env.CMAKE_PYTHON_DIST_FORCE_NINJA_DEP = true
71+
ninja.make-fallback = false
72+
73+
6974
[tool.cibuildwheel]
7075
build = "cp39-*"
7176
test-extras = "test"
7277
test-command = "pytest {project}/tests"
7378
build-verbosity = 1
7479
build-frontend = "build[uv]"
75-
environment = { CMAKE_PYTHON_DIST_ALLOW_NINJA_DEP = "1" }
80+
environment = { CMAKE_PYTHON_DIST_FORCE_NINJA_DEP = "1" }
7681
musllinux-x86_64-image = "musllinux_1_1"
7782
musllinux-i686-image = "musllinux_1_1"
7883
musllinux-aarch64-image = "musllinux_1_1"

0 commit comments

Comments
 (0)