[Distutils] package_data issue (chopping off characters)

Jeremy Sanders jeremy at jeremysanders.net
Thu Apr 14 16:08:48 CEST 2005

Sorry for not replying properly in the thread, but I think I've found the 
bug. I downloaded python from cvs and took the latest distutils from 

In command/build_py.py there is a function:

     def get_data_files (self):
         """Generate list of '(package,src_dir,build_dir,filenames)' tuples"""
         data = []
         if not self.packages:
             return data
         for package in self.packages:
             # Locate package source directory
             src_dir = self.get_package_dir(package)

             # Compute package build directory
             build_dir = os.path.join(*([self.build_lib] + package.split('.')))

             # Length of path to strip from found files
             plen = len(src_dir)+1

             # Strip directory from globbed filenames
             filenames = [
                 file[plen:] for file in self.find_data_files(package, src_dir)
             data.append((package, src_dir, build_dir, filenames))
         return data

Note that the filename is chopped using file[plen:] above. If src_dir=="",
as I have in my setup.py file (which is a perfectly acceptable package 
directory), then plen == 1, and so the first character gets chopped from 
each of the file names.

self.find_data_files returns the correct files, but the first character 
gets chopped from them.


Jeremy Sanders <jeremy at jeremysanders.net>
http://www.jeremysanders.net/                Cambridge, UK
Public Key Server PGP Key ID: E1AAE053

More information about the Distutils-SIG mailing list