Skip to content

Commit

Permalink
fix: build from sources when forcing build from source
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut committed Nov 26, 2024
1 parent bf388ce commit 406766f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,11 @@ jobs:
name: cibw-sdist
path: sdist

- name: Ensure Ninja not present on the system
run: if which ninja; then false; fi

- name: Install SDist
run: pip install $(ls sdist/*.tar.gz)[test] -Ccmake.define.BUILD_CMAKE_FROM_SOURCE=OFF
run: pip install --no-binary=ninja $(ls sdist/*.tar.gz)[test] -Ccmake.define.BUILD_CMAKE_FROM_SOURCE=OFF

- name: Test installed SDist
run: pip check && pytest ./tests
Expand Down
17 changes: 17 additions & 0 deletions _build_backend/backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from scikit_build_core import build as _orig

prepare_metadata_for_build_wheel = _orig.prepare_metadata_for_build_wheel
build_wheel = _orig.build_wheel
build_sdist = _orig.build_sdist
get_requires_for_build_sdist = _orig.get_requires_for_build_sdist

def get_requires_for_build_wheel(config_settings=None):
packages_orig = _orig.get_requires_for_build_wheel(config_settings)
packages = []
for package in packages_orig:
package_name = package.lower().split(">")[0].strip()
if package_name == "ninja":
# never request ninja from the ninja build
continue
packages.append(package)
return packages
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[build-system]
requires = ["scikit-build-core"]
build-backend = "scikit_build_core.build"
requires = ["scikit-build-core>=0.10"]
build-backend = "backend"
backend-path = ["_build_backend"]

[project]
name = "ninja"
Expand Down Expand Up @@ -50,7 +51,8 @@ Homepage = "http://ninja-build.org/"
"Source Code" = "https://github.com/scikit-build/ninja-python-distributions"

[tool.scikit-build]
minimum-version = "0.9"
minimum-version = "build-system.requires"
ninja.make-fallback = true
build-dir = "build/{wheel_tag}"
wheel.py-api = "py3"
wheel.expand-macos-universal-tags = true
Expand Down

0 comments on commit 406766f

Please sign in to comment.