[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
welcome.
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
sys.path.
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.
http://docs.fedoraproject.org/en-US/Fedora/14/html/Storage_Administration_Guide/s1-filesystem-fhs.html,
http://www.debian.org/releases/etch/amd64/apcs02.html,
http://www.pathname.com/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:
http://alexis.notmyidea.org/distutils2/setupcfg.html#resources
"""
Default categories are:
* config
* appdata
* appdata.arch
* appdata.persistent
* appdata.disposable
* help
* icon
* scripts
* doc
* info
* man
"""
GNU has directory variables:
https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
, 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
installed.
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
directory.
- Daniel Holth
More information about the Distutils-SIG
mailing list