feat(build): fail with actionable instructions when a C compiler or cargo is missing - #72
feat(build): fail with actionable instructions when a C compiler or cargo is missing#72rhoadesScholar wants to merge 1 commit into
Conversation
Pure `ruff --fix` pass over the Python sources with --select I001,F401,F811,RUF100,UP035,PYI029,PYI041. No behaviour changes: import sorting, unused-import removals, duplicate-import dedups, redundant noqa removals, typing.Callable -> collections.abc.Callable, and two .pyi stub cleanups (redundant __repr__ declarations; float|int -> float). Rebased from v2.0_patch onto v2.0 now that #70 is closed in favour of #72/#73/#74. Regenerated rather than cherry-picked, so the two hunks that only existed via #70 (build_wrapper.py, tests/test_worker_serialization.py) are simply absent. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…argo is missing Building daisy from source compiles the Rust core through maturin. When a C linker or the Rust toolchain is absent, maturin's own error is cryptic and does not say what to install -- and since `pip install daisy` from an sdist takes this path, it is the first thing a new user sees. build_wrapper.py becomes the PEP 517 backend (backend-path = ["."]) and wraps maturin's build_wheel / build_editable with an up-front check for cc/gcc/clang and cargo, printing per-platform install instructions instead. build_sdist forwards UNWRAPPED -- packaging sources needs no toolchain, so gating it would be a regression. Everything else is re-exported from maturin, which defines no __all__, so get_requires_for_build_wheel, get_requires_for_build_sdist and prepare_metadata_for_build_wheel forward intact. Rebuilt against current v2.0 and reduced to just this. Dropped from the earlier version: the [project.optional-dependencies] dev/examples/docs extras (v2.0 kept [dependency-groups] and added a lint group, so those would now duplicate it -- and their "Your new dev extra" comments were authoring scaffolding), the matching docs.yml/README --group -> --extra changes (unnecessary for the same reason, and the cause of the docs-CI failure on the old branch), and an unrelated .vscode .gitignore line. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
079088c to
b31e753
Compare
|
Force-pushed a rebuild against current
1. The extras conversion was the wrong direction. That also removes the cause of this PR's docs-CI failure: the matching 2. An unrelated rider is gone. The old version also added What is left is only the point of the PR
Re-verified both directions on the rebuilt branch, against current And the forwarded hook surface is intact (maturin defines no
Noticed while resolving, and relevant to my other open work: |
|
I'm skeptical of this build wrapper. While the error message we get from maturin is quite unhelpful. A fairly long list of "could not compile ..." errors after the one we actually want: "error: linker "cc" not found", I think the error handling along with the provided solutions are very system dependent, and we don't want to try to properly handle all systems. I think a better approach would just be to put a line in the README saying "building from source requires a C toolchain: (build-essentials, xcode-select, etc.)" and leave the error to rust/maturin. |
First of three, replacing #70 — which bundled this feature with two unrelated bug fixes and announced
all three in its own title. Opened fresh rather than force-pushed so the review history stays readable.
#70 will be closed pointing here.
Why
Building daisy from source compiles
daisy-corethrough maturin. If a C linker or the Rust toolchainis missing, maturin's error does not say what to install — and since
pip install daisyfrom an sdisthits this path, it is the first thing a new user sees.
What a user sees now
Before — maturin's error, with no indication of the cause or the fix.
After:
There is an equivalent message for a missing
cargo.Verified both directions on the same tree — with the toolchain present the build is unaffected:
How
build_wrapper.pybecomes the PEP 517 backend (build-backend = "build_wrapper",backend-path = ["."]) and wraps maturin'sbuild_wheel/build_editablewith ashutil.whichcheck up front.
build_sdistforwards unwrapped — packaging sources needs no toolchain, so gatingit would be a regression.
Everything else is re-exported with
from maturin import *. That is safe here specifically becausematurin's
__init__.pydefines no__all__, soget_requires_for_build_wheel,get_requires_for_build_sdistandprepare_metadata_for_build_wheelall forward intact — pip will notfail on a missing hook.
Also in scope
dev,examplesanddocsextras under[project.optional-dependencies], so pip users get thedependency groups uv users already had.
That conversion has to update the places that consumed the old
[dependency-groups]table, which iswhy they are in this PR rather than a follow-up:
.github/workflows/docs.yml(two call sites) andREADME.md:52all saiduv sync --group docs, which errors withGroup 'docs' is not defined in the project's dependency-groups tableonce the table is gone.(#70 made the conversion but not these updates, so its docs job failed at dependency install. That is
fixed here rather than shipped again.)