Installing config files into specific directories, even with setuptools?
Basically, I can install files into: $HOME/.local/share/dbus-1/services or /usr/local/share/dbus-1/services or /usr/share/dbus-1/services (or anywhere in xdg.BaseDirectory.xdg_data_dirs really) but I want to pick the most appropriate place, taking into account the --prefix option to setup.py, or the root of the virtualenv/whatever. What is the most portable way to to this? David.
For applications needing user config files at a new location (not sure
about /dbus-1/services), what I currently find suitable is this:
1. Store the default config files at myapp.module.conf namespace (==
site-packages/myapp/module/conf/foo.conf,bar/baz.conf,etc..)
2. When the application is first run, check for ~/.local (or APPDATA on
Windows) - and if user config directory-or-files is not present, copy them
from the namespace location to ~/.local.
3. Next time the app is run, the copied config files can be used; the user
can also edit them.
-srid
On Mon, 10 Aug 2009 13:49:49 -0700, David Laban
Basically, I can install files into:
$HOME/.local/share/dbus-1/services or /usr/local/share/dbus-1/services or /usr/share/dbus-1/services (or anywhere in xdg.BaseDirectory.xdg_data_dirs really)
but I want to pick the most appropriate place, taking into account the --prefix option to setup.py, or the root of the virtualenv/whatever.
What is the most portable way to to this?
David. _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
-- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
2. When the application is first run, check for ~/.local (or APPDATA on Windows) - and if user config directory-or-files is not present, copy them from the namespace location to ~/.local.
The app is only ever run by dbus finding the service file, so this won't work. The file does not need to be editable once it's installed, but if the user does not have root access, it needs to be installed in ~.local/share rather than /usr/share or wherever. If I created an "install_xdg" function, would I be able to contribute it to distutils/setuptools/distribute? David
On Fri, 21 Aug 2009 08:15:47 -0700, David Laban
2. When the application is first run, check for ~/.local (or APPDATA on Windows) - and if user config directory-or-files is not present, copy them from the namespace location to ~/.local. The app is only ever run by dbus finding the service file, so this won't work. The file does not need to be editable once it's installed, but if the user does not have root access, it needs to be installed in ~.local/share rather than /usr/share or wherever. If I created an "install_xdg" function, would I be able to contribute it to distutils/setuptools/distribute?
Aside: It looks like providing support for "post install" scripts in distutils/Distribute would satisfy the user cases like above. apt/yast/etc.. already do this. seutp.py:postinstall() method perhaps? Note that if we are doing this - package managers must also be taken into account .. for post install should not be *run* during "setup.py install --root=.." but only when the package is actually installed (which is installer-specific) on the target system. -srid
participants (2)
-
David Laban
-
Sridhar Ratnakumar