Skip to content

Commit acf7507

Browse files
aignasrickeylev
andauthored
fix(core): do not assume rules_python runtime (#3134)
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 we will crash with attribute error. I could not think how to add a unit test, which would test this fix because it seems to only happen with a released version of rules_python where we are not using `local_repository` override. Fixes #3119 --------- Co-authored-by: Richard Levasseur <[email protected]>
1 parent 537fe30 commit acf7507

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ END_UNRELEASED_TEMPLATE
109109
* (toolchains) use "command -v" to find interpreter in `$PATH`
110110
([#3150](https://github.com/bazel-contrib/rules_python/pull/3150)).
111111
* (pypi) `bazel vendor` now works in `bzlmod` ({gh-issue}`3079`).
112+
* (core) builds work again on `7.x` `WORKSPACE` configurations
113+
([#3119](https://github.com/bazel-contrib/rules_python/issues/3119)).
112114

113115
{#v0-0-0-added}
114116
### 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)