Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Make _run_setup_py magic use pkg_resources.iter_entry_points #584

Merged
merged 2 commits into from

4 participants

@msabramo

instead of relying on egg_info.iter_entry_points, which might not be there if someone
redefines egg_info (like the setup.py in pyobjc-core does)

Fixes GH-11.

@msabramo msabramo Make magic use pkg_resources.iter_entry_points instead of relying on
egg_info.iter_entry_points, which might not be there if someone
redefines egg_info (like the setup.py for pyobjc-core does)

Fixes GH-11
ea109a0
@travisbot

This pull request passes (merged ea109a0 into 4c96de6).

@jezdez
Owner

Hm, even if the tests pass, this needs a test on its own.

@msabramo

@jezdez Good point. See e089e40. Here's the result of running it without and with the fix in ea109a0:

[last: 0] marca@SCML-MarcA:~/dev/git-repos/pip$ git checkout develop
M   tests/test_basic.py
Switched to branch 'develop'
[last: 0] marca@SCML-MarcA:~/dev/git-repos/pip$ .tox/py27/bin/nosetests -s tests.test_basic:test_install_with_hacked_egg_info
Script result: pip install .
  return code: 1
-- stdout: --------------------
Unpacking /Users/marca/dev/git-repos/pip/tests/packages/HackedEggInfo
  Running setup.py egg_info for package from file:///Users/marca/dev/git-repos/pip/tests/packages/HackedEggInfo
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/tmp/pip-ciqDa5-build/setup.py", line 44, in <module>
        zip_safe = False,
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
        dist.run_commands()
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/tmp/pip-ciqDa5-build/setup.py", line 22, in run
        orig_egg_info.egg_info.run(self)
      File "<string>", line 7, in replacement_run
    AttributeError: class egg_info has no attribute 'iter_entry_points'
    Complete output from command python setup.py egg_info:
    running egg_info

creating pip-egg-info/pyobjc_core.egg-info

Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "/tmp/pip-ciqDa5-build/setup.py", line 44, in <module>

    zip_safe = False,

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup

    dist.run_commands()

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands

    self.run_command(cmd)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command

    cmd_obj.run()

  File "/tmp/pip-ciqDa5-build/setup.py", line 22, in run

    orig_egg_info.egg_info.run(self)

  File "<string>", line 7, in replacement_run

AttributeError: class egg_info has no attribute 'iter_entry_points'

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-ciqDa5-build
Storing complete log in /Users/marca/dev/git-repos/pip/tests/tests_cache/test_ws/pip-log.txt

-- created: -------------------
  pip-log.txt  (3415 bytes)
F
======================================================================
FAIL: test installing a package which defines its own egg_info class
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/marca/dev/git-repos/pip/.tox/py27/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/Users/marca/dev/git-repos/pip/tests/test_basic.py", line 385, in test_install_with_hacked_egg_info
    run_pip('install', '.', cwd=run_from)
  File "/Users/marca/dev/git-repos/pip/tests/test_pip.py", line 518, in run_pip
    result = env.run('pip', *args, **kw)
  File "/Users/marca/dev/git-repos/pip/tests/test_pip.py", line 380, in run
    return TestPipResult(super(TestPipEnvironment, self).run(cwd=cwd, *args, **kw), verbose=self.verbose)
  File "/Users/marca/dev/git-repos/pip/.tox/py27/lib/python2.7/site-packages/scripttest/__init__.py", line 255, in run
    result.assert_no_error(quiet)
  File "/Users/marca/dev/git-repos/pip/.tox/py27/lib/python2.7/site-packages/scripttest/__init__.py", line 402, in assert_no_error
    "Script returned code: %s" % self.returncode)
AssertionError: Script returned code: 1

----------------------------------------------------------------------
Ran 1 test in 4.194s

FAILED (failures=1)
[last: 5] marca@SCML-MarcA:~/dev/git-repos/pip$ git checkout issue-11
M   tests/test_basic.py
Switched to branch 'issue-11'
[last: 0] marca@SCML-MarcA:~/dev/git-repos/pip$ .tox/py27/bin/nosetests -s tests.test_basic:test_install_with_hacked_egg_info
.
----------------------------------------------------------------------
Ran 1 test in 4.104s

OK
@travisbot

This pull request passes (merged e089e40f into 4c96de6).

@travisbot

This pull request passes (merged 1f84b65 into 8b8dcea).

@pnasrat pnasrat merged commit 5562a6b into pypa:develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 21, 2012
  1. @msabramo

    Make magic use pkg_resources.iter_entry_points instead of relying on

    msabramo authored
    egg_info.iter_entry_points, which might not be there if someone
    redefines egg_info (like the setup.py for pyobjc-core does)
    
    Fixes GH-11
Commits on Jul 2, 2012
  1. @msabramo
This page is out of date. Refresh to see the latest.
View
6 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'))
View
17 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,
+)
+
View
10 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
Something went wrong with that request. Please try again.