diff --git a/pip/req.py b/pip/req.py index e487edbd902..7cb5a6b8b9b 100644 --- a/pip/req.py +++ b/pip/req.py @@ -245,14 +245,16 @@ def run_egg_info(self, force_root_egg_info=False): _run_setup_py = """ __file__ = __SETUP_PY__ from setuptools.command import egg_info +import pkg_resources +import os def replacement_run(self): self.mkpath(self.egg_info) installer = self.distribution.fetch_build_egg - for ep in egg_info.iter_entry_points('egg_info.writers'): + for ep in pkg_resources.iter_entry_points('egg_info.writers'): # require=False is the change we're making: writer = ep.load(require=False) if writer: - writer(self, ep.name, egg_info.os.path.join(self.egg_info,ep.name)) + writer(self, ep.name, os.path.join(self.egg_info,ep.name)) self.find_sources() egg_info.egg_info.run = replacement_run exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec')) diff --git a/tests/packages/HackedEggInfo/setup.py b/tests/packages/HackedEggInfo/setup.py new file mode 100755 index 00000000000..c34b57c4bc5 --- /dev/null +++ b/tests/packages/HackedEggInfo/setup.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +from setuptools import setup +from setuptools.command import egg_info as orig_egg_info + +class egg_info (orig_egg_info.egg_info): + def run(self): + orig_egg_info.egg_info.run(self) + + +setup( + name = "hackedegginfo", + version = '0.0.0', + cmdclass = {'egg_info':egg_info }, + zip_safe = False, +) + diff --git a/tests/test_basic.py b/tests/test_basic.py index c27e28fd13b..a49824abfb4 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -376,6 +376,16 @@ def test_install_with_pax_header(): run_pip('install', 'paxpkg.tar.bz2', cwd=run_from) +def test_install_with_hacked_egg_info(): + """ + test installing a package which defines its own egg_info class + """ + reset_env() + run_from = abspath(join(here, 'packages', 'HackedEggInfo')) + result = run_pip('install', '.', cwd=run_from) + assert 'Successfully installed hackedegginfo\n' in result.stdout + + def test_install_using_install_option_and_editable(): """ Test installing a tool using -e and --install-option