This was discovered looking into wntrblm/nox#1139. Report from that investigation below.
🤖 AI text below 🤖
Problem
_propose_from_uv falls back to platformdirs.user_data_path("uv") / "python" when neither UV_PYTHON_INSTALL_DIR nor XDG_DATA_HOME is set. On macOS that is ~/Library/Application Support/uv/python, but uv intentionally follows the XDG convention on macOS and stores interpreters in ~/.local/share/uv/python:
$ uv python dir/Users/me/.local/share/uv/python
So on macOS the uv store is silently invisible to discovery. The interpreters are only found via the ~/.local/bin shims on PATH (which users can disable, and which downstreams such as nox are moving to suppress: wntrblm/nox#1139).
Reproduction (macOS, python-discovery 1.5.0)
With cpython-3.8.20-macos-aarch64-none present in ~/.local/share/uv/python and ~/.local/bin removed from PATH:
importosos.environ['PATH'] =':'.join(pforpinos.environ['PATH'].split(':') if'.local/bin'notinp)
frompython_discoveryimportget_interpreterprint(get_interpreter('3.8')) # Noneos.environ['UV_PYTHON_INSTALL_DIR'] =os.path.expanduser('~/.local/share/uv/python')
print(get_interpreter('3.8')) # found in the uv storeSuggested fix
Replicate uv's directory logic (XDG-style ~/.local/share/uv/python on every non-Windows platform, including macOS) instead of platformdirs. Windows may need a check too — uv uses %APPDATA%\uv\python (Roaming), while platformdirs.user_data_path("uv") points at Local; I have only verified the macOS behavior.
Environment: macOS 15 (arm64), python-discovery 1.5.0, uv 0.9.x.
This was discovered looking into wntrblm/nox#1139. Report from that investigation below.
🤖 AI text below 🤖
Problem
_propose_from_uvfalls back toplatformdirs.user_data_path("uv") / "python"when neitherUV_PYTHON_INSTALL_DIRnorXDG_DATA_HOMEis set. On macOS that is~/Library/Application Support/uv/python, but uv intentionally follows the XDG convention on macOS and stores interpreters in~/.local/share/uv/python:So on macOS the uv store is silently invisible to discovery. The interpreters are only found via the
~/.local/binshims onPATH(which users can disable, and which downstreams such as nox are moving to suppress: wntrblm/nox#1139).Reproduction (macOS, python-discovery 1.5.0)
With
cpython-3.8.20-macos-aarch64-nonepresent in~/.local/share/uv/pythonand~/.local/binremoved fromPATH:Suggested fix
Replicate uv's directory logic (XDG-style
~/.local/share/uv/pythonon every non-Windows platform, including macOS) instead ofplatformdirs. Windows may need a check too — uv uses%APPDATA%\uv\python(Roaming), whileplatformdirs.user_data_path("uv")points at Local; I have only verified the macOS behavior.Environment: macOS 15 (arm64), python-discovery 1.5.0, uv 0.9.x.