Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tervay-bdai opened this issue Jul 13, 2023 · 3 comments
Closed

Comments

@tervay-bdai
Copy link

tervay-bdai commented Jul 13, 2023

🐞 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
  
@tervay-bdai
Copy link
Author

This seems to be similar to bazelbuild/bazel#17289, but different, since the suggested fix (adding bazel_dep(name = "platforms", version = "0.0.5")) does not fix this one.

@chrislovecnm
Copy link
Collaborator

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.

So with bzlmod the configurations in the workspace file are not used. You need bzlmod configurations in the MODULE.bazel file, and also have an empty WORKSPACE.bzlmod file.

You can use WORKSPACE like configurations in the WORKSPACE.bzlmod file. But it is better to use the bzlmod configuration.

@tervay-bdai
Copy link
Author

Seems this is intentional:

if BZLMOD_ENABLED:
# you cannot used native.register_toolchains when using bzlmod.
register_toolchains = False

Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants