Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop using requirementslib models #5793

Merged
merged 131 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
d31f56b
Prototyping moving away from requirementslib models
matteius Jul 16, 2023
f7a45af
Check pt progress fixing the edge cases
matteius Jul 16, 2023
4b86ae7
debugging test runner
matteius Jul 16, 2023
4ae3192
change back test runner run_command even though the other way was le…
matteius Jul 16, 2023
81f6f93
change back test runner run_command even though the other way was le…
matteius Jul 16, 2023
383ae83
Fix edge case of editable + vcs
matteius Jul 16, 2023
9e83b55
Fix edge case of file
matteius Jul 16, 2023
8cbc031
check pt progress
matteius Jul 17, 2023
772a5c6
check pt progress
matteius Jul 19, 2023
f8f9162
address additional test failures
matteius Jul 19, 2023
f4e6024
check pt
matteius Jul 22, 2023
5391d63
check pt
matteius Jul 22, 2023
64c9eb1
undo change to pip
matteius Jul 22, 2023
b33267d
Check pt
matteius Jul 22, 2023
85f01b4
Remove --skip-lock flag
matteius Jul 22, 2023
0df5add
merge
matteius Jul 22, 2023
743b535
Restore prior resolver default behavior but maintain direct code path…
matteius Jul 22, 2023
381a283
add news fragment
matteius Jul 22, 2023
0d30cb7
add comments
matteius Jul 22, 2023
4fae08e
merge the resolver update into this branch
matteius Jul 22, 2023
612c24a
Addressing edge cases
matteius Jul 22, 2023
b9096d5
test correction
matteius Jul 22, 2023
5e649f7
Check pt progress
matteius Jul 23, 2023
c82103a
additional progress -- fix the upgrade command
matteius Jul 23, 2023
5707858
corrected mocks
matteius Jul 23, 2023
b99296e
corrected mocks
matteius Jul 23, 2023
9cd4d24
fix regression in refactor
matteius Jul 23, 2023
a332eaa
Handle wheel files with extras
matteius Jul 23, 2023
6a1db61
Fix file edge cases
matteius Jul 23, 2023
38b3299
Fix edge case
matteius Jul 23, 2023
ecca28c
fix
matteius Jul 23, 2023
4c49785
solve more edge cases.
matteius Jul 23, 2023
f462778
Fix part of index restricted packages and handle case of file reqs th…
matteius Jul 24, 2023
57ac7a1
Adjustments
matteius Jul 24, 2023
d09f3ab
revert change to test and it passes
matteius Jul 24, 2023
7c379f8
Revise test since PEP-440 does not support wildcard versions but does…
matteius Jul 24, 2023
ce21489
fix test assumptions
matteius Jul 24, 2023
23f8540
remove unused arg
matteius Jul 27, 2023
191578a
resolve merge conflict with main
matteius Jul 27, 2023
bb29f34
Possible edge case with CI being on different drives.
matteius Jul 27, 2023
3955baf
fix double file prefix
matteius Jul 27, 2023
8d4e8a0
fix some more edge case of various OS paths
matteius Jul 27, 2023
7c0807e
remove unused parse code and maintain relative paths in expansive_ins…
matteius Jul 27, 2023
8cb9174
dont interpret relative files as absolute
matteius Jul 27, 2023
814a769
GPT is is either going to put me in a hole or maybe fix a test or two
matteius Jul 27, 2023
83f9fa2
fix path in one OS break it in another
matteius Jul 27, 2023
a70c510
Merge branch 'main' into skip-lock-removal
matteius Jul 27, 2023
b8d9531
Merge branch 'skip-lock-removal' into draft-no-reqlib
matteius Jul 27, 2023
a63f4b4
Add unearth
matteius Jul 27, 2023
ef4cf76
corrected imports from unearth and correct conditional statement outs…
matteius Jul 27, 2023
9579b85
use unearth to resolve some edge cases
matteius Jul 27, 2023
34f76a6
add pdm-backend to the vendoring depends for unary and fix nt edge case
matteius Jul 27, 2023
1a1bbf5
Handle top level markers and other check points.
matteius Jul 29, 2023
64fdab8
Merge branch 'main' into draft-no-reqlib
matteius Jul 29, 2023
9d063d9
Address --outdated usage and fix bug with upgrade command
matteius Jul 29, 2023
692df48
revert adjustments to path logic (even though CI will fail).
matteius Jul 29, 2023
3639d9f
fix ruff warning and vcs installs
matteius Jul 29, 2023
145c29f
solve the mystery behind the constraints noqa line
matteius Jul 29, 2023
22e6123
simplify and remove dead code
matteius Jul 29, 2023
3fd7f7f
Ensure the os_name marker is AND with the other markers.
matteius Jul 29, 2023
3c2d64e
Address the remaining markers tests
matteius Jul 29, 2023
065f517
Remove unearth
matteius Jul 29, 2023
d04df48
remove dead code
matteius Jul 29, 2023
28d8e6f
Reduce unused vars
matteius Jul 30, 2023
c888387
fix most remaining tests
matteius Jul 30, 2023
9ed349a
resolve linux path issues
matteius Jul 30, 2023
8a627fc
fix more edge cases of linux
matteius Jul 30, 2023
2b1151f
fix more edge cases of linux
matteius Jul 30, 2023
14bfb7e
add conditional for windows
matteius Jul 30, 2023
9b7538c
Fix edge case of linux
matteius Jul 30, 2023
d3f519a
Merge branch 'draft-no-reqlib' of github.com:pypa/pipenv into draft-n…
matteius Jul 30, 2023
4b2d793
Handle windows differently
matteius Jul 30, 2023
9ce0c4e
Attempt to make this code more portable
matteius Jul 30, 2023
fa468da
Solve edge case with py3.7 and py3.8
matteius Jul 30, 2023
f0a8bb7
Handle windows path issue edge case
matteius Jul 30, 2023
3903c26
sort this method out to work on < python 3.8
matteius Jul 31, 2023
b90c63b
Remove duplicated install logic and ensure sys.exit(1); fix remaining…
matteius Jul 31, 2023
892bf5c
Skip this test on non-windows.
matteius Jul 31, 2023
8e665ce
use normpath to try and avoid windows CI errors
matteius Jul 31, 2023
6cec82a
smarter recursive search, handle not searching network paths; error w…
matteius Jul 31, 2023
7c723ff
Try fixing remaining 3 windows test CI failures.
matteius Jul 31, 2023
72dc6fe
Safety patch for windows python 3.7
matteius Jul 31, 2023
6bd1a26
remove errant commit
matteius Jul 31, 2023
d0466f6
Fixes for 5626 pip line deprecation warnings.
matteius Jul 31, 2023
22650f3
Add back window py 3.8 safety patch.
matteius Jul 31, 2023
2cb0524
Safety patch for older Pipfile vcs entries
matteius Aug 5, 2023
d6459be
Merge branch 'main' into draft-no-reqlib
matteius Aug 5, 2023
2f19540
fix lint
matteius Aug 5, 2023
07518f4
Fix edge case of markers in lockfile. Update pipenv lockfile to inst…
matteius Aug 5, 2023
8bc3dcd
Add python 3.12 beta to test runner
matteius Aug 5, 2023
623a9c7
Add python 3.12 beta to test runner
matteius Aug 5, 2023
2a4e0f0
Don't import distutils
matteius Aug 5, 2023
5a9b017
Only patch rmtree on the affected python versions
matteius Aug 5, 2023
efe3398
Merge branch 'main' into draft-no-reqlib
matteius Aug 5, 2023
c2571d2
Move what we still need from requirementslib into the pipenv utils an…
matteius Aug 5, 2023
9aba3c3
satisfy ruff
matteius Aug 5, 2023
e32645c
Further remove requirementslib.
matteius Aug 5, 2023
77e3932
force upgrade of virtualenv for python 3.12
matteius Aug 5, 2023
fa67879
Try patching the python 3.12 CI because its pulling an older pip
matteius Aug 5, 2023
a168dc9
Try patching the python 3.12 CI because its pulling an older pip
matteius Aug 5, 2023
9ce1075
remove virtualenv-clone
matteius Aug 5, 2023
72778eb
relock
matteius Aug 6, 2023
fbf5f41
Use project python
matteius Aug 6, 2023
cd68c7f
Revert "Use project python"
matteius Aug 6, 2023
fd16758
Revert "relock"
matteius Aug 6, 2023
226210a
Fix edge case with locking dependencies that do not match the Markers…
matteius Aug 6, 2023
d7b544f
Restrict black version, iterate on edge case involving markers and pa…
matteius Aug 6, 2023
0ba29b0
Default old_lock_data if not passed
matteius Aug 6, 2023
c065138
Adds news fragment
matteius Aug 6, 2023
920a90a
Skip tests that in py3.12 that involve packages that do not work with…
matteius Aug 6, 2023
bc3ce7e
Skip test on windows 3.8
matteius Aug 6, 2023
d5c96a7
skipif requires reason string
matteius Aug 6, 2023
dd4e228
skipif requires reason string
matteius Aug 6, 2023
d0db077
py 3.8 test failure.
matteius Aug 6, 2023
83e9f65
Try to address to CI test issues
matteius Aug 7, 2023
4a2b9de
Remove test that was strictly a test of the tomlkit library
matteius Aug 7, 2023
3e52aed
Solve problem with re-lock after initial file install succeeds.
matteius Aug 7, 2023
6eb2793
Try to apply python 3.8 windows test patch differently
matteius Aug 7, 2023
6b54847
Iterate on vcs edge cases discovered
matteius Aug 8, 2023
0dec26e
Do not include extras in constraints
matteius Aug 9, 2023
b310811
Support locking the vcs dependencies hash in the lockfile. Use key …
matteius Aug 12, 2023
7c1027a
Update vcs specifiers documentation; infer name from specific pip lin…
matteius Aug 12, 2023
816a3a5
trim possible extras from name
matteius Aug 12, 2023
7aad5bb
trim possible extras from name
matteius Aug 12, 2023
1f0884f
Provide helpful text and error for recently remmoved commands
matteius Aug 16, 2023
e31a958
start addressing the ruff errors that showed up recently but stall ou…
matteius Aug 16, 2023
a2849c2
Merge branch 'main' into draft-no-reqlib
matteius Aug 16, 2023
6f14e48
fix the merge deletion issue
matteius Aug 16, 2023
327db6d
Set the right log levels and verbosity to show users the errors gener…
matteius Aug 16, 2023
8a62691
Fix the collection of all matching package hashes for non-pypi indexe…
matteius Aug 17, 2023
9b3aa48
Merge branch 'main' into draft-no-reqlib
matteius Aug 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"] # "3.12-dev" Windows CI hangs indefinitely
os: [MacOS, Ubuntu, Windows]

steps:
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ myst-parser = {extras = ["linkify"], version = "*"}
invoke = "==2.0.0"
exceptiongroup = "==1.1.0"
tomli = "*"
pyyaml = "==6.0.1"

[packages]
pytz = "*"
Expand Down
763 changes: 386 additions & 377 deletions Pipfile.lock

Large diffs are not rendered by default.

44 changes: 34 additions & 10 deletions docs/specifiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,54 @@ All sub-dependencies will get added to the `Pipfile.lock` as well. Sub-dependenc

## VCS Dependencies

VCS dependencies from git and other version control systems using URLs formatted according to the following rule:
VCS dependencies from git and other version control systems using URLs formatted using preferred pip line formats:

<vcs_type>+<scheme>://<location>/<user_or_organization>/<repository>@<branch_or_tag>#egg=<package_name>
<vcs_type>+<scheme>://<location>/<user_or_organization>/<repository>@<branch_or_tag>

The only optional section is the `@<branch_or_tag>` section. When using git over SSH, you may use the shorthand vcs and scheme alias `git+git@<location>:<user_or_organization>/<repository>@<branch_or_tag>#egg=<package_name>`. Note that this is translated to `git+ssh://git@<location>` when parsed.
Extras may be specified using the following format when issuing install command:

<package_name><possible_extras>@ <vcs_type>+<scheme>://<location>/<user_or_organization>/<repository>@<branch_or_tag>

Note: that the #egg fragments should only be used for legacy pip lines which are still required in editable requirements.

$ pipenv install -e git+https://github.com/requests/[email protected]#egg=requests

Note that it is **strongly recommended** that you install any version-controlled dependencies in editable mode, using `pipenv install -e`, in order to ensure that dependency resolution can be performed with an up-to-date copy of the repository each time it is performed, and that it includes all known dependencies.

Below is an example usage which installs the git repository located at `https://github.com/requests/requests.git` from tag `v2.20.1` as package name `requests`:

$ pipenv install -e git+https://github.com/requests/[email protected]#egg=requests
Creating a Pipfile for this project...
Installing -e git+https://github.com/requests/[email protected]#egg=requests...
[...snipped...]
Adding -e git+https://github.com/requests/[email protected]#egg=requests to Pipfile's [packages]...
[...]
Resolving -e git+https://github.com/requests/[email protected]#egg=requests...
Added requests to Pipfile's [packages] ...
Installation Succeeded
Pipfile.lock not found, creating...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
Success!
Locking [dev-packages] dependencies...
Updated Pipfile.lock (389441cc656bb774aaa28c7e53a35137aace7499ca01668765d528fa79f8acc8)!
Installing dependencies from Pipfile.lock (f8acc8)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

$ cat Pipfile
[packages]
requests = {git = "https://github.com/requests/requests.git", editable = true, ref = "v2.20.1"}
requests = {editable = true, ref = "v2.20.1", git = "git+https://github.com/requests/requests.git"}

$ cat Pipfile.lock
...
"requests": {
"editable": true,
"git": "git+https://github.com/requests/requests.git",
"markers": "python_version >= '3.7'",
"ref": "6cfbe1aedd56f8c2f9ff8b968efe65b22669795b"
},
...

Valid values for `<vcs_type>` include `git`, `bzr`, `svn`, and `hg`. Valid values for `<scheme>` include `http`, `https`, `ssh`, and `file`. In specific cases you also have access to other schemes: `svn` may be combined with `svn` as a scheme, and `bzr` can be combined with `sftp` and `lp`.

You can read more about pip's implementation of VCS support `here <https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support>`__. For more information about other options available when specifying VCS dependencies, please check the `Pipfile spec <https://github.com/pypa/pipfile>`_.
You can read more about pip's implementation of VCS support `here <https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support>`__.


## Specifying Package Categories
Expand Down
2 changes: 2 additions & 0 deletions news/5793.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Drop requirementslib for managing pip lines and InstallRequirements, bring remaining requirementslib functionality into pipenv.
Fixes numerous reports about extras installs with vcs and file installs; format pip lines correctly to not generate deprecation warnings.
20 changes: 18 additions & 2 deletions pipenv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@
import sys
import warnings

# This has to come before imports of pipenv
PIPENV_ROOT = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
PIP_ROOT = os.sep.join([PIPENV_ROOT, "patched", "pip"])
sys.path.insert(0, PIPENV_ROOT)
sys.path.insert(0, PIP_ROOT)

# Load patched pip instead of system pip
os.environ["PIP_DISABLE_PIP_VERSION_CHECK"] = "1"


