mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Updating the patched pip-tools with the wheel dependency bugifx.
Aligned with pip-tools commit ef0aa2d62bd5499b328e5f3c9b26130d07be16dd plus pipenv patching.
This commit is contained in:
@@ -3,6 +3,7 @@ from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from contextlib import contextmanager
|
||||
|
||||
from six import add_metaclass
|
||||
|
||||
@@ -38,3 +39,10 @@ class BaseRepository(object):
|
||||
all of the files for a given requirement. It is not acceptable for an
|
||||
editable or unpinned requirement to be passed to this function.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
@contextmanager
|
||||
def allow_all_wheels(self):
|
||||
"""
|
||||
Monkey patches pip.Wheel to allow wheels from all platforms and Python versions.
|
||||
"""
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
from contextlib import contextmanager
|
||||
|
||||
from piptools.utils import as_tuple, key_from_req, make_install_requirement
|
||||
from .base import BaseRepository
|
||||
|
||||
@@ -63,3 +65,8 @@ class LocalRequirementsRepository(BaseRepository):
|
||||
|
||||
def get_hashes(self, ireq):
|
||||
return self.repository.get_hashes(ireq)
|
||||
|
||||
@contextmanager
|
||||
def allow_all_wheels(self):
|
||||
with self.repository.allow_all_wheels():
|
||||
yield
|
||||
|
||||
@@ -28,24 +28,6 @@ except ImportError:
|
||||
from .._compat import TemporaryDirectory
|
||||
|
||||
|
||||
# Monkey patch pip's Wheel class to support all platform tags. This allows
|
||||
# pip-tools to generate hashes for all available distributions, not only the
|
||||
# one for the current platform.
|
||||
|
||||
def _wheel_supported(self, tags=None):
|
||||
# Ignore current platform. Support everything.
|
||||
return True
|
||||
|
||||
|
||||
def _wheel_support_index_min(self, tags=None):
|
||||
# All wheels are equal priority for sorting.
|
||||
return 0
|
||||
|
||||
|
||||
Wheel.supported = _wheel_supported
|
||||
Wheel.support_index_min = _wheel_support_index_min
|
||||
|
||||
|
||||
class PyPIRepository(BaseRepository):
|
||||
DEFAULT_INDEX_URL = 'https://pypi.python.org/simple'
|
||||
|
||||
@@ -184,7 +166,7 @@ class PyPIRepository(BaseRepository):
|
||||
|
||||
# We need to get all of the candidates that match our current version
|
||||
# pin, these will represent all of the files that could possibly
|
||||
# satisify this constraint.
|
||||
# satisfy this constraint.
|
||||
all_candidates = self.find_all_candidates(ireq.name)
|
||||
candidates_by_version = lookup_table(all_candidates, key=lambda c: c.version)
|
||||
matching_versions = list(
|
||||
@@ -203,6 +185,37 @@ class PyPIRepository(BaseRepository):
|
||||
h.update(chunk)
|
||||
return ":".join([FAVORITE_HASH, h.hexdigest()])
|
||||
|
||||
@contextmanager
|
||||
def allow_all_wheels(self):
|
||||
"""
|
||||
Monkey patches pip.Wheel to allow wheels from all platforms and Python versions.
|
||||
|
||||
This also saves the candidate cache and set a new one, or else the results from the
|
||||
previous non-patched calls will interfere.
|
||||
"""
|
||||
def _wheel_supported(self, tags=None):
|
||||
# Ignore current platform. Support everything.
|
||||
return True
|
||||
|
||||
def _wheel_support_index_min(self, tags=None):
|
||||
# All wheels are equal priority for sorting.
|
||||
return 0
|
||||
|
||||
original_wheel_supported = Wheel.supported
|
||||
original_support_index_min = Wheel.support_index_min
|
||||
original_cache = self._available_candidates_cache
|
||||
|
||||
Wheel.supported = _wheel_supported
|
||||
Wheel.support_index_min = _wheel_support_index_min
|
||||
self._available_candidates_cache = {}
|
||||
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
Wheel.supported = original_wheel_supported
|
||||
Wheel.support_index_min = original_support_index_min
|
||||
self._available_candidates_cache = original_cache
|
||||
|
||||
|
||||
@contextmanager
|
||||
def open_local_or_remote_file(link, session):
|
||||
|
||||
@@ -68,7 +68,8 @@ class Resolver(object):
|
||||
"""
|
||||
Finds acceptable hashes for all of the given InstallRequirements.
|
||||
"""
|
||||
return {ireq: self.repository.get_hashes(ireq) for ireq in ireqs}
|
||||
with self.repository.allow_all_wheels():
|
||||
return {ireq: self.repository.get_hashes(ireq) for ireq in ireqs}
|
||||
|
||||
def resolve(self, max_rounds=12):
|
||||
"""
|
||||
@@ -248,7 +249,6 @@ class Resolver(object):
|
||||
# NOTE: it's much quicker to immediately return instead of
|
||||
# hitting the index server
|
||||
best_match = ireq
|
||||
|
||||
elif is_pinned_requirement(ireq):
|
||||
# NOTE: it's much quicker to immediately return instead of
|
||||
# hitting the index server
|
||||
|
||||
Reference in New Issue
Block a user