Skip to content

Commit fdaca1b

Browse files
committed
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]> (cherry picked from commit acf7507) Cherry-pick notes: adjusted changelog to mention 1.5.2
1 parent 277026b commit fdaca1b

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
@@ -62,6 +62,8 @@ END_UNRELEASED_TEMPLATE
6262
### Fixed
6363
* (pypi) Correctly pull `sdist` distributions using `pip`
6464
([#3131](https://github.com/bazel-contrib/rules_python/pull/3131)).
65+
* (core) builds work again on `7.x` `WORKSPACE` configurations
66+
([#3119](https://github.com/bazel-contrib/rules_python/issues/3119)).
6567

6668
{#1-5-1}
6769
## [1.5.1] - 2025-07-06

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)