Skip to content

uv-managed interpreters are not discovered on macOS: wrong store directory #109

Description

@henryiii

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 store

Suggested 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions