Skip to content

Using bzlmod (at all) breaks Python interpreter version specifications #1313

@tervay-bdai

Description

@tervay-bdai

🐞 bug report

Affected Rule

The issue is caused by the rule: Specific version-related `py_binary`

Is this a regression?

No, does not work as far back as 0.18.0, and repro does not work on 0.17.0.

Description

Enabling the --experimental_enable_bzlmod flag (even with an empty MODULE.bazel) causes Bazel to use the system Python interpreter, not the one specified in WORKSPACE.

🔬 Minimal Reproduction

https://github.com/tervay-bdai/pyexample

This has a Python 3.9 toolchain set up in WORKSPACE. My system interpreter is 3.10.6. The bazelmod enable flag can be enabled with --config=bzlmod if you want. You should see two different versions (assuming your system interpreter is not 3.9).

🔥 Exception or Error

  
13:02 | ~/workspace/rpv | $ bazel run //src:main
INFO: Analyzed target //src:main (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //src:main up-to-date:
  bazel-bin/src/_main
INFO: Elapsed time: 0.203s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/src/main
3.9.16

13:02 | ~/workspace/rpv | $ bazel run //src:main --config=bzlmod
INFO: Analyzed target //src:main (66 packages loaded, 515 targets configured).
INFO: Found 1 target...
Target //src:main up-to-date:
  bazel-bin/src/_main
INFO: Elapsed time: 2.131s, Critical Path: 0.00s
INFO: 7 processes: 7 internal.
INFO: Build completed successfully, 7 total actions
INFO: Running command line: bazel-bin/src/main
3.10.6
  

🌍 Your Environment

Operating System:

  
14:30 | ~/workspace/rpv | $ uname -a
Linux jtervay-LT 5.19.0-46-generic #47~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jun 21 15:35:31 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
  

Output of bazel version:

  
14:30 | ~/workspace/rpv | $ bazel version
Bazelisk version: v1.16.0
Build label: 6.2.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Jun 2 16:59:58 2023 (1685725198)
Build timestamp: 1685725198
Build timestamp as int: 1685725198
  

Rules_python version:

  
0.24.0
  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions