Skip to content

Commit

Permalink
Merge pull request pypa#584 from msabramo/issue-11
Browse files Browse the repository at this point in the history
Make _run_setup_py magic use pkg_resources.iter_entry_points
  • Loading branch information
pnasrat committed Jul 2, 2012
2 parents 8b8dcea + 1f84b65 commit 5562a6b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pip/req.py
Expand Up @@ -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'))
Expand Down
17 changes: 17 additions & 0 deletions 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,
)

10 changes: 10 additions & 0 deletions tests/test_basic.py
Expand Up @@ -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
Expand Down

0 comments on commit 5562a6b

Please sign in to comment.