Error if package_dir has empty string as value

Issue #180 open
Anonymous created an issue

Hello everybody,

I have tons of old code which have the following (example) structure
{{{
joki@chimera /tmp/bug $ tree bug_package
bug_package
|-- data
| |-- data1
| -- data2 |-- __init__.py |-- library.py-- setup.py

1 directory, 5 files
}}}

My setup.py looks like this
{{{

!python

from setuptools import setup
setup(
name="library",
packages=['library'],
package_dir={'library' : ''},
include_package_data=True,
)
}}}

If I execute this setup.py for example "python setup.py bdist_egg" the following error occurs.

{{{
python setup.py bdist_egg
running bdist_egg
running egg_info
creating library.egg-info
writing library.egg-info/PKG-INFO
writing top-level names to library.egg-info/top_level.txt
writing dependency_links to library.egg-info/dependency_links.txt
writing manifest file 'library.egg-info/SOURCES.txt'
writing manifest file 'library.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-i686/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/library
copying library.py -> build/lib/library
copying init.py -> build/lib/library
creating build/lib/library/ata
error: can't copy 'ata/data1': doesn't exist or not a regular file
}}}

I hunt the failure down to '_get_data_files' in commands/build_py.py. After getting all files it cuts of the appropriate src_dir, because the src_dir is used separately

For my particular case where src_dir is empty the 'plen' is 1, BUT the files returned from find_data_files look like this
{{{

!python

[
'data/data1',
'data/data2',
'library.egg-info/PKG-INFO',
'library.egg-info/SOURCES.txt',
'library.egg-info/dependency_links.txt',
'library.egg-info/top_level.txt'
]
}}}

=> After stripping this list is 'broken'
{{{

!python

[
'ata/data1',
'ata/data2',
'ibrary.egg-info/PKG-INFO',
'ibrary.egg-info/SOURCES.txt',
'ibrary.egg-info/dependency_links.txt',
'ibrary.egg-info/top_level.txt'
]
}}}

Currently I have locally patched distribute which solves the issue.

{{{

!udiff

diff -ur distribute_orginal/setuptools/command/build_py.py distribute/setuptools/command/build_py.py
--- distribute_orginal/setuptools/command/build_py.py 2010-07-15 02:01:09.000000000 +0200
+++ distribute/setuptools/command/build_py.py 2010-09-17 12:19:29.000000000 +0200
@@ -108,7 +108,10 @@
build_dir = os.path.join(*([self.build_lib] + package.split('.')))

         # Length of path to strip from found files
  • plen = len(src_dir)+1
  • if src_dir == '':
  • plen = 0
  • else:
  • plen = len(src_dir)+1

         # Strip directory from globbed filenames
         filenames = [
    

    }}}

I'm not sure if this is the best solution. Unfortunately I cannot change the layout of the packages :(

Comments (4)

  1. Leila Pearson

    Just a note to mention that I ran into this today too with distribute 0.6.14 (testing in a virtualenv). It looks like it was a but in distutils too a while back, but fixed there.

    When you only have a single package to install, it's nice to use this kind of package structure - with setup.py right in your package directory instead of one directory above - but that means you need to specify

    package_dir = {'mypackage' : ''}
    

    and this doesn't work currently

    - Leila

  2. Anonymous
  3. Log in to comment