feat(e2e): Source-built Python interpreter with uv deps#830
feat(e2e): Source-built Python interpreter with uv deps#830
Conversation
|
|
|
Read the `no-binary-package` list from pyproject.toml's `[tool.uv]` section. For listed packages: - Force sdist build even when a -none-any wheel exists - Exclude all pre-built wheels from the install configuration - Fail if no sdist is available in the lockfile This mirrors uv's own `no-binary-package` behavior, enabling use cases like building C extensions with custom interpreters (e.g. debug builds). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Demonstrates building CPython 3.11.9 from source as a Bazel build action, registering it as a py_runtime toolchain gated behind a build setting, and using it with uv-sourced C extension dependencies (markupsafe). Key components: - Custom `build_cpython` Starlark rule that runs ./configure && make && make install as a build action producing a tree artifact - Wrapper script that sets PYTHONHOME to bridge the tree artifact layout with py_runtime's interpreter expectations - `source_built_test` transition rule that activates the custom toolchain via a string_flag/config_setting gate - MODULE.bazel `include()` to keep case-specific configuration self-contained - Two tests: basic interpreter verification and uv deps with markupsafe (C extension) proving wheel compatibility Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a69ae14 to
cf4a080
Compare
## Summary - Reads `[tool.uv] no-binary-package` from `pyproject.toml` to identify packages that must be built from source - For listed packages: forces sdist build (even for -none-any wheels), excludes all pre-built wheels from the install config - Adds a safety `fail()` if a no-binary package has no sdist in the lockfile This mirrors uv's own `no-binary-package` behavior, enabling use cases like building C extensions with custom/debug interpreters. ## Test plan - [x] All 44 main tests pass (`bazel test //...`) - [x] All 16 e2e tests pass (`cd e2e && bazel test //...`) - [ ] Stacked PR #830 exercises this with source-built debug Python + markupsafe sdist 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: claude <claude@anthropic.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Use --without-ensurepip instead of --with-ensurepip=install when building CPython from source. The ensurepip step installs pip and setuptools into the interpreter tree, which is unnecessary for our use case and was contributing to sdist build failures in CI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Replaced by #833 |


Summary
--with-pydebug(producingcp311dABI tag)[tool.uv] no-binary-package = ["markupsafe"]to force sdist buildKey design
build_cpython,python_interpreter_wrapper,source_built_test) indefs.bzlcp311dABI tag in the built wheel is impossible to produce from pre-built wheels or PBS interpreters, definitively proving the custom interpreter was usedTest plan
bazel test //...)cd e2e && bazel test //cases/source-built-python/...passes (requires feat(uv): Support [tool.uv] no-binary-package #831)🤖 Generated with Claude Code