Skip to content

Commit 5562a6b

Browse files
committed
Merge pull request #584 from msabramo/issue-11
Make _run_setup_py magic use pkg_resources.iter_entry_points
2 parents 8b8dcea + 1f84b65 commit 5562a6b

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

pip/req.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,16 @@ def run_egg_info(self, force_root_egg_info=False):
245245
_run_setup_py = """
246246
__file__ = __SETUP_PY__
247247
from setuptools.command import egg_info
248+
import pkg_resources
249+
import os
248250
def replacement_run(self):
249251
self.mkpath(self.egg_info)
250252
installer = self.distribution.fetch_build_egg
251-
for ep in egg_info.iter_entry_points('egg_info.writers'):
253+
for ep in pkg_resources.iter_entry_points('egg_info.writers'):
252254
# require=False is the change we're making:
253255
writer = ep.load(require=False)
254256
if writer:
255-
writer(self, ep.name, egg_info.os.path.join(self.egg_info,ep.name))
257+
writer(self, ep.name, os.path.join(self.egg_info,ep.name))
256258
self.find_sources()
257259
egg_info.egg_info.run = replacement_run
258260
exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))

tests/packages/HackedEggInfo/setup.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from setuptools import setup
4+
from setuptools.command import egg_info as orig_egg_info
5+
6+
class egg_info (orig_egg_info.egg_info):
7+
def run(self):
8+
orig_egg_info.egg_info.run(self)
9+
10+
11+
setup(
12+
name = "hackedegginfo",
13+
version = '0.0.0',
14+
cmdclass = {'egg_info':egg_info },
15+
zip_safe = False,
16+
)
17+

tests/test_basic.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,16 @@ def test_install_with_pax_header():
376376
run_pip('install', 'paxpkg.tar.bz2', cwd=run_from)
377377

378378

379+
def test_install_with_hacked_egg_info():
380+
"""
381+
test installing a package which defines its own egg_info class
382+
"""
383+
reset_env()
384+
run_from = abspath(join(here, 'packages', 'HackedEggInfo'))
385+
result = run_pip('install', '.', cwd=run_from)
386+
assert 'Successfully installed hackedegginfo\n' in result.stdout
387+
388+
379389
def test_install_using_install_option_and_editable():
380390
"""
381391
Test installing a tool using -e and --install-option

0 commit comments

Comments
 (0)