10000 transitive bzlmod toolchains can cause name collisions · Issue #1232 · bazel-contrib/rules_python · GitHub
[go: up one dir, main page]

Skip to content
transitive bzlmod toolchains can cause name collisions #1232
Closed
@rickeylev

Description

@rickeylev

🐞 bug report

Affected Rule

The python.toolchain() extension

Is this a regression?

Yes and no. Bzlmod support is beta and it's been present from the start. This was clearly possible with WORKSPACE, but better known as a potential issue there. Bzlmod just makes it easier and less obvious.

Description

The repos created by python.toolchain() are all created in the rules_python~python namespace (module="rules_python", extension="python"). Because the user is able to directly specify the name of the created repo, if two modules both specify the same name, a conflict occurs.

This is partially because in the python.toolchain implementation, we walk the module graph for all the toolchain calls and create any requested toolchains. This is WAI, as modules may need different Python versions, so must be able to request their particular Python version be made available.

A partial workaround is to use a unique name, e.g include the module name in the toolchain call: python.toolchain(name="my_module_python3_10"). I say partial because, while this makes the toolchain available, another module can register a different python version, and then the usual register_toolchains() registration ordering applies. i.e. a sub-module doesn't have a guarantee the toolchain they asked for will be used (this will be fixed as part of making the multi-version toolchains work with bzlmod).

🔬 Minimal Reproduction

A simple reproduction is to have a sub-module call python.toolchain() with the same name as the root module.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0