[Distutils] types of files...

Éric Araujo merwok at netwok.org
Tue Apr 17 19:17:22 CEST 2012


> With the help of others and myself, we are moving Gramps[1] from an
> autotools system to Distutils packaging...
> I know that Autotools/ makefiles can handle these types of files, but
> I need to know if it is possible to even a way to handle?
> a) *.in
> b) *.keys
> c) *.xml
> d) man files
> with Distutils/ Distutils2?
It depends on what you mean with “handle”.  Out of the box, distutils 
can compile C sources and it can install Python modules, extension 
modules (written in C), scripts, data files that are supposed to go in 
the same directory as a package (called package_data), data files that 
are supposed to go to arbitrary locations in the system (called 
data_files).  So if you declare for example man files as data files, 
distutils will install them for you, but in a fragile, 
platform-dependent way: you will have to hard-code the destinations in 
your setup.py.  Countless posts on this mailing list and stack overflow 
show how this situation is unsatisfactory.

distutils2 is smarter when installing: you associate files with 
categories in your setup.cfg file and d2 will install them to the right 
locations for each system (see 
http://docs.python.org/dev/packaging/setupcfg#resources).  In your 
program code, you can call distutils2.database.get_file_path and 
get_file to access the installed files.

> I need to be able to merge different language translations into these files...
Then you need a custom command for the build step.  There are various 
projects on PyPI which implement this; I don’t have access to my 
bookmarks now, but from the top of my head there are Babel, van.potomo, 
4Suite.  Beware that some of them don’t work with pure distutils but 
require setuptools, which may be a good or a bad thing depending on your 
needs and tastes.  Note that distutils2 is able to use distutils1-based 
commands, or will be when I have fixed a bug that I found last Saturday :)

If you have more questions, please ask them.


More information about the Distutils-SIG mailing list