shiv
shiv copied to clipboard
Move default cache root from ~/.shiv to ~/.cache/shiv
More precisely:
- if $SHIV_ROOT is set, use it
- if --root is set, use it
- if ~/.shiv already exists, use it
- on Windows: %LOCALAPPDATA%\shiv\cache
- on macOS: ~/Library/Caches/shiv
- on other: $XDG_CACHE_HOME/shiv or ~/.cache/shiv
Motivation:
- Purely aesthetic reasons :) Less junk in $HOME.
- The location makes it more obvious that it's just a cache. --> Users should feel free to delete it.
- Some backup software will ignore caches by default.
Implementation:
This is an ad hoc, informally-specified, bug-ridden, slow implementation of 1% of platformdirs. platformdirs is the most common library for this, for example it is used by pip to locate its own cache (~/.cache/pip). I didn't want to use platformdirs directly because this code is embedded into .pyz files and shouldn't have any dependencies. The main differences from the original platformdirs algorithm are that Windows only checks getenv (not ctypes/windll or registry) (see also), Windows falls back to Unix if getenv fails, and Android is not special cased (see also).
Please test!!:
I don't have a Windows or macOS development setup. I'd be grateful if someone could check that it works, and that the directory is created nearby to pip's cache (probably %LOCALAPPDATA%\pip\cache, ~/Library/Caches/pip).