Repository navigation
feat: make Python version project scoping opt-in - #4377
Spikhalskiy wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
aignas
left a comment
There was a problem hiding this comment.
A few questions, but in general LGTM.
| "active_directories": { | ||
| "default": [ | ||
| "//bindings", | ||
| "@@rules_python+", | ||
| ], | ||
| }, |
There was a problem hiding this comment.
What about repositories that are created due to the pip.parse tag class? Does the @@rules_python+ means that those will be also included?
| @@ -0,0 +1,35 @@ | |||
| """Analysis assertions for target and exec configuration propagation.""" | |||
There was a problem hiding this comment.
probe.bzl is a very abstract name. Is there a way to make it more concrete?
|
Fabian has also brought up a desire to reign in config state explosion. The basic problem with using PROJECTS.scl is it means every end-user bazel project has to configure their own. Would one of these options work better than this?
It's somewhat tricky because a handful of flags matter, but not always (e.g. compiling LLVM doesn't care about python, but compiling a python C extension does). |
| `scope` accepts: | ||
|
|
||
| * `"universal"` (the default): the version reaches every target, including exec | ||
| tools such as the precompiler. |
There was a problem hiding this comment.
"such as the precompiler" -- is the precompiler ending up in multiple configs one of the motivations for this PR?
Good catch, that had not occured to me. |
Python version transitions also reach native dependencies that don't use Python, so a C++ or Rust library under bindings for several Python versions is configured once per version. Add a root-module
config.python_version_scope(scope = "project")tag that gives//python/config_settings:python_versionBazel's project scope. Under project scope the public flag label becomes an alias to a flag in the generated config repository, whosePROJECT.scldelegates ownership to the consumer's//:PROJECT.sclthrough anactualalias. Targets outside it see the command-line version and share one configuration. Bazel reads the project file of every top-level target's package, so only the opt-in ships that alias, and other builds need no rootPROJECT.scl. Universal scope stays the default, and tags from dependency modules are ignored.Project scope requires Bazel 9.2 or later, the first release that keeps project-scoped flags across exec transitions (bazelbuild/bazel#28320). Owned exec tools such as the precompiler keep the selected version, which preserves the requirement behind #4335. Older Bazel versions fail with an explicit error.
aspect_rules_py terminals set this flag as well as their own; the matching opt-in there is aspect-build/rules_py#1650.
An integration test covers target and exec propagation, convergence of the native dependency's configuration, the unchanged default, and ignored dependency-module tags.
Fixes #4375