1. Tarek Ziadé
  2. distribute
  3. Issues
Issue #282 new

Distribute ignores setuptools_subversion for bdist_*

Anonymous created an issue

I've been trying to create eggs with setuptools (then switched to distribute), with include_package_data=True with no success. I realized my subversion version was too recent for setuptools so I installed "setuptools_subversion". This guy somehow successfully included the svn-managed files for sdist but not for bdist_*.

Started digging and found that in the setuptools.command.build_py:build_py.analyze_manifest method there appears to be something strange. By defaut it reads: {{{

!python

def analyze_manifest(self):
    self.manifest_files = mf = {}
    if not self.distribution.include_package_data:
        return
    src_dirs = {}
    for package in self.packages or ():
        # Locate package source directory
        src_dirs[assert_relative(self.get_package_dir(package))] = package

    self.run_command('egg_info')
    ei_cmd = self.get_finalized_command('egg_info')
    for path in ei_cmd.filelist.files:  
        d,f = os.path.split(assert_relative(path))
        prev = None
        oldf = f
        while d and d!=prev and d not in src_dirs:
            prev = d
            d, df = os.path.split(d)
            f = os.path.join(df, f)
        if d in src_dirs:
            if path.endswith('.py') and f==oldf:
                continue    # it's a module, not data
            mf.setdefault(src_dirs[d],[]).append(path)

}}}

After the while loop, the d variable will be "" and the f variable will be path. The "if d in src_dirs" will most probably fail and "f==oldf" too. I changed it to the following:

{{{

! python

def analyze_manifest(self):
    self.manifest_files = mf = {}
    if not self.distribution.include_package_data:
        return
    src_dirs = {}
    for package in self.packages or ():
        # Locate package source directory
        src_dirs[assert_relative(self.get_package_dir(package))] = package

    self.run_command('egg_info')
    ei_cmd = self.get_finalized_command('egg_info')
    for path in ei_cmd.filelist.files:  
        d,f = os.path.split(assert_relative(path))
        prev = None
        oldf = f
        while d and d!=prev and d not in src_dirs:
            prev = d
            d, df = os.path.split(d)
            f = os.path.join(df, f)
        d, f = os.path.split(f)                                             # this is the fix
        if d in src_dirs and not os.path.isdir(path):    # this is the fix
            if path.endswith('.py') and f==oldf:
                continue    # it's a module, not data
            mf.setdefault(src_dirs[d],[]).append(path)

}}}

This lets setuptools_subversion be used for bdist_egg commands. However I have doubts concerning this fix as I find it strange that such a bug has gone unnoticed. It might be that what is fed to that method isn't right. Still investigating...