mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 06:46:15 +00:00
Merge pull request #5887 from pypa/issue-5827-compat
Issue 5827 restore ignore compatibility finder
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
Restore the ignore compatibility finder pip patch to resolve issues collecting hashes from google artifact registry (and possibly others).
|
||||||
@@ -125,6 +125,7 @@ class LinkEvaluator:
|
|||||||
target_python: TargetPython,
|
target_python: TargetPython,
|
||||||
allow_yanked: bool,
|
allow_yanked: bool,
|
||||||
ignore_requires_python: Optional[bool] = None,
|
ignore_requires_python: Optional[bool] = None,
|
||||||
|
ignore_compatibility: Optional[bool] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
:param project_name: The user supplied package name.
|
:param project_name: The user supplied package name.
|
||||||
@@ -142,6 +143,8 @@ class LinkEvaluator:
|
|||||||
:param ignore_requires_python: Whether to ignore incompatible
|
:param ignore_requires_python: Whether to ignore incompatible
|
||||||
PEP 503 "data-requires-python" values in HTML links. Defaults
|
PEP 503 "data-requires-python" values in HTML links. Defaults
|
||||||
to False.
|
to False.
|
||||||
|
:param ignore_compatibility: Whether to ignore
|
||||||
|
compatibility of python versions and allow all versions of packages.
|
||||||
"""
|
"""
|
||||||
if ignore_requires_python is None:
|
if ignore_requires_python is None:
|
||||||
ignore_requires_python = False
|
ignore_requires_python = False
|
||||||
@@ -151,6 +154,7 @@ class LinkEvaluator:
|
|||||||
self._ignore_requires_python = ignore_requires_python
|
self._ignore_requires_python = ignore_requires_python
|
||||||
self._formats = formats
|
self._formats = formats
|
||||||
self._target_python = target_python
|
self._target_python = target_python
|
||||||
|
self._ignore_compatibility = ignore_compatibility
|
||||||
|
|
||||||
self.project_name = project_name
|
self.project_name = project_name
|
||||||
|
|
||||||
@@ -181,10 +185,10 @@ class LinkEvaluator:
|
|||||||
LinkType.format_unsupported,
|
LinkType.format_unsupported,
|
||||||
f"unsupported archive format: {ext}",
|
f"unsupported archive format: {ext}",
|
||||||
)
|
)
|
||||||
if "binary" not in self._formats and ext == WHEEL_EXTENSION:
|
if "binary" not in self._formats and ext == WHEEL_EXTENSION and not self._ignore_compatibility:
|
||||||
reason = f"No binaries permitted for {self.project_name}"
|
reason = f"No binaries permitted for {self.project_name}"
|
||||||
return (LinkType.format_unsupported, reason)
|
return (LinkType.format_unsupported, reason)
|
||||||
if "macosx10" in link.path and ext == ".zip":
|
if "macosx10" in link.path and ext == ".zip" and not self._ignore_compatibility:
|
||||||
return (LinkType.format_unsupported, "macosx10 one")
|
return (LinkType.format_unsupported, "macosx10 one")
|
||||||
if ext == WHEEL_EXTENSION:
|
if ext == WHEEL_EXTENSION:
|
||||||
try:
|
try:
|
||||||
@@ -199,7 +203,7 @@ class LinkEvaluator:
|
|||||||
return (LinkType.different_project, reason)
|
return (LinkType.different_project, reason)
|
||||||
|
|
||||||
supported_tags = self._target_python.get_tags()
|
supported_tags = self._target_python.get_tags()
|
||||||
if not wheel.supported(supported_tags):
|
if not wheel.supported(supported_tags) and not self._ignore_compatibility:
|
||||||
# Include the wheel's tags in the reason string to
|
# Include the wheel's tags in the reason string to
|
||||||
# simplify troubleshooting compatibility issues.
|
# simplify troubleshooting compatibility issues.
|
||||||
file_tags = ", ".join(wheel.get_formatted_file_tags())
|
file_tags = ", ".join(wheel.get_formatted_file_tags())
|
||||||
@@ -240,7 +244,7 @@ class LinkEvaluator:
|
|||||||
version_info=self._target_python.py_version_info,
|
version_info=self._target_python.py_version_info,
|
||||||
ignore_requires_python=self._ignore_requires_python,
|
ignore_requires_python=self._ignore_requires_python,
|
||||||
)
|
)
|
||||||
if not supports_python:
|
if not supports_python and not self._ignore_compatibility:
|
||||||
reason = f"{version} Requires-Python {link.requires_python}"
|
reason = f"{version} Requires-Python {link.requires_python}"
|
||||||
return (LinkType.requires_python_mismatch, reason)
|
return (LinkType.requires_python_mismatch, reason)
|
||||||
|
|
||||||
@@ -487,7 +491,11 @@ class CandidateEvaluator:
|
|||||||
|
|
||||||
return sorted(filtered_applicable_candidates, key=self._sort_key)
|
return sorted(filtered_applicable_candidates, key=self._sort_key)
|
||||||
|
|
||||||
def _sort_key(self, candidate: InstallationCandidate) -> CandidateSortingKey:
|
def _sort_key(
|
||||||
|
self,
|
||||||
|
candidate: InstallationCandidate,
|
||||||
|
ignore_compatibility: bool = True
|
||||||
|
) -> CandidateSortingKey:
|
||||||
"""
|
"""
|
||||||
Function to pass as the `key` argument to a call to sorted() to sort
|
Function to pass as the `key` argument to a call to sorted() to sort
|
||||||
InstallationCandidates by preference.
|
InstallationCandidates by preference.
|
||||||
@@ -532,10 +540,12 @@ class CandidateEvaluator:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise UnsupportedWheel(
|
if not ignore_compatibility:
|
||||||
"{} is not a supported wheel for this platform. It "
|
raise UnsupportedWheel(
|
||||||
"can't be sorted.".format(wheel.filename)
|
"{} is not a supported wheel for this platform. It "
|
||||||
)
|
"can't be sorted.".format(wheel.filename)
|
||||||
|
)
|
||||||
|
pri = -support_num
|
||||||
if self._prefer_binary:
|
if self._prefer_binary:
|
||||||
binary_preference = 1
|
binary_preference = 1
|
||||||
if wheel.build_tag is not None:
|
if wheel.build_tag is not None:
|
||||||
@@ -602,6 +612,7 @@ class PackageFinder:
|
|||||||
format_control: Optional[FormatControl] = None,
|
format_control: Optional[FormatControl] = None,
|
||||||
candidate_prefs: Optional[CandidatePreferences] = None,
|
candidate_prefs: Optional[CandidatePreferences] = None,
|
||||||
ignore_requires_python: Optional[bool] = None,
|
ignore_requires_python: Optional[bool] = None,
|
||||||
|
ignore_compatibility: Optional[bool] = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
This constructor is primarily meant to be used by the create() class
|
This constructor is primarily meant to be used by the create() class
|
||||||
@@ -623,6 +634,7 @@ class PackageFinder:
|
|||||||
self._ignore_requires_python = ignore_requires_python
|
self._ignore_requires_python = ignore_requires_python
|
||||||
self._link_collector = link_collector
|
self._link_collector = link_collector
|
||||||
self._target_python = target_python
|
self._target_python = target_python
|
||||||
|
self._ignore_compatibility = ignore_compatibility
|
||||||
|
|
||||||
self.format_control = format_control
|
self.format_control = format_control
|
||||||
|
|
||||||
@@ -723,6 +735,7 @@ class PackageFinder:
|
|||||||
target_python=self._target_python,
|
target_python=self._target_python,
|
||||||
allow_yanked=self._allow_yanked,
|
allow_yanked=self._allow_yanked,
|
||||||
ignore_requires_python=self._ignore_requires_python,
|
ignore_requires_python=self._ignore_requires_python,
|
||||||
|
ignore_compatibility=self._ignore_compatibility,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _sort_links(self, links: Iterable[Link]) -> List[Link]:
|
def _sort_links(self, links: Iterable[Link]) -> List[Link]:
|
||||||
|
|||||||
+1
-1
@@ -350,7 +350,7 @@ class Project:
|
|||||||
|
|
||||||
return self.prepend_hash_types(collected_hashes, FAVORITE_HASH)
|
return self.prepend_hash_types(collected_hashes, FAVORITE_HASH)
|
||||||
|
|
||||||
except (ValueError, KeyError, ConnectionError):
|
except Exception:
|
||||||
if self.s.is_verbose():
|
if self.s.is_verbose():
|
||||||
click.echo(
|
click.echo(
|
||||||
"{}: Error generating hash for {}".format(
|
"{}: Error generating hash for {}".format(
|
||||||
|
|||||||
+15
-11
@@ -334,13 +334,13 @@ class Resolver:
|
|||||||
)
|
)
|
||||||
return finder
|
return finder
|
||||||
|
|
||||||
@property
|
def finder(self, ignore_compatibility=True):
|
||||||
def finder(self):
|
|
||||||
finder = self.package_finder
|
finder = self.package_finder
|
||||||
index_lookup = self.prepare_index_lookup()
|
index_lookup = self.prepare_index_lookup()
|
||||||
finder._link_collector.index_lookup = index_lookup
|
finder._link_collector.index_lookup = index_lookup
|
||||||
finder._link_collector.search_scope.index_restricted = True
|
finder._link_collector.search_scope.index_restricted = True
|
||||||
finder._link_collector.search_scope.index_lookup = index_lookup
|
finder._link_collector.search_scope.index_lookup = index_lookup
|
||||||
|
finder._ignore_compatibility = ignore_compatibility
|
||||||
return finder
|
return finder
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
@@ -349,7 +349,7 @@ class Resolver:
|
|||||||
pip_options.extra_index_urls = []
|
pip_options.extra_index_urls = []
|
||||||
return parse_requirements(
|
return parse_requirements(
|
||||||
self.constraint_file,
|
self.constraint_file,
|
||||||
finder=self.finder,
|
finder=self.finder(),
|
||||||
session=self.session,
|
session=self.session,
|
||||||
options=pip_options,
|
options=pip_options,
|
||||||
)
|
)
|
||||||
@@ -361,7 +361,7 @@ class Resolver:
|
|||||||
parsed_default_constraints = parse_requirements(
|
parsed_default_constraints = parse_requirements(
|
||||||
self.default_constraint_file,
|
self.default_constraint_file,
|
||||||
constraint=True,
|
constraint=True,
|
||||||
finder=self.finder,
|
finder=self.finder(),
|
||||||
session=self.session,
|
session=self.session,
|
||||||
options=pip_options,
|
options=pip_options,
|
||||||
)
|
)
|
||||||
@@ -411,7 +411,7 @@ class Resolver:
|
|||||||
globally_managed=True
|
globally_managed=True
|
||||||
) as directory:
|
) as directory:
|
||||||
pip_options = self.pip_options
|
pip_options = self.pip_options
|
||||||
finder = self.finder
|
finder = self.finder()
|
||||||
wheel_cache = WheelCache(pip_options.cache_dir)
|
wheel_cache = WheelCache(pip_options.cache_dir)
|
||||||
preparer = self.pip_command.make_requirement_preparer(
|
preparer = self.pip_command.make_requirement_preparer(
|
||||||
temp_build_dir=directory,
|
temp_build_dir=directory,
|
||||||
@@ -495,9 +495,11 @@ class Resolver:
|
|||||||
if result.markers:
|
if result.markers:
|
||||||
self.markers[result.name] = result.markers
|
self.markers[result.name] = result.markers
|
||||||
else:
|
else:
|
||||||
candidate = self.finder.find_best_candidate(
|
candidate = (
|
||||||
result.name, result.specifier
|
self.finder()
|
||||||
).best_candidate
|
.find_best_candidate(result.name, result.specifier)
|
||||||
|
.best_candidate
|
||||||
|
)
|
||||||
if candidate:
|
if candidate:
|
||||||
requires_python = candidate.link.requires_python
|
requires_python = candidate.link.requires_python
|
||||||
if requires_python:
|
if requires_python:
|
||||||
@@ -545,9 +547,11 @@ class Resolver:
|
|||||||
if hashes:
|
if hashes:
|
||||||
return hashes
|
return hashes
|
||||||
|
|
||||||
applicable_candidates = self.finder.find_best_candidate(
|
applicable_candidates = (
|
||||||
ireq.name, ireq.specifier
|
self.finder(ignore_compatibility=True)
|
||||||
).iter_applicable()
|
.find_best_candidate(ireq.name, ireq.specifier)
|
||||||
|
.iter_applicable()
|
||||||
|
)
|
||||||
applicable_candidates = list(applicable_candidates)
|
applicable_candidates = list(applicable_candidates)
|
||||||
if applicable_candidates:
|
if applicable_candidates:
|
||||||
return sorted(
|
return sorted(
|
||||||
|
|||||||
@@ -0,0 +1,114 @@
|
|||||||
|
diff --git a/pipenv/patched/pip/_internal/index/package_finder.py b/pipenv/patched/pip/_internal/index/package_finder.py
|
||||||
|
index e74e6623..cc81f35c 100644
|
||||||
|
--- a/pipenv/patched/pip/_internal/index/package_finder.py
|
||||||
|
+++ b/pipenv/patched/pip/_internal/index/package_finder.py
|
||||||
|
@@ -125,6 +125,7 @@ class LinkEvaluator:
|
||||||
|
target_python: TargetPython,
|
||||||
|
allow_yanked: bool,
|
||||||
|
ignore_requires_python: Optional[bool] = None,
|
||||||
|
+ ignore_compatibility: Optional[bool] = None,
|
||||||
|
) -> None:
|
||||||
|
"""
|
||||||
|
:param project_name: The user supplied package name.
|
||||||
|
@@ -142,6 +143,8 @@ class LinkEvaluator:
|
||||||
|
:param ignore_requires_python: Whether to ignore incompatible
|
||||||
|
PEP 503 "data-requires-python" values in HTML links. Defaults
|
||||||
|
to False.
|
||||||
|
+ :param ignore_compatibility: Whether to ignore
|
||||||
|
+ compatibility of python versions and allow all versions of packages.
|
||||||
|
"""
|
||||||
|
if ignore_requires_python is None:
|
||||||
|
ignore_requires_python = False
|
||||||
|
@@ -151,6 +154,7 @@ class LinkEvaluator:
|
||||||
|
self._ignore_requires_python = ignore_requires_python
|
||||||
|
self._formats = formats
|
||||||
|
self._target_python = target_python
|
||||||
|
+ self._ignore_compatibility = ignore_compatibility
|
||||||
|
|
||||||
|
self.project_name = project_name
|
||||||
|
|
||||||
|
@@ -181,10 +185,10 @@ class LinkEvaluator:
|
||||||
|
LinkType.format_unsupported,
|
||||||
|
f"unsupported archive format: {ext}",
|
||||||
|
)
|
||||||
|
- if "binary" not in self._formats and ext == WHEEL_EXTENSION:
|
||||||
|
+ if "binary" not in self._formats and ext == WHEEL_EXTENSION and not self._ignore_compatibility:
|
||||||
|
reason = f"No binaries permitted for {self.project_name}"
|
||||||
|
return (LinkType.format_unsupported, reason)
|
||||||
|
- if "macosx10" in link.path and ext == ".zip":
|
||||||
|
+ if "macosx10" in link.path and ext == ".zip" and not self._ignore_compatibility:
|
||||||
|
return (LinkType.format_unsupported, "macosx10 one")
|
||||||
|
if ext == WHEEL_EXTENSION:
|
||||||
|
try:
|
||||||
|
@@ -199,7 +203,7 @@ class LinkEvaluator:
|
||||||
|
return (LinkType.different_project, reason)
|
||||||
|
|
||||||
|
supported_tags = self._target_python.get_tags()
|
||||||
|
- if not wheel.supported(supported_tags):
|
||||||
|
+ if not wheel.supported(supported_tags) and not self._ignore_compatibility:
|
||||||
|
# Include the wheel's tags in the reason string to
|
||||||
|
# simplify troubleshooting compatibility issues.
|
||||||
|
file_tags = ", ".join(wheel.get_formatted_file_tags())
|
||||||
|
@@ -240,7 +244,7 @@ class LinkEvaluator:
|
||||||
|
version_info=self._target_python.py_version_info,
|
||||||
|
ignore_requires_python=self._ignore_requires_python,
|
||||||
|
)
|
||||||
|
- if not supports_python:
|
||||||
|
+ if not supports_python and not self._ignore_compatibility:
|
||||||
|
reason = f"{version} Requires-Python {link.requires_python}"
|
||||||
|
return (LinkType.requires_python_mismatch, reason)
|
||||||
|
|
||||||
|
@@ -487,7 +491,11 @@ class CandidateEvaluator:
|
||||||
|
|
||||||
|
return sorted(filtered_applicable_candidates, key=self._sort_key)
|
||||||
|
|
||||||
|
- def _sort_key(self, candidate: InstallationCandidate) -> CandidateSortingKey:
|
||||||
|
+ def _sort_key(
|
||||||
|
+ self,
|
||||||
|
+ candidate: InstallationCandidate,
|
||||||
|
+ ignore_compatibility: bool = True
|
||||||
|
+ ) -> CandidateSortingKey:
|
||||||
|
"""
|
||||||
|
Function to pass as the `key` argument to a call to sorted() to sort
|
||||||
|
InstallationCandidates by preference.
|
||||||
|
@@ -532,10 +540,12 @@ class CandidateEvaluator:
|
||||||
|
)
|
||||||
|
)
|
||||||
|
except ValueError:
|
||||||
|
- raise UnsupportedWheel(
|
||||||
|
- "{} is not a supported wheel for this platform. It "
|
||||||
|
- "can't be sorted.".format(wheel.filename)
|
||||||
|
- )
|
||||||
|
+ if not ignore_compatibility:
|
||||||
|
+ raise UnsupportedWheel(
|
||||||
|
+ "{} is not a supported wheel for this platform. It "
|
||||||
|
+ "can't be sorted.".format(wheel.filename)
|
||||||
|
+ )
|
||||||
|
+ pri = -support_num
|
||||||
|
if self._prefer_binary:
|
||||||
|
binary_preference = 1
|
||||||
|
if wheel.build_tag is not None:
|
||||||
|
@@ -602,6 +612,7 @@ class PackageFinder:
|
||||||
|
format_control: Optional[FormatControl] = None,
|
||||||
|
candidate_prefs: Optional[CandidatePreferences] = None,
|
||||||
|
ignore_requires_python: Optional[bool] = None,
|
||||||
|
+ ignore_compatibility: Optional[bool] = False,
|
||||||
|
) -> None:
|
||||||
|
"""
|
||||||
|
This constructor is primarily meant to be used by the create() class
|
||||||
|
@@ -623,6 +634,7 @@ class PackageFinder:
|
||||||
|
self._ignore_requires_python = ignore_requires_python
|
||||||
|
self._link_collector = link_collector
|
||||||
|
self._target_python = target_python
|
||||||
|
+ self._ignore_compatibility = ignore_compatibility
|
||||||
|
|
||||||
|
self.format_control = format_control
|
||||||
|
|
||||||
|
@@ -723,6 +735,7 @@ class PackageFinder:
|
||||||
|
target_python=self._target_python,
|
||||||
|
allow_yanked=self._allow_yanked,
|
||||||
|
ignore_requires_python=self._ignore_requires_python,
|
||||||
|
+ ignore_compatibility=self._ignore_compatibility,
|
||||||
|
)
|
||||||
|
|
||||||
|
def _sort_links(self, links: Iterable[Link]) -> List[Link]:
|
||||||
Reference in New Issue
Block a user