1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

wheel is also supported now with setuptools>=0.7.2

This commit is contained in:
Marcus Smith 2013-06-13 22:04:05 -07:00
parent f702f3b6fa
commit 72f0ec9419
5 changed files with 25 additions and 18 deletions

View file

@ -232,12 +232,12 @@ class InstallCommand(Command):
logger.warn(msg)
return
import setuptools
if (options.use_user_site and
requirement_set.has_editables and
not getattr(setuptools, '_distribute', False)):
# import setuptools
# if (options.use_user_site and
# requirement_set.has_editables and
# not getattr(setuptools, '_distribute', False)):
raise InstallationError('--user --editable not supported with setuptools, use distribute')
# raise InstallationError('--user --editable not supported with setuptools, use distribute')
try:
if not options.no_download:

View file

@ -10,7 +10,7 @@ from pip.backwardcompat import wheel_skip_reqs
from pip.exceptions import CommandError
from pip.req import InstallRequirement, RequirementSet, parse_requirements
from pip.util import normalize_path
from pip.wheel import WheelBuilder, wheel_distribute_support, distribute_requirement
from pip.wheel import WheelBuilder, wheel_setuptools_support, distribute_requirement, setuptools_requirement
from pip import cmdoptions
DEFAULT_WHEEL_DIR = os.path.join(normalize_path(os.curdir), 'wheelhouse')
@ -83,8 +83,8 @@ class WheelCommand(Command):
import wheel.bdist_wheel
except ImportError:
raise CommandError("'pip wheel' requires bdist_wheel from the 'wheel' distribution.")
if not wheel_distribute_support():
raise CommandError("'pip wheel' requires %s." % distribute_requirement)
if not wheel_setuptools_support():
raise CommandError("'pip wheel' requires %s or %s." % (distribute_requirement, setuptools_requirement))
index_urls = [options.index_url] + options.extra_index_urls
if options.no_index:

View file

@ -29,7 +29,7 @@ from pip.backwardcompat import (WindowsError, BytesIO,
Empty as QueueEmpty)
from pip.backwardcompat import CertificateError
from pip.download import urlopen, path_to_url2, url_to_path, geturl, Urllib2HeadRequest
from pip.wheel import Wheel, wheel_ext, wheel_distribute_support, distribute_requirement
from pip.wheel import Wheel, wheel_ext, wheel_setuptools_support, distribute_requirement
from pip.pep425tags import supported_tags
from pip.vendor import html5lib
@ -90,7 +90,7 @@ class PackageFinder(object):
@use_wheel.setter
def use_wheel(self, value):
self._use_wheel = value
if self._use_wheel and not wheel_distribute_support():
if self._use_wheel and not wheel_setuptools_support():
raise InstallationError("pip's wheel support requires %s." % distribute_requirement)
def add_dependency_links(self, links):

View file

@ -20,20 +20,27 @@ from pip.util import call_subprocess, normalize_path, make_path_relative
wheel_ext = '.whl'
distribute_requirement = pkg_resources.Requirement.parse("distribute>=0.6.34")
setuptools_requirement = pkg_resources.Requirement.parse("setuptools>=0.7.2")
def wheel_distribute_support(distribute_req=distribute_requirement):
def wheel_setuptools_support():
"""
Return True if we have a distribute that supports wheel.
distribute_req: a pkg_resources.Requirement for distribute
"""
installed_distribute = installed_setuptools = None
try:
installed_dist = pkg_resources.get_distribution('distribute')
supported = installed_dist in distribute_req
installed_distribute = pkg_resources.get_distribution('distribute')
except pkg_resources.DistributionNotFound:
supported = False
pass
try:
installed_setuptools = pkg_resources.get_distribution('setuptools')
except pkg_resources.DistributionNotFound:
pass
supported = (installed_distribute in distribute_requirement) or (installed_setuptools in setuptools_requirement)
if not supported:
logger.warn("%s is required for wheel installs.", distribute_req)
logger.warn("%s or %s is required for wheel installs." % (setuptools_requirement, distribute_requirement))
return supported

View file

@ -48,7 +48,7 @@ class TestWheelSupported(object):
Test wheel_supported returns true, when distribute is installed and requirement is met
"""
mock_get_distribution.return_value = pkg_resources.Distribution(project_name='distribute', version='0.6.34')
assert wheel.wheel_distribute_support()
assert wheel.wheel_setuptools_support()
@patch("pip.wheel.pkg_resources.get_distribution")
def test_wheel_supported_false_no_install(self, mock_get_distribution):
@ -56,7 +56,7 @@ class TestWheelSupported(object):
Test wheel_supported returns false, when distribute not installed
"""
mock_get_distribution.side_effect = self.raise_not_found
assert not wheel.wheel_distribute_support()
assert not wheel.wheel_setuptools_support()
@patch("pip.wheel.pkg_resources.get_distribution")
def test_wheel_supported_false_req_fail(self, mock_get_distribution):
@ -64,7 +64,7 @@ class TestWheelSupported(object):
Test wheel_supported returns false, when distribute is installed, but req is not met
"""
mock_get_distribution.return_value = pkg_resources.Distribution(project_name='distribute', version='0.6.28')
assert not wheel.wheel_distribute_support()
assert not wheel.wheel_setuptools_support()
@patch("pip.wheel.pkg_resources.get_distribution")
def test_finder_raises_error(self, mock_get_distribution):