Search code examples
pythonlinuxdatastoreproject-structure

Where to store data files generated by linux software?


I have a Python script with a make install (by default to /usr/local/lib/python2.7/dist-packages/) option available. But the script also generates files with user-specific mutable data during script's normal usage. It seems to me that I should not keep compiled script files in couple with data. What is conventional default place to store software data in such cases?


Solution

  • Summarizing from the Filesystem Hierarchy Standard:

    Immutable architecture-independent data should go in /usr/share or /usr/local/share. Mutable data should go in the user's home directory if it's user-specific (XDG provides more guidance here), or in /var if it's system-wide (this usually requires a group-owned directory and files, and a setgid application, to allow writing to a shared file).

    /usr/share and /usr/local/share usually have a structure that somewhat mirrors /usr/lib and /usr/local/lib; I don't know about Python, but Perl has a module File::ShareDir that helps a module with installing and accessing data in a share directory corresponding to the directory where the module is installed.

    And don't forget the other option: just ask the user where the data should go.