Skip to content

Commit 9a49f15

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 39703fa commit 9a49f15

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
@@ -101,6 +101,7 @@ END_UNRELEASED_TEMPLATE
101101
`# gazelle:python_resolve_sibling_imports true`
102102
* (pypi) Show overridden index URL of packages when downloading metadata have failed.
103103
([#2985](https://github.com/bazel-contrib/rules_python/issues/2985)).
104+
* (core) builds work again on `7.x` `WORKSPACE` configurations ({gh-issue}`3119`).
104105

105106
{#v0-0-0-added}
106107
### 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)