Skip to content

✨ feat(windows): add WIN_PD_OVERRIDE_* env var overrides#428

Merged
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:347
Feb 13, 2026
Merged

✨ feat(windows): add WIN_PD_OVERRIDE_* env var overrides#428
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:347

Conversation

@gaborbernat
Copy link
Member

On Windows the Shell Folder APIs (ctypes/registry) provide no mechanism for users to redirect directories at runtime. This matters when large data — ML models, package caches, build artifacts — should live on a different drive without changing the system-wide APPDATA / LOCALAPPDATA variables that every other application relies on. On Linux/macOS XDG_* variables solve this naturally, but Windows has no equivalent convention. Fixes #347.

get_win_folder now checks for a WIN_PD_OVERRIDE_* environment variable (e.g. WIN_PD_OVERRIDE_LOCAL_APPDATA) before falling back to the existing resolution. The WIN_PD_OVERRIDE_ prefix avoids colliding with real Windows variables while making it clear this is a platformdirs-specific override, and the WIN_ prefix signals it only applies on Windows. The previous lru_cache on get_win_folder is removed so overrides are picked up dynamically at each access.

The platforms documentation now includes a full reference table of the nine supported override variables with an example showing how to redirect cache to a separate drive.

On Windows the folder resolution (ctypes/registry) provides no way for
users to redirect directories at runtime. This is needed when large
data (ML models, package caches) should live on a different drive
without changing the system-wide APPDATA/LOCALAPPDATA variables.

Each CSIDL folder can now be overridden via a WIN_PD_OVERRIDE_ prefixed
environment variable (e.g. WIN_PD_OVERRIDE_LOCAL_APPDATA), checked
before falling back to the existing resolution. The lru_cache on
get_win_folder is removed so overrides are picked up dynamically.

Closes tox-dev#347
@gaborbernat gaborbernat requested a review from ofek as a code owner February 13, 2026 23:56
@gaborbernat gaborbernat enabled auto-merge (squash) February 13, 2026 23:57
@gaborbernat gaborbernat merged commit 170391e into tox-dev:main Feb 13, 2026
29 checks passed
@gaborbernat gaborbernat deleted the 347 branch February 14, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No way to override location of the folders on Windows

1 participant