fix(interpreter): propagate python version flags through exec transitions - #1539
xangcastle wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✨ Aspect Workflows Tasks📅 Fri Sep 11 15:07:00 UTC 2026 ✅ 7 successful tasks
⏱ Last updated Fri Sep 11 15:48:56 UTC 2026 · 📊 GitHub API quota 472/15,000 (3% used, resets in 47m, throttle 3×) |
Marker-gated dependencies are silently dropped from exec-configuration builds — most visibly from sdist
build_toolvenvs — because the python version flags reset to their defaults when the exec transition strips Starlark flags. Same bug class #917 fixed for the venv flag.Real-world failure (enterprise report)
numcodecs 0.16.5 declares
setuptools-scmin[build-system].requires. Duringget_requires_for_build_wheel, setuptools loads the entry points of every installed distribution, importingsetuptools_scm → vcs_versioning → typing_extensions. The lock gatestyping-extensions; python_full_version < '3.11'; the target builds under Python 3.10, but in exec configuration the marker evaluated against the flag default (3.11), so the gate resolved to:empty:setuptools_scmandvcs_versioningwere present in the venv; only the marker-gated link was missing.Mechanism
no_match = ":empty"(uv_project/repository.bzl);decide_markerreadspython_version/python_full_versionfrom Starlark flags (markers/defs.bzl).pep517_whl.tooliscfg = "exec". With--incompatible_exclude_starlark_flags_from_exec_config(flips on in Bazel 10, --incompatible_exclude_starlark_flags_from_exec_config bazelbuild/bazel#26909), python flags reset in exec; the build_tool's rule transition then re-derives the version from the rules_python default → markers decide with the wrong version → gated transitives vanish, while the exec toolchain may resolve a different interpreter entirely.scopeonly when set explicitly on the target (skylib ≥1.8's attr default does not count); transition writes over excluded flags persist. Bazel 8.5.1 only has the--experimental_…spelling and ignoresscopeentirely — with it, even the venv flag and third-party flags reset (breaks the rust tool link), so the exclusion is unusable on 8.x regardless of this fix.Fix
Explicit
scope = "universal"on//py/private/interpreter:python_versionand:freethreaded(propagated by the samepython_transition, consumed by interpreter toolchaintarget_settings). Exact precedent: #917 for//uv/private/constraints/venv:venv.Trade-off (same as #917): exec-built tools inherit the target's python version; there is currently no way to express a deliberately different exec interpreter — unchanged from the venv flag's behavior.
Test plan
New e2e
cases/uv-exec-marker-build-dep: docopt sdist built with setuptools-scm in the build venv, realuv lockcarryingsetuptools-scm → vcs-versioning → typing-extensions; python_full_version < '3.11', targetpython_version = "3.10". The sdist is patched to make thetyping_extensionsimport unconditional, standing in for setuptools' unconditional entry-point loading (in the bare e2e the import chain is version-guarded and the exec interpreter self-heals to 3.11, masking the client's crash).ModuleNotFoundError: typing_extensions, build venv on python 3.11 for a 3.10 target; cquery shows the typing-extensions gate resolving to//private/sccs:emptyin exec.//:typing_extensions, build_tool resolves the 3.10 interpreter; case also passes on plain Bazel 8.5.1 and 9.2.bazel test //py/... //uv/...115/115; e2e regressions: uv-extra-marker, uv-conflict-817 (a+b), uv-abi3-compat-853, uv-sdist-dup-build-deps, uv-sdist-native-inputs, freethreaded-805 all pass; buildifier and gazelle clean.Known pre-existing issues (not addressed here)
uv-sdist-native-build:testis silently skipped in CI (novenvattr → incompatible) and broken if forced (@project__…//:builddoesn't exist).MODULE.bazeldeclares skylib 1.4.2 whilescoperequires ≥1.8 — already true since feat: add scope = "universal" to @pypi//venv for Bazel 10 compatibility #917; worth bumping separately.