Skip to content

python_register_toolchains does not select appropriate interpreter for target platform#704

Description

@nvachhar

馃悶 bug report

Affected Rule

The issue is caused by the rule: python_register_toolchains

Is this a regression?

No

Description

python_register_toolchains registers the toolchains with exec_compatible_with but should register the toolchains with target_compatible_with instead according to the design here: https://github.com/bazelbuild/rules_python/blob/main/proposals/2019-02-12-design-for-a-python-toolchain.md

The result is cross-platform builds end up with an exec platform platform interpreter in the runfiles tree instead of a target platform interpeter.

馃敩 Minimal Reproduction

From a checkout of https://github.com/nvachhar/rules_python_bug:

馃敟 Exception or Error

Building for macos-x86_64 on a macos-x86_64 host results in an x86_64 interpeter.

$ bazel build --platforms :macos-x86_64 hello
INFO: Build option --platforms has changed, discarding analysis cache.
INFO: Analyzed target //:hello (0 packages loaded, 3974 targets configured).
INFO: Found 1 target...
Target //:hello up-to-date:
  bazel-bin/hello
INFO: Elapsed time: 0.352s, Critical Path: 0.03s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
$ ls bazel-bin/hello.runfiles                
MANIFEST*  __init__.py*  __main__/  python3_9_x86_64-apple-darwin/

Building for macos-arm64 on a macos-x86_64 host still results in an x86_64 interpeter.

$ bazel build --platforms :macos-arm64 hello 
INFO: Build option --platforms has changed, discarding analysis cache.
INFO: Analyzed target //:hello (0 packages loaded, 3974 targets configured).
INFO: Found 1 target...
Target //:hello up-to-date:
  bazel-bin/hello
INFO: Elapsed time: 0.387s, Critical Path: 0.03s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
$ ls bazel-bin/hello.runfiles               
MANIFEST*  __init__.py*  __main__/  python3_9_x86_64-apple-darwin/

馃實 Your Environment

Operating System:

  
macOS 12.3.1
  

Output of bazel version:

  
Bazelisk version: development
Build label: 5.0.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Jan 19 14:15:55 2022 (1642601755)
Build timestamp: 1642601755
Build timestamp as int: 1642601755
  

Rules_python version:

  
0.8.1
  

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions