Location of data files

Matthias-Christian Ott ott at mirix.org
Fri Apr 1 20:37:35 CEST 2011


I want to include data files with a python package. With distutils it
seems common to specifiy these files in the data_files argument with a
non-portable location (e.g. data_files=[('share/example', 'icon.png')]).
Another approach is to include the file in the Python module of the
package (e.g. example/data) and specify the submodule in package_data
argument and load them via pkgutil or pkg_ressources. This method seems
portable, but doesn't allow customisation and doesn't conform to the

What is the recommended way to allow easy platform-specific packaging
(e.g. data files are installed to /usr/share when requested), portability and
customisation (i.e. data files can be replaced by the user or
alternative locations can be specified)?


More information about the Python-list mailing list