|
From: Ramon F. <fel...@ya...> - 2010-01-28 19:15:30
|
Hello all, I have migrated my ad hoc configuration settings to ConfigObj and am quite happy with how it is working out. My project includes a number of commandline programs that all need to re-use the same configuration settings, so I've abstracted access to the configuration data through a config.py file that finds the INI file, loads it into a module-level variable, and provides some utility functions to access the config data. So far so good. However, I am struggling to define a cross-platform deployment set up for configuration files that isn't brittle bootstrapping during code startup, and was wondering how others have solved this issue. The two issues I have are placement of the INI file itself, and the most pythonic method for subsequently locating and loading that file. 1. Location of the INI files go when you deploy your project. I imagine you want them separate from the code so you easily deploy code updates while maintaining settings files intact. Are there guidelines for storing this in a standardized location? E.g. next to your code? in a project-dependent data directory? in a user-specific data directory? 2. Finding the INI file from within the installed, running code. I would like to avoid forcing users to have pass the INI file location on the commandline. My config.py file currently searches for it in the sys.path list, but most of these are geared toward finding code, not settings files. For that same reason, I'm hesitant to hack sys.path to add in data directories as well. Is there a standard location (platform-independent or abstracted via a python lib) to find these, similar to how the tempfile module works? Thanks in advance for any pointers or suggestions, Ramon |