[Distutils] Add additional file categories for distutils, setuptools, wheel

Daniel Holth dholth at gmail.com
Sat Apr 18 23:24:33 CEST 2015

I am working on a minor update to the wheel format to add more
categories under which files can be installed. Constructive comments

Distutills, setuptools, wheel currently have the best support for
installing files relative to ('purelib', 'platlib', 'headers',
'scripts', 'data') with 'data' usually meaning '/' or the root of the
virtualenv.  In practice only exactly one of the 'purelib' or
'platlib' locations (which are usually mapped to the same directory on
disk), and sometimes 'scripts' is used for any given package, and
Python packages have no good way of loading any of their package files
at run time if they are installed into any location not relative to

This works fairly well for Python libraries, but anyone packaging
applications for a Linux distribution is required to follow the
filesystem hierarchy standard or FHS.


It would help Linux distribution package maintainers and Python
application (not library) developers if wheel had better support for
installing files into the FHS, but it would help everyone else who
wanted to generate cross-platform packages if the FHS was not
hardcoded as paths in the data/ category. To that end we should come
up with some additional categories that map, or do not map, to the FHS
based on the end user's platform.

Distutils2 had the concept of resource categories:

Default categories are:

* config
* appdata
* appdata.arch
* appdata.persistent
* appdata.disposable
* help
* icon
* scripts
* doc
* info
* man

GNU has directory variables:
, for example prefix, exec_prefix, bindir, sbindir.

Bento has a list based on the GNU paths, and allows new paths to be defined:

prefix: install architecture-independent files
eprefix: install architecture-dependent files
bindir: user executables
sbindir: system admin executables
libexecdir: program executables
sysconfdir: read-only single-machine data
sharedstatedir: modifiable architecture-independent data
localstatedir: modifiable single-machine data
libdir: object code libraries
includedir: C header files
oldincludedir: C header files for non-gcc
datarootdir: read-only arch.-independent data root
datadir: read-only architecture-independent data
infodir: info documentation
localedir: locale-dependent data
mandir: man documentation
docdir: documentation root
htmldir: html documentation
dvidir: dvi documentation
pdfdir: pdf documentation
psdir: ps documentation

I would like to add Bento's list to wheel and to setuptools. We would
fix the disused setup.py setup(data_files = ) argument so that it
could be used with $ substitution, or provide a utility function that
would expand them in setup.py itself:

data_files = { '$libdir/mylib' : [ 'some_library_file'],
'$datadir/mydata' : ['some_data_file']}

We would provide a default configuration file that mapped the
categories to their installed locations.

We would store the actual paths used at install time, so a package
could look for files relative to the $datadir used when it was

Then it would be easier to distribute Python programs that need to
install some files to paths that are not relative to the site-packages

- Daniel Holth

More information about the Distutils-SIG mailing list