Skip to content

Error: 'PyRuntimeInfo' value has no field or method 'pyc_tag' when using platforms #2364

@carpenterjc

Description

@carpenterjc

🐞 bug report

Affected Rule

The issue is caused by the rule:
py_llibrary, py_binary and python_register_toolchains

Is this a regression?

Yes: this worked in 0.36.0 and regressed in 0.37.0

Description

Analysis phase failed when you use a platform, it seems to get confused as to which PyRuntimeInfo it expects to see.

🔬 Minimal Reproduction

Run the following command on the example zip provided:
bazel build //... --platforms=//:x86_platform --nobuild

platform_analysis_broken.zip

🔥 Exception or Error

I first saw this:


Traceback (most recent call last):
        File "C:/dev/_bazel/jarbmqax/external/rules_python/python/private/py_library_rule_bazel.bzl", line 39, column 33, in _py_library_impl
                return bazel_py_library_impl(
        File "C:/dev/_bazel/jarbmqax/external/rules_python/python/private/py_library.bzl", line 74, column 51, in py_library_impl
                precompile_result = semantics.maybe_precompile(ctx, direct_sources)
        File "C:/dev/_bazel/jarbmqax/external/rules_python/python/private/common_bazel.bzl", line 107, column 30, in maybe_precompile
                pyc = _precompile(ctx, src, use_pycache = keep_source)
        File "C:/dev/_bazel/jarbmqax/external/rules_python/python/private/common_bazel.bzl", line 168, column 32, in _precompile
                if not target_toolchain.pyc_tag:
Error: 'PyRuntimeInfo' value has no field or method 'pyc_tag'
Available attributes: bootstrap_template, coverage_files, coverage_tool, files, interpreter, interpreter_path, python_version, stub_shebang

🌍 Your Environment

Operating System:

  
windows
  

Output of bazel version:

  
7.4.0
  

Rules_python version:

  
0.37.1
  

Anything else relevant?

We use platforms

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