From dc2d3c211210364bb3a940ee82bbc81669d530af Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Sun, 3 Aug 2025 11:55:50 +0900 Subject: [PATCH 1/2] 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 --- CHANGELOG.md | 1 + python/private/py_executable.bzl | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2535a0f1dc..f90626f1aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,7 @@ END_UNRELEASED_TEMPLATE * (toolchains) use "command -v" to find interpreter in `$PATH` ([#3150](https://github.com/bazel-contrib/rules_python/pull/3150)). * (pypi) `bazel vendor` now works in `bzlmod` ({gh-issue}`3079`). +* (core) builds work again on `7.x` `WORKSPACE` configurations ({gh-issue}`3119`). {#v0-0-0-added} ### Added diff --git a/python/private/py_executable.bzl b/python/private/py_executable.bzl index 7e50247e61..9927975aa8 100644 --- a/python/private/py_executable.bzl +++ b/python/private/py_executable.bzl @@ -796,6 +796,7 @@ def _create_stage1_bootstrap( is_for_zip, runtime_details, venv = None): + """Create a legacy bootstrap script that is written in Python.""" runtime = runtime_details.effective_runtime if venv: @@ -805,8 +806,11 @@ def _create_stage1_bootstrap( python_binary_actual = venv.interpreter_actual_path if venv else "" - # Runtime may be None on Windows due to the --python_path flag. - if runtime and runtime.supports_build_time_venv: + # Guard against the following: + # * Runtime may be None on Windows due to the --python_path flag. + # * Runtime may not have 'supports_build_time_venv' if a really old version is autoloaded + # on bazel 7.6.x. + if runtime and getattr(runtime, "supports_build_time_venv", False): resolve_python_binary_at_runtime = "0" else: resolve_python_binary_at_runtime = "1" From a4476c0a92b49444d47fdc288b0b3c1afd3bf286 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sun, 10 Aug 2025 20:04:44 -0700 Subject: [PATCH 2/2] use regular markdown url for issue ref --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f90626f1aa..27c84389c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,7 +107,8 @@ END_UNRELEASED_TEMPLATE * (toolchains) use "command -v" to find interpreter in `$PATH` ([#3150](https://github.com/bazel-contrib/rules_python/pull/3150)). * (pypi) `bazel vendor` now works in `bzlmod` ({gh-issue}`3079`). -* (core) builds work again on `7.x` `WORKSPACE` configurations ({gh-issue}`3119`). +* (core) builds work again on `7.x` `WORKSPACE` configurations + ([#3119](https://github.com/bazel-contrib/rules_python/issues/3119)). {#v0-0-0-added} ### Added