1

I've got a Python (2.x) project which contains 2 Python fragment configuration files (import config; config.FOO and so on). Everything is installed using setuptools causing these files to end up in the site-packages directory. From a UNIX perspective it would be nice to have the configuration for a software suite situated in /etc so people could just edit it without resorting to crawl into /usr/lib/python*/site-packages. On the other hand it would be nice to retain the hassle-free importing.

I've got 2 "fixes" in mind that would resolve this issue:

  • Create a softlink from /etc/stuff.cfg to the file in site-packages (non-portable and ugly)
  • Write a configuration management tool (somewhat like a registry) that edit site-packages directly (waay more work that I am willing to do).

I am probably just incapable of finding the appropriate documentation as I can't imagine that there is no mechanism to do this.

user2952698
  • 159
  • 1
  • 1
  • 7
  • 1
    if you know the path; you can import the module hassle free: [`imp.load_source('module.name', '/path/to/file.py')`](http://stackoverflow.com/q/67631/4279) – jfs Sep 18 '14 at 13:34
  • But then I'd have to either just copy the files into a static directory (/etc/foo/) and break everything for users that install the software differently (Windows, virtualenv, ...) or write an elaborate wrapper thingy that's able to install configuration files into a user supplied directory with sane defaults for most systems. – user2952698 Sep 19 '14 at 10:46
  • there are two issues: 1. find the config 2. consume it. I've provided the solution for the 2nd issue. The 1st issue is resolved the same way whether you use ini, yaml, sqlite3, or python format i.e., it is application-specific: what is appropriate for a daemon on POSIX system might not be appropriate for a GUI app on Windows and in reverse. – jfs Sep 19 '14 at 12:31

0 Answers0