[Distutils] Crying over "data_files".

Mac Ryan quasipedia at gmail.com
Mon Aug 22 03:30:33 CEST 2011


	thanks also to the feedback of this ML members, I manage to get
going with debian packages using distutils + setuptools + stdeb.
There are a few things that still puzzle me though on the data_files
parameter of the setup script.

The need for a MANIFEST.in file
Apparently including the list of files in `data_files` is not
sufficient for them to be included in the distribution. I found this
question on StackOverflow: http://stackoverflow.com/q/2994396/146792
and the accepted answer states that it was a bug fixed in python 2.7.
(most probably this one: http://bugs.python.org/issue2279). Although I
am running ubuntu 11.04 (shipping python 2.7.1+) the behaviour for me is
still the old, possibly buggy one. What am I doing wrong?

Data files for modules (instead than for packages)
The small application I am testing my packaging skills with, has a file
structure like this:

├── distribute_setup.py
├── setup.py
└── src
    ├── prog.py
    ├── scrapedata.py
    └── data.yml

In my distribution I only want to ship `prog.py` and `data.yml`,
ignoring `scrapedata.py`. Initially I managed to build the .deb package
by creating an `__init__.py`  file in the `src` directory and then
putting in my setup.py something like:

    packages = find_packages(),
    package_data = {'src': ['data.yml'],

but then I realised that doing so I was creating a `src` directory
under `/usr/lib/python2.7/dist-packages`, which seems very wrong (src
is just a directory for me to keep my files organised, it is not a
package). So I tried to do something like:

    py_modules = ['src/prog'],
    data_files=['', ['src/data.yml']],

but - beside not working (see following question) - I wonder if there
is a standard and better way to link data files to specific modules
rather than packages.

The dreadful "error: can't copy '': doesn't exist or not a regular file"
This actually happens when I try to assemble the built distribution for
debian (so it the problem might be with stdeb rather than with
distutils, but I'm unsure). In my setup script I have:

    data_files=['', ['src/data.yml']],

If I alter the destination directory with for example '.', the error
message will be the same, just reporting the '.' instead of the
'' (this is why I am sure it is related to this line)... Again, I am a
bit confused... am I doing something wrong here?

Thank you in advance for your help (and sorry if I am asking something
silly. This is my very first experience with distutils and packaging! :)


More information about the Distutils-SIG mailing list