Skip to content

docs(migration): formalize the native-build contract - #888

Merged
c-vigo merged 1 commit into
devfrom
feature/882-native-build-contract
Jul 7, 2026
Merged

c-vigo merged 1 commit into
devfrom
feature/882-native-build-contract

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

Formalize the native-build contract in docs/MIGRATION.md: state, as official
policy, where C/C++ toolchains for native Python (sdist) builds come from —
the project flake, not the base image. 0.4.0 field validation (#639,
EXOMA/hyrr) showed uv sync hard-fails in the image for any dependency
without a cp314 wheel; the mechanical half is #879, this PR documents the
contract half.

Closes #882

Type of Change

  • docs -- Documentation only

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

All snippets validated against the repo: mkProjectShell in flake.nix
accepts extraPackages ? [ ]; the pinned nixpkgs
(34268251cf5547d39063f2c5ea9a196246f7f3a6) evaluates geant4-11.4.1,
root-6.40.00, gcc-wrapper-15.2.0 (stdenv.cc), cmake-4.1.2.

Changelog Entry

Changed

  • MIGRATION.md: formalized the native-build contract (#882)
    • Tiered policy for native Python builds (wheel-only / toolchain from the project flake via mkProjectShell.extraPackages / in-container nix develop -c middle path), a worked Geant4/ROOT example, and the explicit non-goal of shipping a C/C++ toolchain in the base image. Cross-links #879 and #854.

Testing

  • Tests pass locally (just test) — n/a, docs-only
  • Manual testing performed (describe below)

Manual Testing Details

TDD not applicable: documentation-only change, no testable behavior.
Verification performed instead:

  • just precommit (full hook suite, all files): exit 0, 52 hooks Passed,
    0 Failed (includes pymarkdown, typos, sync-manifest, generate-docs).
  • Nix snippets checked against flake.nix's actual mkProjectShell signature
    and package names evaluated against the pinned nixpkgs revision (versions
    above).

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (MIGRATION.md is a direct file, not template-generated; generate-docs hook passed)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Refs: #882

Extend MIGRATION.md 'Adding tools the image does not ship' with the
tiered native-build contract (wheel-only / project-flake toolchain via
mkProjectShell extraPackages / in-container nix develop middle path),
a worked Geant4/ROOT example, and the explicit non-goal of shipping a
C/C++ toolchain in the base image. Cross-link the sysconfig mechanics
(#879) and the nix-direct CI lane (#854); add a pointer from NIX.md.

Refs: #882
@c-vigo
c-vigo merged commit 9e18745 into dev Jul 7, 2026
13 checks passed
@c-vigo
c-vigo deleted the feature/882-native-build-contract branch July 7, 2026 11:12
c-vigo added a commit that referenced this pull request Jul 7, 2026
…#893)

## Description

Closes #879. In the 0.4.0 image, any `uv sync` needing a source build
hard-fails: the baked CPython records its Nix build toolchain in
sysconfig (`CC='gcc'`, `CXX='g++'`, and link commands starting with
those names), the image ships no compiler, and PEP 517 backends inherit
the phantom names verbatim — scikit-build-core exports them so CMake
aborts on the missing `g++` instead of doing PATH discovery.

This rewrites the first token of
`CC`/`CXX`/`LINKCC`/`LDSHARED`/`BLDSHARED`/`LDCXXSHARED` to the generic
POSIX `cc`/`c++` in `_sysconfigdata__*.py`, `_sysconfig_vars__*.json`,
and the config `Makefile`, restoring normal PATH compiler discovery
against whatever toolchain the project flake provides (see the
native-build contract, #882 / PR #888) — and an honest "no compiler
found" when none does.

Mechanism: a last-layer shadow copy via `fakeRootCommands` — no CPython
rebuild, dev-shell toolchain untouched, all python-dependent derivations
stay cached; deterministic seds preserve digest reproducibility. Stale
hash-based `.pyc`s (CHECKED_HASH) self-invalidate.

## Type of Change

- [x] `fix` -- Bug fix

## Changes Made

- `flake.nix`: `fakeRootCommands` sanitize step in the image
customisation layer
- `tests/test_image.py`: `test_sysconfig_compiler_vars_are_generic` —
asserts generic first tokens and no `/nix/store/` leakage (TDD:
committed RED first)
- `CHANGELOG.md` (+ workspace mirror): Unreleased/Fixed entry

## Changelog Entry

### Fixed
- **Image sysconfig no longer records the Nix build toolchain**
([#879](#879))
- `CC`/`CXX` and link commands sanitized to generic `cc`/`c++`, so PEP
517 source builds fall back to PATH compiler discovery (project-flake
toolchains work; honest error otherwise)

## Testing

- RED: new test failed against the unpatched image (`CC='gcc'`)
- GREEN: full image test suite 114/114 passing locally after the fix,
including the new test
- `just precommit` full suite green

Refs: #879
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant