From f51668576f921197b6596d835a810a130e7a77e4 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Wed, 7 Jun 2006 19:36:49 +0000 Subject: Fix bdist_egg not including files in .egg-info subdirectories. (merge from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4046722 --- setuptools/command/bdist_egg.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'setuptools/command/bdist_egg.py') diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 7f32c369..0ae3984e 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -8,7 +8,7 @@ from setuptools import Command from distutils.dir_util import remove_tree, mkpath from distutils.sysconfig import get_python_version, get_python_lib from distutils import log -from pkg_resources import get_build_platform, Distribution +from pkg_resources import get_build_platform, Distribution, ensure_directory from types import CodeType from setuptools.extension import Library @@ -91,7 +91,7 @@ class bdist_egg(Command): def finalize_options(self): - ei_cmd = self.get_finalized_command("egg_info") + ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: @@ -216,10 +216,7 @@ class bdist_egg(Command): if not self.dry_run: os.unlink(native_libs) - for filename in os.listdir(self.egg_info): - path = os.path.join(self.egg_info,filename) - if os.path.isfile(path): - self.copy_file(path,os.path.join(egg_info,filename)) + self.copy_metadata_to(egg_info) write_safety_flag( os.path.join(archive_root,'EGG-INFO'), self.zip_safe() @@ -233,7 +230,7 @@ class bdist_egg(Command): if self.exclude_source_files: self.zap_pyfiles() - + # Make the archive make_zipfile(self.egg_output, archive_root, verbose=self.verbose, dry_run=self.dry_run) @@ -244,6 +241,9 @@ class bdist_egg(Command): getattr(self.distribution,'dist_files',[]).append( ('bdist_egg',get_python_version(),self.egg_output)) + + + def zap_pyfiles(self): log.info("Removing .py files from temporary directory") for base,dirs,files in walk_egg(self.bdist_dir): @@ -262,7 +262,7 @@ class bdist_egg(Command): def make_init_files(self): """Create missing package __init__ files""" - init_files = [] + init_files = [] for base,dirs,files in walk_egg(self.bdist_dir): if base==self.bdist_dir: # don't put an __init__ in the root @@ -276,7 +276,7 @@ class bdist_egg(Command): filename = os.path.join(base,'__init__.py') if not self.dry_run: f = open(filename,'w'); f.write(NS_PKG_STUB) - f.close() + f.close() init_files.append(filename) break else: @@ -285,6 +285,14 @@ class bdist_egg(Command): return init_files + def copy_metadata_to(self, target_dir): + prefix = os.path.join(self.egg_info,'') + for path in self.ei_cmd.filelist.files: + if path.startswith(prefix): + target = os.path.join(target_dir, path[len(prefix):]) + ensure_directory(target) + self.copy_file(path, target) + def get_ext_outputs(self): """Get a list of relative paths to C extensions in the output distro""" @@ -318,18 +326,10 @@ NATIVE_EXTENSIONS = dict.fromkeys('.dll .so .dylib .pyd'.split()) - - - - - - - - def walk_egg(egg_dir): """Walk an unpacked egg's contents, skipping the metadata directory""" walker = os.walk(egg_dir) - base,dirs,files = walker.next() + base,dirs,files = walker.next() if 'EGG-INFO' in dirs: dirs.remove('EGG-INFO') yield base,dirs,files @@ -448,4 +448,4 @@ def make_zipfile (zip_filename, base_dir, verbose=0, dry_run=0, compress=None): return zip_filename - +# -- cgit v1.2.3