fix: consolidate data file locations to follow XDG Base Directory Specification#77
Conversation
…ecification - Add paths.py module with XDG-compliant path resolution - Migrate legacy paths (~/.pyvm_history.json, ~/.pyvm_metadata.sqlite, ~/.pyvm/) to XDG locations - On Linux/macOS: config in ~/.config/pyvm, data in ~/.local/share/pyvm, cache in ~/.cache/pyvm - On Windows: all paths use %LOCALAPPDATA%/pyvm - Update constants.py, config.py, venv.py to use new path helpers - Wire migration into CLI entry point for automatic one-time migration - Add comprehensive tests for path resolution and migration
shreyasmene06
left a comment
There was a problem hiding this comment.
@swarnimbandekar please make sure the checks are passed
shreyasmene06
left a comment
There was a problem hiding this comment.
The XDG migration logic can lose user data in conflict cases:
- _move_file: if destination already exists, it deletes the legacy source (src.unlink()), which can discard data.
- _move_directory: when destination exists, conflicting items are skipped, then source dir is removed (rmtree), so
skipped/conflicting files can be lost.
Please make migration conflict-safe (no destructive delete of source on conflict), and add tests for “destination already
exists / partial overlap” cases before merge.
|
fix: |
shreyasmene06
left a comment
There was a problem hiding this comment.
Thanks for the fixes. The previous conflict/data-loss issue looks addressed and CI is green, but I still see one blocker
before merge.
When migrating ~/.pyvm/venvs and ~/.pyvm/venvs.json, the registry file is moved as-is. Existing registry entries can
still contain absolute paths under the legacy root, e.g. ~/.pyvm/venvs/myenv, while the actual venv directory has been
moved to the new XDG location, e.g. ~/.local/share/pyvm/venvs/myenv.
That would make migrated venvs appear missing or fail activation/removal because venv.py trusts the stored registry path.
Please update the migration to rewrite registry entry paths from the old venv root to the new venv root, and add a test
covering an existing venvs.json entry with an absolute legacy path.
Also minor: README.md line 251 has trailing whitespace (git diff --check catches it).
Moves data files from
$HOMEto proper XDG directories:fixes #76
~/.pyvm_history.json~/.local/share/pyvm/history.json~/.pyvm_metadata.sqlite~/.cache/pyvm/metadata.sqlite~/.pyvm/venvs/~/.local/share/pyvm/venvs/~/.pyvm/venvs.json~/.local/share/pyvm/venvs.jsonOn Windows everything goes to
%LOCALAPPDATA%/pyvm/.Existing files are automatically migrated on first run. Migration only runs once and logs what it moved.
Also respects
XDG_*_HOMEenv vars if set.Testing: All 64 tests pass, including 15 new ones for path resolution and migration.
GSSoC26