Skip to content

Commit dc2d3c2

Browse files
committed
fix(core): do not assume rules_python runtime
This change reverts the behaviour where we assume that particular attributes will be always present - if bazel is doing autoloading for WORKSPACE builds (7.6.1), then this will crash. I could not think how to add a unit test, so just adding the fix here and a comment. Fixes #3119
1 parent bc788d5 commit dc2d3c2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ END_UNRELEASED_TEMPLATE
107107
* (toolchains) use "command -v" to find interpreter in `$PATH`
108108
([#3150](https://github.com/bazel-contrib/rules_python/pull/3150)).
109109
* (pypi) `bazel vendor` now works in `bzlmod` ({gh-issue}`3079`).
110+
* (core) builds work again on `7.x` `WORKSPACE` configurations ({gh-issue}`3119`).
110111

111112
{#v0-0-0-added}
112113
### Added

python/private/py_executable.bzl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ def _create_stage1_bootstrap(
796796
is_for_zip,
797797
runtime_details,
798798
venv = None):
799+
"""Create a legacy bootstrap script that is written in Python."""
799800
runtime = runtime_details.effective_runtime
800801

801802
if venv:
@@ -805,8 +806,11 @@ def _create_stage1_bootstrap(
805806

806807
python_binary_actual = venv.interpreter_actual_path if venv else ""
807808

808-
# Runtime may be None on Windows due to the --python_path flag.
809-
if runtime and runtime.supports_build_time_venv:
809+
# Guard against the following:
810+
# * Runtime may be None on Windows due to the --python_path flag.
811+
# * Runtime may not have 'supports_build_time_venv' if a really old version is autoloaded
812+
# on bazel 7.6.x.
813+
if runtime and getattr(runtime, "supports_build_time_venv", False):
810814
resolve_python_binary_at_runtime = "0"
811815
else:
812816
resolve_python_binary_at_runtime = "1"

0 commit comments

Comments
 (0)