Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include standard on recommending XDG Base Directory Specification for storing data #28

Open
namurphy opened this issue May 21, 2024 · 3 comments

Comments

@namurphy
Copy link
Contributor

namurphy commented May 21, 2024

After exceeding the quota for my network home directory several times 🎉💾🥦, I learned about the XDG Base Directory Specification. This specification defines locations where programs should store and look for user-specific data and configuration files.

Probably the two most relevant environment variables would be:

  • $XDG_DATA_HOME defines the base directory relative to which user-specific data files should be stored. If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.
  • $XDG_CONFIG_HOME defines the base directory relative to which user-specific configuration files should be stored. If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.

My inclination would be for data files for a package to be located in $XDG_DATA_HOME/<package>, where <package> is replaced with the package name as it would be imported. For example, data for PlasmaPy would be in $XDG_DATA_HOME/plasmapy.

Some packages already have environment variables that define where to place stored data (like $SPEDAS_DATA_DIR). For backward compatibility, the existing variables should be given priority.

The benefits would be that users would only need to define this location once for all packages, and that it would be more convenient to find where the stored data files from all packages are.

This could be a standalone PHEP, or perhaps included in a standards doc.

See also: PlasmaPy/PlasmaPy#2600

@jibarnum
Copy link

@namurphy do you plan to be at the next PyHC telecon (9/23)? Bringing up current in-progress PHEPs and seeing what questions/thoughts the community has, while also bringing up the issues shown here in the standard GitHub. It would be great to see about pitching this to the community then. Could use hackathon time during the PyHC meeting to make it come to fruition?

@jtniehof
Copy link
Contributor

Is there an established / graceful fallback on Windows? Use the environment variable if set and, if not, fall back to %USERPROFILE% (from memory)?

@namurphy
Copy link
Contributor Author

namurphy commented Oct 2, 2024

I'd say that this issue is fairly low priority, so my inclination is to wait and come back to this next year.

Is there an established / graceful fallback on Windows? Use the environment variable if set and, if not, fall back to %USERPROFILE% (from memory)?

I'm not fully certain, but I believe that the common practice is for packages to use the XDG_* variables if set, and then fall back to a different location as chosen by the package.

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

No branches or pull requests

3 participants