|
12 | 12 | from pathlib import Path
|
13 | 13 | from sysconfig import get_paths, get_python_version, get_scheme_names
|
14 | 14 | from urllib.parse import urlparse
|
15 |
| -from urllib.request import url2pathname |
16 | 15 |
|
17 | 16 | import pipenv
|
18 | 17 | from pipenv.patched.pip._internal.commands.install import InstallCommand
|
19 | 18 | from pipenv.patched.pip._internal.index.package_finder import PackageFinder
|
| 19 | +from pipenv.patched.pip._internal.req.req_install import InstallRequirement |
20 | 20 | from pipenv.patched.pip._vendor import pkg_resources
|
| 21 | +from pipenv.patched.pip._vendor.packaging.specifiers import SpecifierSet |
21 | 22 | from pipenv.patched.pip._vendor.packaging.utils import canonicalize_name
|
22 | 23 | from pipenv.utils import console
|
| 24 | +from pipenv.utils.constants import VCS_LIST |
| 25 | +from pipenv.utils.dependencies import as_pipfile |
| 26 | +from pipenv.utils.fileutils import normalize_path, temp_path |
23 | 27 | from pipenv.utils.funktools import chunked, unnest
|
24 | 28 | from pipenv.utils.indexes import prepare_pip_source_args
|
25 | 29 | from pipenv.utils.processes import subprocess_run
|
26 |
| -from pipenv.utils.shell import make_posix |
| 30 | +from pipenv.utils.shell import make_posix, temp_environ |
27 | 31 | from pipenv.vendor.pythonfinder.utils import is_in_path
|
28 |
| -from pipenv.vendor.requirementslib.fileutils import normalize_path, temp_path |
29 |
| -from pipenv.vendor.requirementslib.utils import temp_environ |
30 | 32 |
|
31 | 33 | try:
|
32 | 34 | # this is only in Python3.8 and later
|
@@ -200,11 +202,6 @@ def base_paths(self) -> dict[str, str]:
|
200 | 202 | .. note:: The implementation of this is borrowed from a combination of pip and
|
201 | 203 | virtualenv and is likely to change at some point in the future.
|
202 | 204 |
|
203 |
| - >>> from pipenv.core import project |
204 |
| - >>> from pipenv.environment import Environment |
205 |
| - >>> env = Environment(prefix=project.virtualenv_location, is_venv=True, sources=project.sources) |
206 |
| - >>> import pprint |
207 |
| - >>> pprint.pprint(env.base_paths) |
208 | 205 | {'PATH': '/home/hawk/.virtualenvs/pipenv-MfOPs1lW/bin::/bin:/usr/bin',
|
209 | 206 | 'PYTHONPATH': '/home/hawk/.virtualenvs/pipenv-MfOPs1lW/lib/python3.7/site-packages',
|
210 | 207 | 'data': '/home/hawk/.virtualenvs/pipenv-MfOPs1lW',
|
@@ -760,38 +757,46 @@ def is_installed(self, pkgname):
|
760 | 757 |
|
761 | 758 | return any(d for d in self.get_distributions() if d.project_name == pkgname)
|
762 | 759 |
|
763 |
| - def is_satisfied(self, req): |
| 760 | + def is_satisfied(self, req: InstallRequirement): |
764 | 761 | match = next(
|
765 | 762 | iter(
|
766 | 763 | d
|
767 | 764 | for d in self.get_distributions()
|
768 |
| - if canonicalize_name(d.project_name) == req.normalized_name |
| 765 | + if req.name |
| 766 | + and canonicalize_name(d.project_name) == canonicalize_name(req.name) |
769 | 767 | ),
|
770 | 768 | None,
|
771 | 769 | )
|
772 | 770 | if match is not None:
|
773 |
| - if req.editable and req.line_instance.is_local and self.find_egg(match): |
774 |
| - requested_path = req.line_instance.path |
| 771 | + if req.editable and req.link and req.link.is_file: |
| 772 | + requested_path = req.link.file_path |
775 | 773 | if os.path.exists(requested_path):
|
776 | 774 | local_path = requested_path
|
777 | 775 | else:
|
778 | 776 | parsed_url = urlparse(requested_path)
|
779 |
| - local_path = url2pathname(parsed_url.path) |
| 777 | + local_path = parsed_url.path |
780 | 778 | return requested_path and os.path.samefile(local_path, match.location)
|
781 | 779 | elif match.has_metadata("direct_url.json"):
|
782 | 780 | direct_url_metadata = json.loads(match.get_metadata("direct_url.json"))
|
783 |
| - commit_id = direct_url_metadata.get("vcs_info", {}).get("commit_id", "") |
| 781 | + requested_revision = direct_url_metadata.get("vcs_info", {}).get( |
| 782 | + "requested_revision", "" |
| 783 | + ) |
784 | 784 | vcs_type = direct_url_metadata.get("vcs_info", {}).get("vcs", "")
|
785 |
| - _, pipfile_part = req.as_pipfile().popitem() |
| 785 | + _, pipfile_part = as_pipfile(req).popitem() |
| 786 | + vcs_ref = "" |
| 787 | + for vcs in VCS_LIST: |
| 788 | + if pipfile_part.get(vcs): |
| 789 | + vcs_ref = pipfile_part[vcs].rsplit("@", 1)[-1] |
| 790 | + break |
786 | 791 | return (
|
787 |
| - vcs_type == req.vcs |
788 |
| - and commit_id == req.commit_hash |
789 |
| - and direct_url_metadata["url"] == pipfile_part[req.vcs] |
| 792 | + vcs_type == req.link.scheme |
| 793 | + and vcs_ref == requested_revision |
| 794 | + and direct_url_metadata["url"] == pipfile_part[req.link.scheme] |
790 | 795 | )
|
791 |
| - elif req.is_vcs or req.is_file_or_url: |
| 796 | + elif req.link and req.link.is_vcs: |
792 | 797 | return False
|
793 |
| - elif req.line_instance.specifiers is not None: |
794 |
| - return req.line_instance.specifiers.contains( |
| 798 | + elif req.specifier is not None: |
| 799 | + return SpecifierSet(str(req.specifier)).contains( |
795 | 800 | match.version, prereleases=True
|
796 | 801 | )
|
797 | 802 | return True
|
|
0 commit comments