From 9e685d7ca07540934e866fdad17ee50946a7d5b5 Mon Sep 17 00:00:00 2001 From: Laramie Leavitt Date: Fri, 15 Aug 2025 21:02:03 -0700 Subject: [PATCH 1/6] fix(local_runtime): Search for libs in sys._base_executable when available. (#3178) Search directory for libraries should look in the same directory as sys._base_executable. Since sys._base_executable may be unset, fallback to sys.executable Found this when trying to build using a venv for [tensorstore](https://github.com/google/tensorstore) on Windows: * Github CI uses nuget to download Python. * Build sets up a Python venv. The venv does not include all the lib directories required to link an extension. Fixes https://github.com/bazel-contrib/rules_python/issues/3172 --------- Co-authored-by: Richard Levasseur --- python/private/get_local_runtime_info.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/python/private/get_local_runtime_info.py b/python/private/get_local_runtime_info.py index 19db3a2935..0ef7681abb 100644 --- a/python/private/get_local_runtime_info.py +++ b/python/private/get_local_runtime_info.py @@ -16,13 +16,31 @@ import sys import sysconfig +_IS_WINDOWS = sys.platform == "win32" +_IS_DARWIN = sys.platform == "darwin" + + +def _get_base_executable(): + """Returns the base executable path.""" + try: + if sys._base_executable: # pylint: disable=protected-access + return sys._base_executable # pylint: disable=protected-access + except AttributeError: + # Bug reports indicate sys._base_executable doesn't exist in some cases, + # but it's not clear why. + # See https://github.com/bazel-contrib/rules_python/issues/3172 + pass + # The normal sys.executable is the next-best guess if sys._base_executable + # is missing. + return sys.executable + data = { "major": sys.version_info.major, "minor": sys.version_info.minor, "micro": sys.version_info.micro, "include": sysconfig.get_path("include"), "implementation_name": sys.implementation.name, - "base_executable": sys._base_executable, + "base_executable": _get_base_executable(), } config_vars = [ From ee04af2937754a9bdeec96e06ff3b21b4c618a77 Mon Sep 17 00:00:00 2001 From: Hong Shin Date: Tue, 26 Aug 2025 21:02:35 +0000 Subject: [PATCH 2/6] add 1.5.4 changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c4da84085..f4ca4c0a80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,16 @@ BEGIN_UNRELEASED_TEMPLATE END_UNRELEASED_TEMPLATE --> +{#1-5-4} +## [1.5.4] - 2025-08-26 + +[1.5.4]: https://github.com/bazel-contrib/rules_python/releases/tag/1.5.4 + +{#v1-5-4-fixed} +### Fixed + +* fix(local_runtime): Search for libs in sys._base_executable when available. #3178 + {#1-5-1} ## [1.5.1] - 2025-07-06 From 16279fd7a2f6d5c3c8ef8a35eedc79ee919ab7ce Mon Sep 17 00:00:00 2001 From: Hong Shin Date: Tue, 26 Aug 2025 21:45:36 +0000 Subject: [PATCH 3/6] rm errant _WINDOWS and _DARWIN --- python/private/get_local_runtime_info.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/python/private/get_local_runtime_info.py b/python/private/get_local_runtime_info.py index 0ef7681abb..1e81e7b02f 100644 --- a/python/private/get_local_runtime_info.py +++ b/python/private/get_local_runtime_info.py @@ -16,10 +16,6 @@ import sys import sysconfig -_IS_WINDOWS = sys.platform == "win32" -_IS_DARWIN = sys.platform == "darwin" - - def _get_base_executable(): """Returns the base executable path.""" try: From 058ffe9778b91b6c5472999c8ceccf672955c536 Mon Sep 17 00:00:00 2001 From: Hong Shin Date: Tue, 26 Aug 2025 21:48:57 +0000 Subject: [PATCH 4/6] fix bad merge detritus --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f38a536ba..13d13399cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,7 +56,7 @@ END_UNRELEASED_TEMPLATE ### Fixed * fix(local_runtime): Search for libs in sys._base_executable when available. #3178 -gg======= + {#1-5-3} ## [1.5.3] - 2025-08-11 From 14ad5873926997ae0de5f9b006e16d854565dd22 Mon Sep 17 00:00:00 2001 From: Hong Shin Date: Tue, 26 Aug 2025 21:49:55 +0000 Subject: [PATCH 5/6] re-add whitespace --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13d13399cc..7d8b2686d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,7 @@ END_UNRELEASED_TEMPLATE * (core) builds work again on `7.x` `WORKSPACE` configurations ([#3119](https://github.com/bazel-contrib/rules_python/issues/3119)). + {#1-5-1} ## [1.5.1] - 2025-07-06 From d06a4040c780d627cdd1566ad31ec86bb7c75f04 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Wed, 27 Aug 2025 22:04:39 -0700 Subject: [PATCH 6/6] copy edit changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d8b2686d7..c5b86b6b6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,7 +55,8 @@ END_UNRELEASED_TEMPLATE {#v1-5-4-fixed} ### Fixed -* fix(local_runtime): Search for libs in sys._base_executable when available. #3178 +* (local toolchains) Search for libs in sys._base_executable when available + ([#3178](https://github.com/bazel-contrib/rules_python/issues/3178)). {#1-5-3} ## [1.5.3] - 2025-08-11