Distutils help
Carl Banks
imbosol at vt.edu
Sat Dec 7 12:46:28 EST 2002
Fabrizio wrote:
> Hi,
>
> I want to use distutils to create a windows installer for a python script.
> The python program uses a large number of .jpg images which are into an
> 'images' directory.
>
> How can I write a distutils setup file to add the 'images' directory with
> all its contents to the distribution ?
>
> I guess I have to use the "data_files" option; but how can I use it so as to
> avoid listing all the files in the directory, one by one ?
>
> e.g.
> data_files=[('images',['images/image1.jpg', 'images/image2.jpg',
> 'images/image3.jpg'])]
>
> is not workable if the image files are a lot !
>
> I use Python 2.1.1 on Windows98.
The setup script is written in Python, so you can use Python to do the
dirty work for you.
I would do something like this:
from glob import glob
data_files=[('images',glob('images/*.jpg'))]
Or maybe this:
import os
data_files=[('images',[ "images/"+x for x in os.listdir('path/to/images') ])]
I'm sure you get the idea. Someone might fill you in on a better way
to do this; last time I used distutils I don't recall there being one.
--
CARL BANKS
More information about the Python-list
mailing list