Skip to content

fix(local_runtime): Search for libs in sys._base_executable when available. #3178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 16, 2025

Conversation

laramiel
Copy link
Contributor

@laramiel laramiel commented Aug 14, 2025

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 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 #3172

Search directory for librarys should look in the same directory as sys._base_executable.
Since sys._base_executable may be unset, fallback to sys.executable
@rickeylev
Copy link
Collaborator

base_executable is missing when building within a venv

But sys._base_executable is suppose to point where the venv's interpreter is, that's its purpose.

I wonder if this problem manifests when the underlying interpreter can't be found, but the venv is otherwise functional? Maybe if the venv has a copy, not symlink to the interpreter? IIRC, windows venvs create copies of python.exe and rely on pyvenv.cfg to point to the correct pythonhome location. Hm, maybe hardlinks on linux/mac result in something similar? ISTR macs also have some funny tricks they pull with the python executable.

In anycase, LGTM

@rickeylev rickeylev enabled auto-merge August 15, 2025 23:07
@rickeylev rickeylev added this pull request to the merge queue Aug 15, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 15, 2025
@aignas aignas added this pull request to the merge queue Aug 16, 2025
Merged via the queue into bazel-contrib:main with commit cda5877 Aug 16, 2025
3 checks passed
@laramiel
Copy link
Contributor Author

I thought that it was trying to be the realpath of sys.executable, usually:

https://github.com/python/cpython/blob/main/Modules/getpath.py

But in any event, we may create nested venvs, and sys._base_executable is used to create those nested venvs, so I think that's the appropriate path to use. Also the windows copy thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GetPythonInfo failed on trying to update to 1.5.3
3 participants