Description
🐞 bug report
Affected Rule
The issue is caused by the modules_mapping rule: https://github.com/bazelbuild/rules_python/blob/main/gazelle/modules_mapping/def.bzl#L41
Is this a regression?
No
Description
Following the newly added bzlmod document in #1149 to try the rules_python with bzlmod, however the current example build_file_generation will complain the @pip
repository could not be resolved when build the modules_map:
$ bazel build --enable_bzlmod //:modules_map
ERROR: rules_python/examples/build_file_generation/BUILD.bazel:25:16: no such package '@pip//flask': The repository '@pip' could not be resolved: Repository '@pip' is not defined and referenced by '//:modules_map'
After some test, I believe this is due to the modules_mapping somewhat always point to the @pip
repository in the old WORKSPACE instead of the one defined in MODULE.bazel. This is annoying because you have to still write all the snippet in WORKSPACE file with bzlmod in order to use the gazelle plugin (//:gazelle_python_manifest.update). Especially if you want to start a new bazel python project using bzlmod, you need write duplicate snippets for both MODULE.bazel and WORKSPACE file.
🔬 Minimal Reproduction
This can be easily reproduced by creating a WORKSPACE.bzlmod file in the build_file_generation folder:
$ git clone https://github.com/bazelbuild/rules_python.git
$ cd rules_python/examples/build_file_generation
$ touch WORKSPACE.bzlmod
$ bazel build --enable_bzlmod //:modules_map
The empty WORKSPACE.bzlmod would clear all the effects of snippets defined in WORKSPACE. In bzlmod, we already finish all the setup in the MODULE.bazel file. Therefore, we don't need the WORKSPACE file.
🔥 Exception or Error
N/A
🌍 Your Environment
Operating System:
Debian 6.1.12-1 (2023-02-15) x86_64 GNU/Linux
Output of bazel version
:
Bazelisk version: v1.12.2
Build label: 6.1.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Mar 15 15:44:56 2023 (1678895096)
Build timestamp: 1678895096
Build timestamp as int: 1678895096
Rules_python version:
0.19.0
Anything else relevant?
N/A