diff --git a/CHANGELOG.md b/CHANGELOG.md index 48bb97f644..c5b86b6b6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,17 @@ 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 + +* (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 diff --git a/python/private/get_local_runtime_info.py b/python/private/get_local_runtime_info.py index 19db3a2935..1e81e7b02f 100644 --- a/python/private/get_local_runtime_info.py +++ b/python/private/get_local_runtime_info.py @@ -16,13 +16,27 @@ import sys import sysconfig +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 = [