def _ensure_modules():
# Can be removed when we drop pydantic
spec = importlib.util.spec_from_file_location(
"typing_extensions",
location=os.path.join(
Expand All @@ -14,6 +24,14 @@ def _ensure_modules():
typing_extensions = importlib.util.module_from_spec(spec)
sys.modules["typing_extensions"] = typing_extensions
spec.loader.exec_module(typing_extensions)
# Ensure when pip gets invoked it uses our patched version
spec = importlib.util.spec_from_file_location(
"pip",
location=os.path.join(os.path.dirname(__file__), "patched", "pip", "__init__.py"),
)
pip = importlib.util.module_from_spec(spec)
sys.modules["pip"] = pip
spec.loader.exec_module(pip)


_ensure_modules()
Expand All @@ -26,8 +44,6 @@ def _ensure_modules():
warnings.filterwarnings("ignore", category=ResourceWarning)
warnings.filterwarnings("ignore", category=UserWarning)

# Load patched pip instead of system pip
os.environ["PIP_DISABLE_PIP_VERSION_CHECK"] = "1"

if os.name == "nt":
from pipenv.vendor import colorama
Expand Down
11 changes: 5 additions & 6 deletions pipenv/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def install(state, **kwargs):
requirementstxt=state.installstate.requirementstxt,
pre=state.installstate.pre,
deploy=state.installstate.deploy,
index_url=state.index,
index=state.index,
packages=state.installstate.packages,
editable_packages=state.installstate.editables,
site_packages=state.site_packages,
Expand Down Expand Up @@ -610,7 +610,7 @@ def run_open(state, module, *args, **kwargs):
[
state.project._which("python"),
"-c",
"import {0}; print({0}.__file__)".format(module),
f"import {module}; print({module}.__file__)",
]
)
if c.returncode:
Expand Down Expand Up @@ -693,11 +693,10 @@ def scripts(state):
scripts = state.project.parsed_pipfile.get("scripts", {})
first_column_width = max(len(word) for word in ["Command"] + list(scripts))
second_column_width = max(len(word) for word in ["Script"] + list(scripts.values()))
lines = ["{0:<{width}} Script".format("Command", width=first_column_width)]
lines.append("{} {}".format("-" * first_column_width, "-" * second_column_width))
lines = [f"{command:<{first_column_width}} Script" for command in ["Command"]]
lines.append(f"{'-' * first_column_width} {'-' * second_column_width}")
lines.extend(
"{0:<{width}} {1}".format(name, script, width=first_column_width)
for name, script in scripts.items()
f"{name:<{first_column_width}} {script}" for name, script in scripts.items()
)
console.print("\n".join(line for line in lines))

Expand Down
82 changes: 82 additions & 0 deletions pipenv/cli/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re

from pipenv.project import Project
from pipenv.utils import err
from pipenv.utils.internet import is_valid_url
from pipenv.vendor.click import (
BadArgumentUsage,
Expand Down Expand Up @@ -483,6 +484,83 @@ def validate_pypi_mirror(ctx, param, value):
return value


# OLD REMOVED COMMANDS THAT WE STILL DISPLAY HELP TEXT FOR #
def skip_lock_option(f):
def callback(ctx, param, value):
if value:
err.print(
"The flag --skip-lock has been functionally removed. "
"Without running the lock resolver it is not possible to manage multiple package indexes. "
"Additionally it bypassed the build consistency guarantees provided by maintaining a lock file.",
style="yellow bold",
)
raise ValueError("The flag --skip-lock flag has been removed.")
return value

return option(
"--skip-lock",
is_flag=True,
default=False,
expose_value=False,
envvar="PIPENV_SKIP_LOCK",
callback=callback,
type=click_types.BOOL,
show_envvar=True,
hidden=True, # This hides the option from the help text.
)(f)


def keep_outdated_option(f):
def callback(ctx, param, value):
state = ctx.ensure_object(State)
state.installstate.keep_outdated = value
if value:
err.print(
"The flag --keep-outdated has been removed. "
"The flag did not respect package resolver results and lead to inconsistent lock files. "
"Consider using the `pipenv upgrade` command to selectively upgrade packages.",
style="yellow bold",
)
raise ValueError("The flag --keep-outdated flag has been removed.")
return value

return option(
"--keep-outdated",
is_flag=True,
default=False,
expose_value=False,
callback=callback,
type=click_types.BOOL,
show_envvar=True,
hidden=True, # This hides the option from the help text.
)(f)


def selective_upgrade_option(f):
def callback(ctx, param, value):
state = ctx.ensure_object(State)
state.installstate.selective_upgrade = value
if value:
err.print(
"The flag --selective-upgrade has been removed. "
"The flag was buggy and lead to inconsistent lock files. "
"Consider using the `pipenv upgrade` command to selectively upgrade packages.",
style="yellow bold",
)
raise ValueError("The flag --selective-upgrade flag has been removed.")
return value

return option(
"--selective-upgrade",
is_flag=True,
default=False,
type=click_types.BOOL,
help="Update specified packages.",
callback=callback,
expose_value=False,
)(f)


def common_options(f):
f = pypi_mirror_option(f)
f = verbose_option(f)
Expand All @@ -496,6 +574,7 @@ def install_base_options(f):
f = common_options(f)
f = pre_option(f)
f = extra_pip_args(f)
f = keep_outdated_option(f) # Removed, but still displayed in help text.
return f


Expand All @@ -505,6 +584,7 @@ def uninstall_options(f):
f = uninstall_dev_option(f)
f = editable_option(f)
f = package_arg(f)
f = skip_lock_option(f) # Removed, but still displayed in help text.
return f


Expand All @@ -530,6 +610,8 @@ def install_options(f):
f = ignore_pipfile_option(f)
f = editable_option(f)
f = package_arg(f)
f = skip_lock_option(f) # Removed, but still display help text.
f = selective_upgrade_option(f) # Removed, but still display help text.
return f


Expand Down
49 changes: 27 additions & 22 deletions pipenv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,23 @@
from pathlib import Path
from sysconfig import get_paths, get_python_version, get_scheme_names
from urllib.parse import urlparse
from urllib.request import url2pathname

import pipenv
from pipenv.patched.pip._internal.commands.install import InstallCommand
from pipenv.patched.pip._internal.index.package_finder import PackageFinder
from pipenv.patched.pip._internal.req.req_install import InstallRequirement
from pipenv.patched.pip._vendor import pkg_resources
from pipenv.patched.pip._vendor.packaging.specifiers import SpecifierSet
from pipenv.patched.pip._vendor.packaging.utils import canonicalize_name
from pipenv.utils import console
from pipenv.utils.constants import VCS_LIST
from pipenv.utils.dependencies import as_pipfile
from pipenv.utils.fileutils import normalize_path, temp_path
from pipenv.utils.funktools import chunked, unnest
from pipenv.utils.indexes import prepare_pip_source_args
from pipenv.utils.processes import subprocess_run
from pipenv.utils.shell import make_posix
from pipenv.utils.shell import make_posix, temp_environ
from pipenv.vendor.pythonfinder.utils import is_in_path
from pipenv.vendor.requirementslib.fileutils import normalize_path, temp_path
from pipenv.vendor.requirementslib.utils import temp_environ

try:
# this is only in Python3.8 and later
Expand Down Expand Up @@ -200,11 +202,6 @@ def base_paths(self) -> dict[str, str]:
.. note:: The implementation of this is borrowed from a combination of pip and
virtualenv and is likely to change at some point in the future.

>>> from pipenv.core import project
>>> from pipenv.environment import Environment
>>> env = Environment(prefix=project.virtualenv_location, is_venv=True, sources=project.sources)
>>> import pprint
>>> pprint.pprint(env.base_paths)
{'PATH': '/home/hawk/.virtualenvs/pipenv-MfOPs1lW/bin::/bin:/usr/bin',
'PYTHONPATH': '/home/hawk/.virtualenvs/pipenv-MfOPs1lW/lib/python3.7/site-packages',
'data': '/home/hawk/.virtualenvs/pipenv-MfOPs1lW',
Expand Down Expand Up @@ -760,38 +757,46 @@ def is_installed(self, pkgname):

return any(d for d in self.get_distributions() if d.project_name == pkgname)

def is_satisfied(self, req):
def is_satisfied(self, req: InstallRequirement):
match = next(
iter(
d
for d in self.get_distributions()
if canonicalize_name(d.project_name) == req.normalized_name
if req.name
and canonicalize_name(d.project_name) == canonicalize_name(req.name)
),
None,
)
if match is not None:
if req.editable and req.line_instance.is_local and self.find_egg(match):
requested_path = req.line_instance.path
if req.editable and req.link and req.link.is_file:
requested_path = req.link.file_path
if os.path.exists(requested_path):
local_path = requested_path
else:
parsed_url = urlparse(requested_path)
local_path = url2pathname(parsed_url.path)
local_path = parsed_url.path
return requested_path and os.path.samefile(local_path, match.location)
elif match.has_metadata("direct_url.json"):
direct_url_metadata = json.loads(match.get_metadata("direct_url.json"))
commit_id = direct_url_metadata.get("vcs_info", {}).get("commit_id", "")
requested_revision = direct_url_metadata.get("vcs_info", {}).get(
"requested_revision", ""
)
vcs_type = direct_url_metadata.get("vcs_info", {}).get("vcs", "")
_, pipfile_part = req.as_pipfile().popitem()
_, pipfile_part = as_pipfile(req).popitem()
vcs_ref = ""
for vcs in VCS_LIST:
if pipfile_part.get(vcs):
vcs_ref = pipfile_part[vcs].rsplit("@", 1)[-1]
break
return (
vcs_type == req.vcs
and commit_id == req.commit_hash
and direct_url_metadata["url"] == pipfile_part[req.vcs]
vcs_type == req.link.scheme
and vcs_ref == requested_revision
and direct_url_metadata["url"] == pipfile_part[req.link.scheme]
)
elif req.is_vcs or req.is_file_or_url:
elif req.link and req.link.is_vcs:
return False
elif req.line_instance.specifiers is not None:
return req.line_instance.specifiers.contains(
elif req.specifier is not None:
return SpecifierSet(str(req.specifier)).contains(
match.version, prereleases=True
)
return True
Expand Down
2 changes: 1 addition & 1 deletion pipenv/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import sys

from pipenv.patched.pip._vendor.platformdirs import user_cache_dir
from pipenv.utils.fileutils import normalize_drive
from pipenv.utils.shell import env_to_bool, is_env_truthy, isatty
from pipenv.vendor.requirementslib.fileutils import normalize_drive

# HACK: avoid resolver.py uses the wrong byte code files.
# I hope I can remove this one day.
Expand Down
2 changes: 1 addition & 1 deletion pipenv/pep508checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def format_full_version(info):
version = "{0.major}.{0.minor}.{0.micro}".format(info)
version = f"{info.major}.{info.minor}.{info.micro}"
kind = info.releaselevel
if kind != "final":
version += kind[0] + str(info.serial)
Expand Down
Loading