Skip to content

Commit

Permalink
Update safety patch
Browse files Browse the repository at this point in the history
  • Loading branch information
matteius authored and oz123 committed Jul 23, 2023
1 parent ed4fced commit 301d204
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions tasks/vendoring/patches/patched/_post_pip_import.patch
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ index 599132611..f6ff8ad22 100644

sys.exit(_main())
diff --git a/pipenv/patched/pip/_internal/resolution/resolvelib/candidates.py b/pipenv/patched/pip/_internal/resolution/resolvelib/candidates.py
index 0ba06c52..6fdb59b7 100644
index de04e1d73..0f54c26a1 100644
--- a/pipenv/patched/pip/_internal/resolution/resolvelib/candidates.py
+++ b/pipenv/patched/pip/_internal/resolution/resolvelib/candidates.py
@@ -2,6 +2,7 @@ import logging
Expand All @@ -28,8 +28,8 @@ index 0ba06c52..6fdb59b7 100644
from pipenv.patched.pip._vendor.packaging.utils import NormalizedName, canonicalize_name
from pipenv.patched.pip._vendor.packaging.version import Version

@@ -253,7 +253,10 @@ class _InstallRequirementBackedCandidate(Candidate):
yield self._factory.make_requires_python_requirement(self.dist.requires_python)
@@ -244,7 +245,10 @@ class _InstallRequirementBackedCandidate(Candidate):
yield self._factory.make_requires_python_requirement(self.dist.requires_python)

def get_install_requirement(self) -> Optional[InstallRequirement]:
- return self._ireq
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ index 858a41014..868a1cad9 100644
"Show help for commands.",
),
diff --git a/pipenv/patched/pip/_internal/index/package_finder.py b/pipenv/patched/pip/_internal/index/package_finder.py
index 9bf247f02..9cfc3003a 100644
index b6f8d57e8..35bf105b9 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:
Expand All @@ -139,9 +139,9 @@ index 9bf247f02..9cfc3003a 100644
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}",
Expand All @@ -157,7 +157,7 @@ index 9bf247f02..9cfc3003a 100644
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:
Expand All @@ -172,11 +172,11 @@ index 9bf247f02..9cfc3003a 100644
+ 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,10 @@ class CandidateEvaluator:

return sorted(filtered_applicable_candidates, key=self._sort_key)

- def _sort_key(self, candidate: InstallationCandidate) -> CandidateSortingKey:
+ def _sort_key(
+ self, candidate: InstallationCandidate,
Expand All @@ -202,49 +202,49 @@ index 9bf247f02..9cfc3003a 100644
if self._prefer_binary:
binary_preference = 1
if wheel.build_tag is not None:
@@ -601,6 +610,7 @@ class PackageFinder:
@@ -602,6 +611,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
@@ -622,6 +632,7 @@ class PackageFinder:
@@ -623,6 +633,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
@@ -722,6 +733,7 @@ class PackageFinder:
target_python=self._target_python,
allow_yanked=self._allow_yanked,
ignore_requires_python=self._ignore_requires_python,

@@ -663,6 +674,7 @@ class PackageFinder:
allow_yanked=selection_prefs.allow_yanked,
format_control=selection_prefs.format_control,
ignore_requires_python=selection_prefs.ignore_requires_python,
+ ignore_compatibility=self._ignore_compatibility
)

def _sort_links(self, links: Iterable[Link]) -> List[Link]:
@property
diff --git a/pipenv/patched/pip/_internal/req/req_install.py b/pipenv/patched/pip/_internal/req/req_install.py
index a1e376c89..1406403a4 100644
index 1f479713a..34fb11c07 100644
--- a/pipenv/patched/pip/_internal/req/req_install.py
+++ b/pipenv/patched/pip/_internal/req/req_install.py
@@ -485,6 +485,7 @@ class InstallRequirement:
@@ -514,6 +514,7 @@ class InstallRequirement:
self.unpacked_source_directory,
backend,
backend_path=backend_path,
+ python_executable=os.getenv('PIP_PYTHON_PATH', sys.executable)
+ python_executable=os.getenv('PIPENV_PYTHON_PATH', sys.executable)
)

def isolated_editable_sanity_check(self) -> None:
diff --git a/pipenv/patched/pip/_vendor/requests/packages.py b/pipenv/patched/pip/_vendor/requests/packages.py
index 9582fa730..720410ab5 100644
--- a/pipenv/patched/pip/_vendor/requests/packages.py
+++ b/pipenv/patched/pip/_vendor/requests/packages.py
@@ -4,13 +4,13 @@ import sys
# I don't like it either. Just look the other way. :)

for package in ('urllib3', 'idna', 'chardet'):
- vendored_package = "pip._vendor." + package
+ vendored_package = "pipenv.patched.pip._vendor." + package
Expand All @@ -257,5 +257,5 @@ index 9582fa730..720410ab5 100644
- sys.modules['pip._vendor.requests.packages.' + unprefixed_mod] = sys.modules[mod]
+ unprefixed_mod = mod[len("pipenv.patched.pip._vendor."):]
+ sys.modules['pipenv.patched.pip._vendor.requests.packages.' + unprefixed_mod] = sys.modules[mod]

# Kinda cool, though, right?
6 changes: 3 additions & 3 deletions tasks/vendoring/patches/patched/pip_index_safety.patch
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ index 0120610c..ead5227e 100644
return link_collector

diff --git a/pipenv/patched/pip/_internal/models/search_scope.py b/pipenv/patched/pip/_internal/models/search_scope.py
index a64af738..76c44656 100644
index fe61e8116..dab85fbb9 100644
--- a/pipenv/patched/pip/_internal/models/search_scope.py
+++ b/pipenv/patched/pip/_internal/models/search_scope.py
@@ -3,7 +3,7 @@ import logging
Expand Down Expand Up @@ -86,14 +86,14 @@ index a64af738..76c44656 100644

def get_formatted_locations(self) -> str:
lines = []
@@ -130,4 +134,7 @@ class SearchScope:
@@ -129,4 +133,9 @@ class SearchScope:
loc = loc + "/"
return loc

- return [mkurl_pypi_url(url) for url in self.index_urls]
+ index_urls = self.index_urls
+ if project_name in self.index_lookup:
+ index_urls = [self.index_lookup[project_name]]
+ else:
+ elif self.index_urls:
+ index_urls = [self.index_urls[0]]
+ return [mkurl_pypi_url(url) for url in index_urls]

0 comments on commit 301d204

Please sign in to comment.