I know package_data. But it is for readonly data inside the package. Or is this assumption wrong? How to install shared or user specific writeable data? For example to ProgramData or AppData on Windows. I'm interested in a solution for linux, too.
Asked
Active
Viewed 115 times
1 Answers
1
Your assumption seems right to me (package data should be read-only). For writable data: either let the user choose a target directory, or pick one directory according to a common convention. But this can not happen at install time. It's probably better to have your library or application check if these shared directories and files exist when they are needed, and if they don't then create them on the fly.
For example a pretty common convention is the XDG Base Directory Specification. These libraries can help write code according to this specification:
platformdirs
(preferred, up-to-date and well maintained)appdirs
(outdated)xdgappdirs
(outdated)

sinoroc
- 18,409
- 2
- 39
- 70
-
A call to site_data_dir("app", "company") returns '/usr/share/gnome-xorg/app'. Not what I expected. I'm on ubuntu. – Martin Fehrs Feb 10 '20 at 22:05
-
Even if this would return sensible paths, I still don't know how to integrate this in my setup.py file. – Martin Fehrs Feb 10 '20 at 22:07
-
Then use another of the many available functions. What is it that you are expecting as a result? – sinoroc Feb 10 '20 at 22:08
-
1@MartinFehrs This definitely shouldn't be part of your setup script. In the code of your library or application, check if these _shared_ directories and/or files exist, if they don't then create them. – sinoroc Feb 10 '20 at 22:10
-
I expected /usr/share/app or /usr/local/share/app. When I call site_data_dir(appname, appauthor, multipath=True) I get a list of paths including both. But even those two paths aren't what i want. I think /var/lib/app would be right directory, because it is writable. – Martin Fehrs Feb 10 '20 at 22:17
-
These projects follow the [_XDG Base Directory Specification_](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html), it's a pretty common one. Pick another convention if it feels like it would be a better choice for your users. I was just giving you an example, but seems like you got the point of my answer. – sinoroc Feb 10 '20 at 22:24