-
-
Notifications
You must be signed in to change notification settings - Fork 617
Description
🐞 bug report
Affected Rule
py_binary
, py_test
, and py_library
in 1.5.0 and 1.5.1.
Is this a regression?
Yes. It was not present in 1.4.1, but is present in 1.5.0.
Description
Bazel 7.6.1 will use the builtin PyRuntimeInfo
when building under WORKSPACE
. The PyRuntimeInfo.supports_build_time_venv
field (added in #2760) breaks, since it exists in rules_python
1.5.0 and 1.5.1, but doesn't exist in the builtin provider.
WORKSPACE
builds work with Bazel 8.0.0 and 8.3.1. Bzlmod builds work with Bazel 7.6.1.
🔬 Minimal Reproduction
WORKSPACE
:
workspace(name = "pyruntimeinfo_breakage")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_python",
sha256 = "7b9039c31e909cf59eeaea8ccbdc54f09f7ebaeb9609b94371c7de45e802977c",
strip_prefix = "rules_python-1.5.0",
url = "https://github.com/bazel-contrib/rules_python/releases/download/1.5.0/rules_python-1.5.0.tar.gz",
)
load("@rules_python//python:repositories.bzl", "py_repositories")
py_repositories()
MODULE.bazel
(optional):
module(name = "pyruntimeinfo_breakage")
bazel_dep(name = "rules_python", version = "1.5.0")
BUILD
:
load("@rules_python//python:py_binary.bzl", "py_binary")
py_binary(
name = "example",
srcs = ["example.py"],
)
Then run:
touch example.py
USE_BAZEL_VERSION=7.6.1 bazel build --enable_workspace --noenable_bzlmod //...
🔥 Exception or Error
$ USE_BAZEL_VERSION=7.6.1 bazel build --enable_workspace --noenable_bzlmod //...
Starting local Bazel server and connecting to it...
ERROR: BUILD:3:10: in py_binary rule //:example:
Traceback (most recent call last):
File ".../external/rules_python/python/private/py_binary_rule.bzl", line 24, column 30, in _py_binary_impl
return py_executable_impl(
File ".../external/rules_python/python/private/py_executable.bzl", line 255, column 35, in py_executable_impl
return py_executable_base_impl(
File ".../external/rules_python/python/private/py_executable.bzl", line 1140, column 46, in py_executable_base_impl
exec_result = semantics.create_executable(
File ".../external/rules_python/python/private/py_executable.bzl", line 365, column 33, in _create_executable
_create_stage1_bootstrap(
File ".../external/rules_python/python/private/py_executable.bzl", line 809, column 27, in _create_stage1_bootstrap
if runtime and runtime.supports_build_time_venv:
Error: 'PyRuntimeInfo' value has no field or method 'supports_build_time_venv'
Available attributes: bootstrap_template, coverage_files, coverage_tool, files, interpreter, interpreter_path, python_version, stub_shebang
ERROR: BUILD:3:10: Analysis of target '//:example' failed
ERROR: Analysis of target '//:example' failed; build aborted
🌍 Your Environment
Operating System:
$ uname -mrs
Darwin 24.5.0 arm64
Output of bazel version
:
$ USE_BAZEL_VERSION=7.6.1 bazel version
Bazelisk version: 1.26.0
Starting local Bazel server and connecting to it...
Build label: 7.6.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Mar 31 17:11:07 2025 (1743441067)
Build timestamp: 1743441067
Build timestamp as int: 1743441067
Rules_python version:
$ grep -- '"rules_python-' WORKSPACE
strip_prefix = "rules_python-1.5.0",
Anything else relevant?
I encountered this while building bazel-contrib/rules_scala using Bazel 7.6.1 in WORKSPACE
mode after upgrading to rules_python
1.5.1.
Trying --incompatible_autoload_externally
with either +@rules_python
or +PyRuntimeInfo
breaks with the same error, but preceded with the warning:
WARNING: Couldn't auto load rules or symbols,
because no dependency on module/repository 'rules_python' found.
This will result in a failure if there's a reference to those rules or symbols.
Nothing I could do could avoid using the builtin PyRuntimeInfo
under Bazel 7.6.1 when building under WORKSPACE
.