[Distutils] package_data issue (chopping off characters)

Jens Thomas j.m.h.thomas at dl.ac.uk
Thu Jan 18 18:29:33 CET 2007


I've just hit the problem that was mentioned in the thread with the 
above title (see: 

However, the email trail seemed to have hit a dead end and it wasn't 
clear to me whether this had been flagged as a bug or whether it was a 
problem with the way that setup.py was being used.

I've included a summary of the problem as I've encountered it below, but 
would appreciate any clarification on whether this is a bug and I need 
to wait for patched version, or whether it's a problem with the way I'm 
using setup.py and there is a change/work around I can use.

Many thanks,


(this is being run on Ubuntu Dapper:Python 2.4.3 (#2, Oct  6 2006, 
07:52:30) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 )

I have the following directory tree




And the following setup.py:
#!/usr/bin/env python

from distutils.core import setup

      package_dir = {'dir1': ''},
      package_data={'dir1': ['doc/*.txt']}

I need this done in this way because of the way that my CVS repository 
has been set up, with the root directory of the source (where the 
setup.py script lives) also being the root directory of the package, and 
I thought that the package_dir line above took care of that.

On running the script, however, I get:

jmht at csevig6:~/dir1$ python setup.py install
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/dir1
copying __init__.py -> build/lib/dir1
creating build/lib/dir1/dir2
copying dir2/__init__.py -> build/lib/dir1/dir2
creating build/lib/dir1/oc
error: can't copy 'oc/test.txt': doesn't exist or not a regular file

This appears to be caused by a bit in the function get_data_files in the 


specifically the line:

 plen = len(src_dir)+1

If len(src_dir) is 0, which it is in my case, the first character of the 
directory gets chopped off.

More information about the Distutils-SIG mailing list