py2exe/distutils: how to include a tree of files?
pavlovevidence at gmail.com
Sat Aug 25 02:04:12 CEST 2007
On Aug 24, 5:46 pm, Grant Edwards <gra... at visi.com> wrote:
> On 2007-08-24, Grant Edwards <gra... at visi.com> wrote:
> > I'm packaging up a python program and need to include an entire
> > directory tree in the distribution.
> I've cobbled together something using package_dir/package_data
> and os.path.walk(), but it seems like a bit of a kludge...
"data_files" is documented in the official distutils documentation.
(Yes, in regular distutils you do have to pretty much walk the data
directories to get your data.)
I guess the idea was that you would use the same setup.py for
building, installing, and packaging (source and py2exe). But it
doesn't work all that well in practice, because using "data_files" is
rather useless for non-py2exe packaging since you could never be sure
where distutils actually installed the data files. (You could only
guess, based on the location of the script files, and even that was
shaky because of a bug if the user installed it with --prefix.)
The packages I use all seem to avoid this difficulty by placing data
in the package directories, alongside the py files.
I suppose because "data_files" wasn't too helpful, there was never
much incentive to improve it. Which (getting back to py2exe) is
unfortunate since you CAN rely on the location when using py2exe, but
it is stuck with the unwieldy usage. Oh well.
More information about the Python-list