File: _post_pip_import.patch

package info (click to toggle)
pipenv 2024.0.1%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,568 kB
  • sloc: python: 187,163; makefile: 191; javascript: 133; sh: 64
file content (42 lines) | stat: -rw-r--r-- 1,902 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
diff --git a/pipenv/patched/pip/__main__.py b/pipenv/patched/pip/__main__.py
index 599132611..f6ff8ad22 100644
--- a/pipenv/patched/pip/__main__.py
+++ b/pipenv/patched/pip/__main__.py
@@ -19,6 +19,13 @@ if __package__ == "":
     sys.path.insert(0, path)

 if __name__ == "__main__":
+    import importlib.util
+    import sys
+    spec = importlib.util.spec_from_file_location(
+        "pipenv", location=os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "__init__.py"))
+    pipenv = importlib.util.module_from_spec(spec)
+    sys.modules["pipenv"] = pipenv
+    spec.loader.exec_module(pipenv)
    from pipenv.patched.pip._internal.cli.main import main as _main

     sys.exit(_main())
diff --git a/pipenv/patched/pip/_internal/resolution/resolvelib/candidates.py b/pipenv/patched/pip/_internal/resolution/resolvelib/candidates.py
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
 import sys
 from typing import TYPE_CHECKING, Any, FrozenSet, Iterable, Optional, Tuple, Union, cast

+from pipenv.patched.pip._vendor.packaging.specifiers import SpecifierSet
 from pipenv.patched.pip._vendor.packaging.utils import NormalizedName, canonicalize_name
 from pipenv.patched.pip._vendor.packaging.version import Version

@@ -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
+        ireq = self._ireq
+        if self._version and ireq.req and not ireq.req.url:
+            ireq.req.specifier = SpecifierSet(f"=={self._version}")
+        return ireq


 class LinkCandidate(_InstallRequirementBackedCandidate):