[Distutils] installing data files and headers

Jeremy Hylton jeremy@alum.mit.edu
Fri Feb 28 10:26:01 2003


Another problem we've been struggling with for Zope projects is that
distutils really only installs Python modules and extensions.  It's
support for data files and C header files is pretty limited.  We've got
problems with each that could probably be solved in distutils.

We often store data files in a package directory.  Zope components
sometimes have configuration files, presentation files like html and
images, and other data.  One common case is unit test packages, which
often have test data in them.  In all these cases, we find it useful to
access the data files by loading them from the package directory.  You
get the package's __path__ attribute and look for data files in that
directory.

The problem is that distutils won't install these files for us.  It ends
up being a lot of work to get the files installed.  You need to provide
a custom distclass to copy the files at build and install time.  It
would be a lot more convenient if distutils would just install the files
by default.

I think there are some potential problems with installing non .py
files.  You need to have some control over what exactly gets built and
installed, so that you don't install .py~ files.  One possibility is to
explicitly list the file extensions that constitute installable data. 
We did that for Zope3, but the list of extensions ended up being fairly
long.

The other problem we have is with header files.  We'd like to have .h
files that are installed inside a directory in /usr/local/include.  For
example, we'd like source code that uses the persistence API to read
like this:

#include "persistence/persistence.h"
#include "persistence/persistenceAPI.h"

I can't figure out any way to instruct distutils to create a persistence
directory and put the headers in it.  I think we'd need to extend the
specification for header files to make this possible.

Jeremy