distutils - how to get more flexible configuration

Jonathan Fine J.Fine at open.ac.uk
Wed Mar 7 14:52:08 CET 2007


Hello

I'm writing a package that has cgi-bin scripts, html
files and data files (templates used by cgi scripts).
I find that using distutils in the standard way
does not give me enough flexibilty, even if I use
a setup.cfg.

For example, I want certain data files to go to
markedly different locations.

However, I have come up with a solution, that looks
like it will work for me, and I'd welcome comments.

Here's the MANIFEST file
===
setup.py
myproj_cfg.py
data/wibble.txt
data/wobble.txt
===

And here's the setup.py file I've written
===
from distutils.core import setup
import myproj_cfg

data_files = [
    (myproj_cfg.wibble, ['data/wibble.txt']),
    (myproj_cfg.wobble, ['data/wobble.txt']),
    ]

setup(data_files=data_files)
===

The user is asked to create a myproj_cfg.py file,
which might look like
===
wibble = '/wibble'
wobble = '/wobble'
===

And when a distribution is created and installed
we get
===
$ python setup.py install
running install
running build
running install_data
creating /wibble
copying data/wibble.txt -> /wibble
creating /wobble
copying data/wobble.txt -> /wobble
===

This is an example of what I want.  I'd welcome
your comments.

-- 
Jonathan Fine
The Open University, Milton Keynes, England





More information about the Python-list mailing list