Commit f5166857 authored by PJ Eby's avatar PJ Eby

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
parent 760c89ad
...@@ -2498,6 +2498,9 @@ XXX ...@@ -2498,6 +2498,9 @@ XXX
Release Notes/Change History Release Notes/Change History
---------------------------- ----------------------------
0.6b3
* Fix bdist_egg not including files in .egg-info subdirectories.
0.6b1 0.6b1
* Strip ``module`` from the end of compiled extension modules when computing * Strip ``module`` from the end of compiled extension modules when computing
the name of a ``.py`` loader/wrapper. (Python's import machinery ignores the name of a ``.py`` loader/wrapper. (Python's import machinery ignores
......
...@@ -8,7 +8,7 @@ from setuptools import Command ...@@ -8,7 +8,7 @@ from setuptools import Command
from distutils.dir_util import remove_tree, mkpath from distutils.dir_util import remove_tree, mkpath
from distutils.sysconfig import get_python_version, get_python_lib from distutils.sysconfig import get_python_version, get_python_lib
from distutils import log 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 types import CodeType
from setuptools.extension import Library from setuptools.extension import Library
...@@ -91,7 +91,7 @@ class bdist_egg(Command): ...@@ -91,7 +91,7 @@ class bdist_egg(Command):
def finalize_options(self): 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 self.egg_info = ei_cmd.egg_info
if self.bdist_dir is None: if self.bdist_dir is None:
...@@ -216,10 +216,7 @@ class bdist_egg(Command): ...@@ -216,10 +216,7 @@ class bdist_egg(Command):
if not self.dry_run: if not self.dry_run:
os.unlink(native_libs) os.unlink(native_libs)
for filename in os.listdir(self.egg_info): self.copy_metadata_to(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))
write_safety_flag( write_safety_flag(
os.path.join(archive_root,'EGG-INFO'), self.zip_safe() os.path.join(archive_root,'EGG-INFO'), self.zip_safe()
...@@ -233,7 +230,7 @@ class bdist_egg(Command): ...@@ -233,7 +230,7 @@ class bdist_egg(Command):
if self.exclude_source_files: if self.exclude_source_files:
self.zap_pyfiles() self.zap_pyfiles()
# Make the archive # Make the archive
make_zipfile(self.egg_output, archive_root, verbose=self.verbose, make_zipfile(self.egg_output, archive_root, verbose=self.verbose,
dry_run=self.dry_run) dry_run=self.dry_run)
...@@ -244,6 +241,9 @@ class bdist_egg(Command): ...@@ -244,6 +241,9 @@ class bdist_egg(Command):
getattr(self.distribution,'dist_files',[]).append( getattr(self.distribution,'dist_files',[]).append(
('bdist_egg',get_python_version(),self.egg_output)) ('bdist_egg',get_python_version(),self.egg_output))
def zap_pyfiles(self): def zap_pyfiles(self):
log.info("Removing .py files from temporary directory") log.info("Removing .py files from temporary directory")
for base,dirs,files in walk_egg(self.bdist_dir): for base,dirs,files in walk_egg(self.bdist_dir):
...@@ -262,7 +262,7 @@ class bdist_egg(Command): ...@@ -262,7 +262,7 @@ class bdist_egg(Command):
def make_init_files(self): def make_init_files(self):
"""Create missing package __init__ files""" """Create missing package __init__ files"""
init_files = [] init_files = []
for base,dirs,files in walk_egg(self.bdist_dir): for base,dirs,files in walk_egg(self.bdist_dir):
if base==self.bdist_dir: if base==self.bdist_dir:
# don't put an __init__ in the root # don't put an __init__ in the root
...@@ -276,7 +276,7 @@ class bdist_egg(Command): ...@@ -276,7 +276,7 @@ class bdist_egg(Command):
filename = os.path.join(base,'__init__.py') filename = os.path.join(base,'__init__.py')
if not self.dry_run: if not self.dry_run:
f = open(filename,'w'); f.write(NS_PKG_STUB) f = open(filename,'w'); f.write(NS_PKG_STUB)
f.close() f.close()
init_files.append(filename) init_files.append(filename)
break break
else: else:
...@@ -285,6 +285,14 @@ class bdist_egg(Command): ...@@ -285,6 +285,14 @@ class bdist_egg(Command):
return init_files 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): def get_ext_outputs(self):
"""Get a list of relative paths to C extensions in the output distro""" """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()) ...@@ -318,18 +326,10 @@ NATIVE_EXTENSIONS = dict.fromkeys('.dll .so .dylib .pyd'.split())
def walk_egg(egg_dir): def walk_egg(egg_dir):
"""Walk an unpacked egg's contents, skipping the metadata directory""" """Walk an unpacked egg's contents, skipping the metadata directory"""
walker = os.walk(egg_dir) walker = os.walk(egg_dir)
base,dirs,files = walker.next() base,dirs,files = walker.next()
if 'EGG-INFO' in dirs: if 'EGG-INFO' in dirs:
dirs.remove('EGG-INFO') dirs.remove('EGG-INFO')
yield base,dirs,files yield base,dirs,files
...@@ -448,4 +448,4 @@ def make_zipfile (zip_filename, base_dir, verbose=0, dry_run=0, compress=None): ...@@ -448,4 +448,4 @@ def make_zipfile (zip_filename, base_dir, verbose=0, dry_run=0, compress=None):
return zip_filename return zip_filename
#
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment