Skip to content

Commit 40b6391

Browse files
authored
Enable auto-rebuild in scikit-build-core at import time (#27)
Closes MET-41 ## Summary of Changes `scikit-build-core` has an `editable.rebuild` option, which can automatically invoke CMake under the hood when we import from `genmetaballs` to rebuild the C++ extension if needed. To use this option, we need to turn off build isolation for our package so that scikit build can use the right set of tools (see scikit-build/scikit-build-core#1112 (comment)). On the other hand, this also makes rebuilding a lot faster because Pixi doesn't have to re-create a new isolated environment and build from scratch. See [`scikit-build-core`'s official doc on editable install for more details](https://scikit-build-core.readthedocs.io/en/latest/configuration/index.html#editable-installs). With this change, we shouldn't need to manually run `pixi reinstall genmetaballs` anymore. Hopefully this will make our development experience a bit smoother :). ## Test Plan After enabling this option & run `pixi reinstall genmetaballs` one last time just to make sure that the config is active. Then, I tried modifying a couple of the C++ files, then run `pixi run test` immediately after (without running `reinstall` manually), and the changes are correctly reflected on the Python test results.
1 parent 76458d2 commit 40b6391

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
- id: test
2828
name: Run all tests
2929
# reinstall genmetaballs to rebuild C++/CUDA code, then run tests
30-
entry: bash -c "pixi reinstall genmetaballs && pixi run test"
30+
entry: pixi run test
3131
language: system
3232
pass_filenames: false
3333
always_run: true

pixi.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,23 @@ ninja = "*"
3939
scikit-build-core = "*"
4040
nanobind = "*"
4141
gtest = ">=1.17.0,<2"
42-
clang-tools = ">=18,<20" # Includes clang-format and clang-tidy
42+
clang-tools = ">=18,<20" # Includes clang-format and clang-tidy
4343
mesalib = ">=25.0.5,<26"
4444

4545
[tool.pixi.pypi-dependencies]
4646
genmetaballs = { path = ".", editable = true }
4747
ruff = ">=0.8.0"
4848
pre-commit = ">=3.0.0"
4949

50+
[tool.pixi.pypi-options]
51+
# Disable build isolation for genmetaballs to allow scikit-build to find cmake and other build tools
52+
# See https://github.com/scikit-build/scikit-build-core/issues/1112#issuecomment-3025463521
53+
no-build-isolation = ["genmetaballs"]
54+
5055
[tool.pixi.tasks]
5156
ctest = "ctest --test-dir build"
5257
pytest = "pytest"
53-
test = { depends-on = ["ctest", "pytest"] }
58+
test = { depends-on = ["pytest", "ctest"] }
5459
# Simple lint/format/fix commands (C++/CUDA + Python)
5560
format = { cmd = "scripts/format.sh" }
5661
lint = { cmd = "scripts/lint.sh" }
@@ -66,6 +71,7 @@ wheel.py-api = "cp313" # Or your Python version
6671
wheel.packages = ["genmetaballs/src/genmetaballs"]
6772
# use a persistent build directory to speed up rebuild & testing
6873
build-dir = "build"
74+
editable.rebuild = true
6975

7076
[dependency-groups]
7177
dev = ["pytest"]
@@ -86,20 +92,20 @@ line-ending = "auto"
8692

8793
[tool.ruff.lint]
8894
select = [
89-
"E", # pycodestyle errors
90-
"W", # pycodestyle warnings
91-
"F", # pyflakes
92-
"I", # isort
93-
"B", # flake8-bugbear
94-
"C4", # flake8-comprehensions
95-
"UP", # pyupgrade
95+
"E", # pycodestyle errors
96+
"W", # pycodestyle warnings
97+
"F", # pyflakes
98+
"I", # isort
99+
"B", # flake8-bugbear
100+
"C4", # flake8-comprehensions
101+
"UP", # pyupgrade
96102
]
97103
ignore = [
98-
"E501", # line too long (handled by formatter)
99-
"B008", # do not perform function calls in argument defaults
104+
"E501", # line too long (handled by formatter)
105+
"B008", # do not perform function calls in argument defaults
100106
]
101107

102108
[tool.ruff.lint.isort]
103109
known-first-party = ["genmetaballs"]
104110
[tool.pixi.activation.env]
105-
PYOPENGL_PLATFORM = "osmesa"
111+
PYOPENGL_PLATFORM = "osmesa"

0 commit comments

Comments
 (0)