- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 636
 
Description
π bug report
Affected Rule
The issue is caused by the rule:  py_binary
Is this a regression?
Yes, the previous version in which this bug was not present was: Bazel 6.5.0.Description
When using Bazel 7.0.0 or 7.3.1 (and presumably others in that range), the system Python is used where the @rules_python//python/config_settings:python_version was previously respected (by Bazel 6.5.0) when running with a WORKSPACE file instead of a MODULE.bazel file. The rules_python/examples/multi_python_versions/ example in this very repository exhibits the problem, if you remove the MODULE.bazel* files and WORKSPACE.bzlmod.
This makes it difficult to upgrade to Bazel 7 first and do the MODULE.bazel migration after, which otherwise would seem like an attractive migration path.
π¬ Minimal Reproduction
Setup:
git clone https://github.com/bazelbuild/rules_python
cd rules_python/examples/multi_python_versions/
rm WORKSPACE.bzlmod MODULE.bazel*By removing WORKSPACE.bzlmod and MODULE.bazel*, we're now in a situation with just a WORKSPACE file. The following command works, and correctly reports 3.11:
USE_BAZEL_VERSION=6.5.0 bazelisk run \
    --@rules_python//python/config_settings:python_version=3.11 //tests:version_defaultWhen I test the same thing under Bazel 7.3.1 reports 3.10 (which is the system Python on Ubuntu 22) or 3.12 (which is the system Python on Ubuntu 24), depending on the system I run it on.
USE_BAZEL_VERSION=7.3.1 bazelisk run \
    --@rules_python//python/config_settings:python_version=3.11 //tests:version_defaultπ Your Environment
Operating System:
  
Distributor ID:	Ubuntu
Description:	Ubuntu 24.04.1 LTS
Release:	24.04
Codename:	noble
  
Output of bazel version:
  
Bazelisk version: v1.20.0
Build label: 7.3.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Aug 19 16:12:50 2024 (1724083970)
Build timestamp: 1724083970
Build timestamp as int: 1724083970
  
Rules_python version:
  
commit 9a98e8c1f18fb8b1c41e1d409088da9c72cee352 (HEAD -> main, origin/main, origin/HEAD)
  
Anything else relevant?
Previously mentioned on https://bazelbuild.slack.com/archives/CA306CEV6/p1727352240596449