diff options
author | Toby Vincent <tobyv@tobyvin.dev> | 2023-11-07 12:25:25 -0600 |
---|---|---|
committer | Toby Vincent <tobyv@tobyvin.dev> | 2023-11-07 12:40:40 -0600 |
commit | 6cd28a807f92a96508df32fcfef2e51ec47b4ce1 (patch) | |
tree | b9a584a222890be9491dc852eb067f7cb001392f /python | |
parent | 08797f4958f5948348068f2c08765e70c6889147 (diff) |
fix(python): fix XDG Base Directory compat for python
Diffstat (limited to 'python')
-rw-r--r-- | python/.config/profile.d/20-python.sh | 2 | ||||
-rw-r--r-- | python/.config/python/startup.py | 8 |
2 files changed, 6 insertions, 4 deletions
diff --git a/python/.config/profile.d/20-python.sh b/python/.config/profile.d/20-python.sh index 65ea113..febd407 100644 --- a/python/.config/profile.d/20-python.sh +++ b/python/.config/profile.d/20-python.sh @@ -1,3 +1,5 @@ #!/bin/sh export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/startup.py" +export PYTHONUSERBASE="$XDG_DATA_HOME/python" +export PYTHONPYCACHEPREFIX="$XDG_CACHE_HOME/python" diff --git a/python/.config/python/startup.py b/python/.config/python/startup.py index 15fe43c..9dc77b9 100644 --- a/python/.config/python/startup.py +++ b/python/.config/python/startup.py @@ -4,16 +4,16 @@ # Create the following .config/python/startup.py file # and export its path using PYTHONSTARTUP environment variable: # -# export PYTHONSTARTUP="${XDG_CONFIG_HOME:-$HOME/.config}/python/startup.py" +# export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/startup.py" import atexit import os import readline -xdg_cache = os.getenv("XDG_CACHE_HOME", os.path.expanduser("~/.cache")) -xdg_python_history = os.path.join(xdg_cache, "python", "history") +xdg_state = os.getenv("XDG_STATE_HOME", os.path.expanduser("~/.local/state")) +histfile = os.getenv("PYTHONHISTFILE", os.path.join( + xdg_state, "python", "history")) -histfile = os.getenv("PYTHONHISTFILE", xdg_python_history) alt_histfile = os.path.expanduser("~/.python_history") if not os.path.exists(histfile) and os.path.exists(alt_histfile): |