From f49a1dd8735325639ecdc75a18de8e82feee3d76 Mon Sep 17 00:00:00 2001 From: frostming Date: Fri, 28 Aug 2020 14:21:52 +0800 Subject: [PATCH] Fix constraint validation --- news/4386.bugfix.rst | 1 + pipenv/cli/options.py | 1 + pipenv/core.py | 8 ++++---- pipenv/resolver.py | 12 +++++++----- 4 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 news/4386.bugfix.rst diff --git a/news/4386.bugfix.rst b/news/4386.bugfix.rst new file mode 100644 index 00000000..ff633fb9 --- /dev/null +++ b/news/4386.bugfix.rst @@ -0,0 +1 @@ +Fix a bug that non-wheel file requirements can be resolved successfully. diff --git a/pipenv/cli/options.py b/pipenv/cli/options.py index b96a03f6..35af39ca 100644 --- a/pipenv/cli/options.py +++ b/pipenv/cli/options.py @@ -440,6 +440,7 @@ def lock_options(f): f = install_base_options(f) f = lock_dev_option(f) f = emit_requirements_flag(f) + f = emit_requirements_header_flag(f) f = dev_only_flag(f) return f diff --git a/pipenv/core.py b/pipenv/core.py index 6e8639ee..a59ef9df 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -841,15 +841,15 @@ def do_install_dependencies( dev = dev or dev_only deps_list = list(lockfile.get_requirements(dev=dev, only=dev_only)) if emit_requirements: - index_args = prepare_pip_source_args(get_source_list(pypi_mirror=pypi_mirror, project=project)) + index_args = prepare_pip_source_args( + get_source_list(pypi_mirror=pypi_mirror, project=project) + ) index_args = " ".join(index_args).replace(" -", "\n-") deps = [ req.as_line(sources=False, include_hashes=False) for req in deps_list ] click.echo(index_args) - click.echo( - "\n".join(sorted(deps)) - ) + click.echo("\n".join(sorted(deps))) sys.exit(0) if concurrent: nprocs = PIPENV_MAX_SUBPROCESS diff --git a/pipenv/resolver.py b/pipenv/resolver.py index 733b28d5..697109d4 100644 --- a/pipenv/resolver.py +++ b/pipenv/resolver.py @@ -562,13 +562,15 @@ class Entry(object): :return: True if the constraints are satisfied by the resolution provided :raises: :exc:`pipenv.exceptions.DependencyConflict` if the constraints dont exist """ + from pipenv.exceptions import DependencyConflict + from pipenv.environments import is_verbose + constraints = self.get_constraints() + old_version = self.strip_version(self.old_specifiers) for constraint in constraints: - try: - constraint.check_if_exists(False) - except Exception: - from pipenv.exceptions import DependencyConflict - from pipenv.environments import is_verbose + if not constraint.req: + continue + if not constraint.req.specifier.contains(str(old_version), prereleases=True): if is_verbose(): print("Tried constraint: {0!r}".format(constraint), file=sys.stderr) msg = (