From 0f04e5708c320fd3dee93d41f32644375e369dce Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Wed, 13 Dec 2017 01:24:57 -0500 Subject: [PATCH] Fix backup resolver - Backup resolver was broken when hash resolution was split out into two functions - This PR returns the resolver to the caller function - This is for edge cases where the PyPI json API and the pip resolver don't return the same authoritative result for a package lookup (a name can be resolved in one source but not the other) - Added test to prevent future regression - Fixes #1195 --- pipenv/utils.py | 8 ++++---- tests/test_pipenv.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/pipenv/utils.py b/pipenv/utils.py index f433287b..adf4df4f 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -523,7 +523,8 @@ def actually_resolve_reps(deps, index_lookup, markers_lookup, project, sources, raise RuntimeError - return resolved_tree + return resolved_tree, resolver + def resolve_deps(deps, which, which_pip, project, sources=None, verbose=False, python=False, clear=False, pre=False): """Given a list of dependencies, return a resolved list of dependencies, @@ -542,7 +543,7 @@ def resolve_deps(deps, which, which_pip, project, sources=None, verbose=False, p with HackedPythonVersion(python_version=python, python_path=python_path): try: - resolved_tree = actually_resolve_reps(deps, index_lookup, markers_lookup, project, sources, verbose, clear, pre) + resolved_tree, resolver = actually_resolve_reps(deps, index_lookup, markers_lookup, project, sources, verbose, clear, pre) except RuntimeError: # Don't exit here, like usual. resolved_tree = None @@ -554,12 +555,11 @@ def resolve_deps(deps, which, which_pip, project, sources=None, verbose=False, p try: # Attempt to resolve again, with different Python version information, # particularly for particularly particular packages. - resolved_tree = actually_resolve_reps(deps, index_lookup, markers_lookup, project, sources, verbose, clear, pre) + resolved_tree, resolver = actually_resolve_reps(deps, index_lookup, markers_lookup, project, sources, verbose, clear, pre) except RuntimeError: sys.exit(1) - for result in resolved_tree: if not result.editable: name = pep423_name(result.name) diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 78692429..f472b97c 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -498,6 +498,23 @@ tpfd = "*" c = p.pipenv('run python -c "import requests; import idna; import certifi; import records; import tpfd; import parse;"') assert c.return_code == 0 + @pytest.mark.install + @pytest.mark.resolver + @pytest.mark.backup_resolver + def test_backup_resolver(self): + with PipenvInstance() as p: + with open(p.pipfile_path, 'w') as f: + contents = """ +[packages] +"ibm-db-sa-py3" = "==0.3.1-1" + """.strip() + f.write(contents) + + c = p.pipenv('install') + assert c.return_code == 0 + assert 'ibm-db-sa-py3' in p.lockfile['default'] + + @pytest.mark.sequential @pytest.mark.install @pytest.mark.update