Support consumer-configured project scoping for python_version

Aberta
#4,375 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@Spikhalskiy já está trabalhando nisso.

Desde 28/10/2026.

  • #4377 de @Spikhalskiy — aberto

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
35/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
python
Domínio
build-system

Direção de pesquisa

Start by reading the python_version flag declaration in @rules_python//python/config_settings and the root module's Python configuration API; then review the target and exec transitions, including the behavior needed by the precompiler in #4335. The issue describes the desired opt-in and ownership boundary, but leaves the API design and supported Bazel versions open. Done means documenting a supported root-module option and testing target transitions and exec tools while preserving the default behavior.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Relevant Rules

@rules_python//python/config_settings:python_version and the root module's Python configuration API.

Description

I build Python extensions for multiple interpreter versions, with large Python-independent Rust/C++ libraries underneath them. The bindings need different Python configurations, but the native libraries should share a configuration when their other inputs are equal.

For example:

Python 3.11 binding -> native core
Python 3.12 binding -> native core

A version transition on a binding also reaches its native dependencies unless that setting is reset. This creates extra configured targets and can change action keys even where the native library does not use Python. Exec-only flag trimming does not address ordinary target-configured libraries.

Bazel's configurability roadmap explicitly describes project-scoped flags as a way to avoid this cache fragmentation; its public example demonstrates the mechanism.

Currently I need a source patch to make the version flag project-scoped and associate it with my project's ownership definition. I would like to configure that through a supported API.

Describe the solution you'd like

An opt-in, root-module-controlled configuration that:

  1. Selects project scope for the Python-version flag while preserving the existing default behavior.
  2. Associates the flag with a consumer-supplied PROJECT.scl definition, without requiring a patch to the dependency's source tree.

The consumer would own the paths for bindings, intervening aliases, Python headers/runtimes and Python-sensitive build scripts. Python-independent native dependencies would remain outside those paths. The API need not infer that boundary automatically.

Please document the supported Bazel versions and test both target transitions and exec tools. In particular, #4335 deliberately sets universal scope so Bazel 10's precompiler uses the correct interpreter. An opt-in project mode must account for that correctness requirement rather than simply replacing the default.

This request uses Bazel's existing invocation-baseline reset semantics. It does not require the separate declared-default reset proposal in bazelbuild/bazel#32178.

Describe alternatives you've considered

Patching the flag declaration and adding a project-definition alias works as a local workaround, but ties the policy to dependency implementation details. Custom reset transitions require maintaining explicit boundaries and wrappers. A supported project-scoping option would let the ruleset own the integration while the consuming project owns its dependency boundary.

Linguagem predominante
Starlark
Estrelas
692
Forks
734
Merge médio
11h 2min
PRs com merge (30d)
150

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de bazel-contrib/rules_python

Todas as issues de bazel-contrib/rules_python

Issues semelhantes

Mais issues de Build System

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.