Making code run in both source tree and installation path
ldo at geek-central.gen.new_zealand
Mon Jun 29 23:55:01 EDT 2009
In message <mailman.2310.1246292443.8015.python-list at python.org>, Javier
> - distutils trick in setup.py to modify the installed script (i.e.
> changing a global variable value) so that it has a reference to the
> data files location.
This seems to me to be the cleanest solution, at least as a default.
> - Heuristic in the package code to detect when it's being executed
> from the source tree and when it has been the installed
By definition, a "heuristic" can never be fully reliable.
> - Just using an environment variable that the user must set according
> to his needs
This can be useful as a way to override default settings. But requiring it
means extra trouble for the user.
For configurable settings, best to observe a hierarchy like the following
(from highest to lowest priority):
* command-line options
* environment-variable settings
* user prefs in ~/.whatever
* system configs in /etc
* common data in /usr/share
More information about the Python-list