Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 5 additions & 6 deletions pipenv/utils/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,16 @@ def convert_deps_to_pip(

def get_constraints_from_deps(deps):
"""Get contraints from Pipfile-formatted dependency"""
from pipenv.patched.pip._internal.req.req_install import (
check_invalid_constraint_type,
)
from pipenv.vendor.requirementslib.models.requirements import Requirement

def is_constraint(dep):
# https://pip.pypa.io/en/stable/user_guide/#constraints-files
# constraints must have a name, they cannot be editable, and they cannot specify extras.
return dep.name and not dep.editable and not dep.extras

constraints = []
for dep_name, dep in deps.items():
new_dep = Requirement.from_pipfile(dep_name, dep)
if is_constraint(new_dep):
problem = check_invalid_constraint_type(new_dep.as_ireq())
if not problem:
c = new_dep.as_line().strip()
constraints.append(c)
return constraints
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def test_convert_deps_to_pip_one_way(deps, expected):
({"requests": {"extras": ["security"]}}, []),
({"requests": {"extras": []}}, ["requests"]),
({"extras" : {}}, ["extras"]),
({"uvicorn[standard]" : {}}, [])
],
)
def test_get_constraints_from_deps(deps, expected):
Expand Down