Package data distribution and installation

Alejandro Dubrovsky alito at organicrobot.com
Sun Oct 17 05:56:23 EDT 2010


I've got a script that is an executable and it reads template files that 
should be packaged with the script.  How do I tell the script where to 
find the templates?

In distutils, there's a package_data option, but that installs the 
templates under the /usr/lib/pythonX.XX/...  directory, which seems like 
the wrong directory in the unix hierarchy.  Traditionally, this kind of 
data goes under /usr/share. There's also the data_files option, but that 
can be overridden on the install command line with --install-data 
directory, and the scripts/modules don't get informed (or do they? if so, 
how?)

Googling around, people seem to write big install scripts to get around 
this, subclassing from distutils/setuptools and "manually" replacing 
certain tags in their modules with the final data directory.  Is that the 
only way to do this properly?  Is there a pre-packaged solution not in 
Python's library that takes care of it, maybe similarly to the auto-tools 
config.h.in substitution?  If so, could someone point me to it?

Thanks



More information about the Python-list mailing list