Skip to content

🐛 fix(uv): return absolute paths for a relative install dir - #289

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
gaborbernat:fix/uv-install-dir-absolute
Nov 30, 2026
Merged

gaborbernat merged 2 commits into
tox-dev:mainfrom
gaborbernat:fix/uv-install-dir-absolute

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Setting UV_PYTHON_INSTALL_DIR to a relative folder made discovery return relative interpreter paths. After the calling tool changed directory, that path named a different Python or nothing, and a second lookup in the same process could pair the first folder's details with the wrong binary. 🐛 Interpreters found there now come back as absolute paths. Fixes #284.

$ mkdir -p project/store/cpython-3.13-linux-x86_64-gnu/bin
$ ln -s "$(readlink -f "$(uv python find 3.13)")" project/store/cpython-3.13-linux-x86_64-gnu/bin/python
$ cd project && PATH=/usr/bin UV_PYTHON_INSTALL_DIR=store python -c 'import os
from python_discovery import get_interpreter
exe = get_interpreter("3.13").executable
os.chdir("/")
print(exe, os.path.exists(exe))'

Before:

store/cpython-3.13-linux-x86_64-gnu/bin/python False

After:

/home/me/demo/project/store/cpython-3.13-linux-x86_64-gnu/bin/python True

The folder is still searched from the current directory, as uv anchors it. Discovery now makes it absolute when the lookup runs, as it already does for interpreters found on PATH.

Absolute values and uv's default locations behave as before. Lookups from two directories still search two stores, as uv would.

Reported by oss-scanner: ANT-2026-JQLRJOIU.

Discovery searched a relative UV_PYTHON_INSTALL_DIR as written and
returned the interpreters it found with relative paths, so a returned
executable depended on the directory the caller was in when it used
it. uv anchors a relative store at the working directory, so do the
same and return absolute paths.

Fixes tox-dev#284.
Reported by oss-scanner as ANT-2026-JQLRJOIU.
@gaborbernat gaborbernat added the bug Something isn't working label Nov 29, 2026
The hand-built from_exe mock only checked the path it received, which the
uv_probed fixture already records.
@gaborbernat
gaborbernat merged commit 008577d into tox-dev:main Nov 30, 2026
24 checks passed
@gaborbernat
gaborbernat deleted the fix/uv-install-dir-absolute branch November 30, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A relative UV_PYTHON_INSTALL_DIR returns a relative executable path

1 participant