uv icon indicating copy to clipboard operation
uv copied to clipboard

Respect `XDG_DATA_HOME` on macOS if set

Open zanieb opened this issue 1 year ago • 3 comments

Rather than using Application Support for state storage, we use XDG_DATA_HOME if it is set. This feels like a reasonable compromise respecting the OS defaults while allowing users to opt-in to XDG.

Closes #4411

e.g.

❯ export XDG_DATA_HOME="$HOME/.local/share"
❯ cargo run -- python install
Looking for installation Python 3.12.1 (any-3.12.1-any-any-any)
Looking for installation Python 3.11.7 (any-3.11.7-any-any-any)
Looking for installation Python 3.10.13 (any-3.10.13-any-any-any)
Looking for installation Python 3.9.18 (any-3.9.18-any-any-any)
Looking for installation Python 3.8.18 (any-3.8.18-any-any-any)
Looking for installation Python 3.8.12 (any-3.8.12-any-any-any)
Found 6/6 installations requiring installation
Downloading cpython-3.12.1-macos-aarch64-none
Downloading cpython-3.11.7-macos-aarch64-none
Downloading cpython-3.10.13-macos-aarch64-none
Downloading cpython-3.9.18-macos-aarch64-none
Installed Python 3.12.1 to /Users/zb/.local/share/uv/python/cpython-3.12.1-macos-aarch64-none
Installed Python 3.11.7 to /Users/zb/.local/share/uv/python/cpython-3.11.7-macos-aarch64-none
Installed Python 3.10.13 to /Users/zb/.local/share/uv/python/cpython-3.10.13-macos-aarch64-none
Installed Python 3.9.18 to /Users/zb/.local/share/uv/python/cpython-3.9.18-macos-aarch64-none
Downloading cpython-3.8.18-macos-aarch64-none
Downloading cpython-3.8.12-macos-aarch64-none
Installed Python 3.8.18 to /Users/zb/.local/share/uv/python/cpython-3.8.18-macos-aarch64-none
Installed Python 3.8.12 to /Users/zb/.local/share/uv/python/cpython-3.8.12-macos-aarch64-none
Installed 6 installations in 8s

zanieb avatar Jul 03 '24 13:07 zanieb

In ruff, we're using etcetera for xdg directories, is there a reason not to do this in uv, too?

konstin avatar Jul 03 '24 13:07 konstin

I'm just following the patterns we're using in our other crates here. I don't have context on why not etcetera, cc @charliermarsh. We could change separately from this if we want.

zanieb avatar Jul 03 '24 13:07 zanieb

Since we're not a GUI application I'm basically down to just move over to XDG entirely too btw.

zanieb avatar Jul 03 '24 14:07 zanieb

I'm planning to move us to XDG entirely for macOS (maybe not for the cache for now, though). How much do we care about backwards-compatibility here given that it's preview-only?

If we make it backwards-compatible, we may need to "never upgrade" existing users (since we'd just detect if /Users/crmarsh/Library/Application Support/uv exists and use that). Or we could support both (read-only from /Users/crmarsh/Library/Application Support/uv, read/write to XDG), but it's more work of course.

charliermarsh avatar Aug 05 '24 03:08 charliermarsh

You could just move it if we find it in the old location? That's what I did when I renamed the Python directory. We could make a link?

zanieb avatar Aug 05 '24 13:08 zanieb

Hmm, will there be any absolute references to things in the existing folder? Like paths to interpreters? Not sure...

charliermarsh avatar Aug 05 '24 13:08 charliermarsh

Fair, that could be problematic. I guess we "never upgrade" and provide instructions for manual migration?

zanieb avatar Aug 05 '24 13:08 zanieb

Tragic!

charliermarsh avatar Aug 05 '24 13:08 charliermarsh

Continuing on in https://github.com/astral-sh/uv/pull/5806.

charliermarsh avatar Aug 06 '24 01:08 charliermarsh