diff options
| -rw-r--r-- | .hgtags | 1 | ||||
| -rw-r--r-- | CHANGES.txt | 6 | ||||
| -rwxr-xr-x | setuptools/command/egg_info.py | 26 | ||||
| -rw-r--r-- | setuptools/tests/test_egg_info.py | 58 |
4 files changed, 91 insertions, 0 deletions
@@ -162,6 +162,7 @@ bc6655b4acf205dd9f25c702955645656077398a 6.0.1 df26609c2f614f5fc9110342e4003ee8bd95cf84 7.0 850a5c155c48b6ecfbb83b961586ea359b561522 8.0b1 7ea0e7498e4ddbf63b6929ee83c75a9207996b08 8.0 +1af3a5f24f7dd4e51d117f701918052b7de65c99 8.1b1 d62bf4e407b3b9b5bedcc1396a9ba46f35571902 8.0.1 1c03d512e39d5cfd711ae3ed7e316769f427e43b 8.0.2 6c3467488123ce70b1dd009145a02f51fb78cdcc 8.0.3 diff --git a/CHANGES.txt b/CHANGES.txt index 9b27f3ea..3621ed77 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,6 +3,12 @@ CHANGES ======= --- +8.2 +--- + +* Pull Request #85: Search egg-base when adding egg-info to manifest. + +--- 8.1 --- diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 43df87dc..e1324127 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -6,6 +6,7 @@ from distutils.filelist import FileList as _FileList from distutils.util import convert_path from distutils import log import distutils.errors +import distutils.filelist import os import re import sys @@ -324,8 +325,33 @@ class manifest_maker(sdist): elif os.path.exists(self.manifest): self.read_manifest() ei_cmd = self.get_finalized_command('egg_info') + self._add_egg_info(cmd=ei_cmd) self.filelist.include_pattern("*", prefix=ei_cmd.egg_info) + def _add_egg_info(self, cmd): + """ + Add paths for egg-info files for an external egg-base. + + The egg-info files are written to egg-base. If egg-base is + outside the current working directory, this method + searchs the egg-base directory for files to include + in the manifest. Uses distutils.filelist.findall (which is + really the version monkeypatched in by setuptools/__init__.py) + to perform the search. + + Since findall records relative paths, prefix the returned + paths with cmd.egg_base, so add_default's include_pattern call + (which is looking for the absolute cmd.egg_info) will match + them. + """ + if cmd.egg_base == os.curdir: + # egg-info files were already added by something else + return + + discovered = distutils.filelist.findall(cmd.egg_base) + resolved = (os.path.join(cmd.egg_base, path) for path in discovered) + self.filelist.allfiles.extend(resolved) + def prune_file_list(self): build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname() diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 4c4f9456..e8068420 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -1,8 +1,10 @@ +import distutils.core import os import sys import tempfile import shutil +import stat import unittest import pkg_resources @@ -35,6 +37,20 @@ class TestEggInfo(unittest.TestCase): entries_f.write(entries) entries_f.close() + def _create_project(self): + with open('setup.py', 'w') as f: + f.write('from setuptools import setup\n') + f.write('\n') + f.write('setup(\n') + f.write(" name='foo',\n") + f.write(" py_modules=['hello'],\n") + f.write(" entry_points={'console_scripts': ['hi = hello.run']},\n") + f.write(' zip_safe=False,\n') + f.write(' )\n') + with open('hello.py', 'w') as f: + f.write('def run():\n') + f.write(" print('hello')\n") + @skipIf(not test_svn._svn_check, "No SVN to text, in the first place") def test_version_10_format(self): """ @@ -81,6 +97,48 @@ class TestEggInfo(unittest.TestCase): self.assertEqual(rev, '89000') + def test_egg_base_installed_egg_info(self): + self._create_project() + temp_dir = tempfile.mkdtemp(prefix='setuptools-test.') + os.chmod(temp_dir, stat.S_IRWXU) + try: + paths = {} + for dirname in ['home', 'lib', 'scripts', 'data', 'egg-base']: + paths[dirname] = os.path.join(temp_dir, dirname) + os.mkdir(paths[dirname]) + config = os.path.join(paths['home'], '.pydistutils.cfg') + with open(config, 'w') as f: + f.write('[egg_info]\n') + f.write('egg-base = %s\n' % paths['egg-base']) + environ = os.environ.copy() + environ['HOME'] = paths['home'] + code, data = environment.run_setup_py( + cmd=[ + 'install', '--home', paths['home'], + '--install-lib', paths['lib'], + '--install-scripts', paths['scripts'], + '--install-data', paths['data']], + pypath=os.pathsep.join([paths['lib'], self.old_cwd]), + data_stream=1, + env=environ) + if code: + raise AssertionError(data) + egg_info = None + for dirpath, dirnames, filenames in os.walk(paths['lib']): + if os.path.basename(dirpath) == 'EGG-INFO': + egg_info = sorted(filenames) + self.assertEqual( + egg_info, + ['PKG-INFO', + 'SOURCES.txt', + 'dependency_links.txt', + 'entry_points.txt', + 'not-zip-safe', + 'top_level.txt']) + finally: + shutil.rmtree(temp_dir) + + DUMMY_SOURCE_TXT = """CHANGES.txt CONTRIBUTORS.txt HISTORY.txt |
