distutils and data_files (many files and directories)

Anders J. Munch andersjm at dancontrol.dk
Tue Dec 10 09:42:13 EST 2002


"Lee Harr" <missive at frontiernet.net> wrote:
> 
> I am new to distutils, so maybe I am missing something...
> 
> If I want to distribute a directory full of data with my
> module (images, and directories full of images, mostly)
> do I need to specify each directory and image to distutils
> with the
> 
> setup(...
>          data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
>                        ('config', ['cfg/data.cfg'])]
> )
> 
> format, or is there some shortcut which says: "everything in
> this directory is data, include it all in the distribution"?

setup.py is just plain old Python code, so you can just do whatever
you would normally do to get a list of the files in a directory, like
os.listdir or glob.glob:

import glob
setup(...
         data_files=[('bitmaps', glob.glob('bm/*.gif')),
                       ('config', glob.glob('cfg/*.cfg'))]
)

- Anders






More information about the Python-list mailing list