Remove the setuptools version check

With the vendoring of pkg_resources we no longer need to worry
about the version of the installed setuptools.
This commit is contained in:
Donald Stufft 2014-01-07 06:43:10 -05:00
parent 073ae0d0b1
commit cb7af82f20
5 changed files with 20 additions and 65 deletions

View File

@ -9,7 +9,7 @@ from pip.log import logger
from pip.exceptions import CommandError, PreviousBuildDirError
from pip.req import InstallRequirement, RequirementSet, parse_requirements
from pip.util import normalize_path
from pip.wheel import WheelBuilder, wheel_setuptools_support
from pip.wheel import WheelBuilder
from pip import cmdoptions
DEFAULT_WHEEL_DIR = os.path.join(normalize_path(os.curdir), 'wheelhouse')
@ -89,8 +89,21 @@ class WheelCommand(Command):
import wheel.bdist_wheel
except ImportError:
raise CommandError("'pip wheel' requires the 'wheel' package. To fix this, run: pip install wheel")
if not wheel_setuptools_support():
raise CommandError("'pip wheel' requires setuptools>=0.8. To fix this, run: pip install --upgrade setuptools")
try:
import pkg_resources
except ImportError:
raise CommandError(
"'pip wheel' requires setuptools >= 0.8 for dist-info support."
" To fix this, run: pip install --upgrade setuptools"
)
else:
if not hasattr(pkg_resources, 'DistInfoDistribution'):
raise CommandError(
"'pip wheel' requires setuptools >= 0.8 for dist-info "
"support. To fix this, run: pip install --upgrade "
"setuptools"
)
index_urls = [options.index_url] + options.extra_index_urls
if options.no_index:

View File

@ -12,7 +12,7 @@ from pip.exceptions import (DistributionNotFound, BestVersionAlreadyInstalled,
InstallationError, InvalidWheelFilename, UnsupportedWheel)
from pip.backwardcompat import urlparse, url2pathname
from pip.download import PipSession, url_to_path, path_to_url
from pip.wheel import Wheel, wheel_ext, wheel_setuptools_support
from pip.wheel import Wheel, wheel_ext
from pip.pep425tags import supported_tags, supported_tags_noarch, get_platform
from pip._vendor import html5lib, requests, pkg_resources
from pip._vendor.requests.exceptions import SSLError
@ -77,16 +77,6 @@ class PackageFinder(object):
# The Session we'll use to make requests
self.session = session or PipSession()
@property
def use_wheel(self):
return self._use_wheel
@use_wheel.setter
def use_wheel(self, value):
self._use_wheel = value
if self._use_wheel and not wheel_setuptools_support():
raise InstallationError("pip's wheel support requires setuptools >= 0.8 for dist-info support.")
def add_dependency_links(self, links):
## FIXME: this shouldn't be global list this, it should only
## apply to requirements of the package that specifies the

View File

@ -25,14 +25,6 @@ from pip._vendor.distlib.scripts import ScriptMaker
wheel_ext = '.whl'
def wheel_setuptools_support():
"""
Return True if we have a setuptools that supports wheel.
"""
fulfilled = hasattr(pkg_resources, 'DistInfoDistribution')
if not fulfilled:
logger.warn("Wheel installs require setuptools >= 0.8 for dist-info support.")
return fulfilled
def rehash(path, algo='sha256', blocksize=1<<20):
"""Return (hash, length) for path using hashlib.new(algo)"""

View File

@ -172,7 +172,7 @@ class Tests_get_installed_distributions:
@patch('pip.util.dist_is_local')
@patch('pip.util.dist_is_editable')
@patch('pkg_resources.working_set', workingset)
@patch('pip._vendor.pkg_resources.working_set', workingset)
def test_editables_only(self, mock_dist_is_editable, mock_dist_is_local):
mock_dist_is_editable.side_effect = self.dist_is_editable
mock_dist_is_local.side_effect = self.dist_is_local
@ -183,7 +183,7 @@ class Tests_get_installed_distributions:
@patch('pip.util.dist_is_local')
@patch('pip.util.dist_is_editable')
@patch('pkg_resources.working_set', workingset)
@patch('pip._vendor.pkg_resources.working_set', workingset)
def test_exclude_editables(self, mock_dist_is_editable, mock_dist_is_local):
mock_dist_is_editable.side_effect = self.dist_is_editable
mock_dist_is_local.side_effect = self.dist_is_local
@ -194,7 +194,7 @@ class Tests_get_installed_distributions:
@patch('pip.util.dist_is_local')
@patch('pip.util.dist_is_editable')
@patch('pkg_resources.working_set', workingset)
@patch('pip._vendor.pkg_resources.working_set', workingset)
def test_include_globals(self, mock_dist_is_editable, mock_dist_is_local):
mock_dist_is_editable.side_effect = self.dist_is_editable
mock_dist_is_local.side_effect = self.dist_is_local

View File

@ -51,46 +51,6 @@ def test_uninstallation_paths():
assert paths2 == paths
class TestWheelSupported(object):
def set_use_wheel_true(self, finder):
finder.use_wheel = True
def test_wheel_supported_true(self, monkeypatch):
"""
Test wheel_supported returns true, when setuptools is installed and requirement is met
"""
monkeypatch.setattr('pkg_resources.DistInfoDistribution', True)
assert wheel.wheel_setuptools_support()
def test_wheel_supported_false_no_install(self, monkeypatch):
"""
Test wheel_supported returns false, when setuptools not installed or does not meet the requirement
"""
monkeypatch.delattr('pkg_resources.DistInfoDistribution')
assert not wheel.wheel_setuptools_support()
def test_finder_raises_error(self, monkeypatch):
"""
Test the PackageFinder raises an error when wheel is not supported
"""
monkeypatch.delattr('pkg_resources.DistInfoDistribution')
# on initialization
assert_raises_regexp(InstallationError, 'wheel support', PackageFinder, [], [], use_wheel=True)
# when setting property later
p = PackageFinder([], [], use_wheel=False)
assert_raises_regexp(InstallationError, 'wheel support', self.set_use_wheel_true, p)
def test_finder_no_raises_error(self, monkeypatch):
"""
Test the PackageFinder doesn't raises an error when use_wheel is False, and wheel is supported
"""
monkeypatch.setattr('pkg_resources.DistInfoDistribution', True)
p = PackageFinder( [], [], use_wheel=False)
p = PackageFinder([], [])
p.use_wheel = False
class TestWheelFile(object):
def test_inavlid_filename_raises(self):