[Distutils] distutils: packaging a generated configuration file

Mark Dickinson dickinsm at gmail.com
Mon Oct 5 21:02:36 CEST 2009

I'm trying to use distutils for the first time to package up a
project, and struggling a bit;  I wonder whether some kind soul could
point me in the right direction.

I'm packaging a pure Python project that uses ctypes.  The only
complication is that I'd like the setup script to install a
configuration file alongside the various .py files.  From the
documentation, this sounds like something that would usually be
specified with 'package_data' or 'data_files'.  The catch is that
parts of the configuration file are generated at setup time:  that is,
the setup script gathers various pieces of system information (e.g.,
library locations) and uses those to transform a hard-coded
'config.in' file into the 'config' file that I want to install.

I could just generate the 'config' file in the top-level package
directory, but it seems dangerous to assume that that directory is
writable; it seems better to use one of the build directories that
distutils already knows about.

What's the best way to manage generation and installation of the
config file?  I've got as far as subclassing the build command and
making __run__ create the config file from the config.in file, putting
it into the build_temp directory;  I can't figure out how to tell
distutils to install it in the right place.

It seems like I want a sort of build_data/install_data pair of
commands, that allows creation and installation of *generated* data

Any hints?


More information about the Distutils-SIG mailing list