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

Bugfix: resolver takes the wrong section to validate constraints #4528

Merged
merged 1 commit into from
Nov 10, 2020
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
1 change: 1 addition & 0 deletions news/4527.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug that the resolver takes wrong section to validate constraints.
13 changes: 7 additions & 6 deletions pipenv/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ def parse_packages(packages, pre, clear, system, requirements_dir=None):
print(json.dumps([]))


def resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages):
def resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev):
from pipenv.utils import create_mirror_source, resolve_deps, replace_pypi_sources
pypi_mirror_source = (
create_mirror_source(os.environ["PIPENV_PYPI_MIRROR"])
Expand Down Expand Up @@ -709,9 +709,9 @@ def resolve(packages, pre, project, sources, clear, system, requirements_dir=Non
requirements_dir=requirements_dir,
)
if keep_outdated:
results = clean_outdated(results, resolver, project)
results = clean_outdated(results, resolver, project, dev)
else:
results = clean_results(results, resolver, project)
results = clean_results(results, resolver, project, dev)
if write:
with open(write, "w") as fh:
if not results:
Expand All @@ -726,7 +726,7 @@ def resolve(packages, pre, project, sources, clear, system, requirements_dir=Non
print(json.dumps([]))


def _main(pre, clear, verbose, system, write, requirements_dir, packages, parse_only=False):
def _main(pre, clear, verbose, system, write, requirements_dir, packages, parse_only=False, dev=False):
os.environ["PIPENV_REQUESTED_PYTHON_VERSION"] = ".".join([str(s) for s in sys.version_info[:3]])
os.environ["PIP_PYTHON_PATH"] = str(sys.executable)
if parse_only:
Expand All @@ -738,7 +738,7 @@ def _main(pre, clear, verbose, system, write, requirements_dir, packages, parse_
requirements_dir=requirements_dir,
)
else:
resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)
resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)


def main():
Expand All @@ -756,7 +756,8 @@ def main():
os.environ["PYTHONUNBUFFERED"] = str("1")
parsed = handle_parsed_args(parsed)
_main(parsed.pre, parsed.clear, parsed.verbose, parsed.system, parsed.write,
parsed.requirements_dir, parsed.packages, parse_only=parsed.parse_only)
parsed.requirements_dir, parsed.packages, parse_only=parsed.parse_only,
dev=parsed.dev)


if __name__ == "__main__":
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,3 +775,15 @@ def test_lock_package_with_wildcard_version(PipenvInstance):
assert "six" in p.lockfile["default"]
assert "version" in p.lockfile["default"]["six"]
assert p.lockfile["default"]["six"]["version"] == "==1.11.0"


@pytest.mark.lock
@pytest.mark.install
def test_default_lock_overwrite_dev_lock(PipenvInstance):
with PipenvInstance(chdir=True) as p:
c = p.pipenv("install 'click==6.7'")
assert c.ok
c = p.pipenv("install -d flask")
assert c.ok
assert p.lockfile["default"]["click"]["version"] == "==6.7"
assert p.lockfile["develop"]["click"]["version"] == "==6.7"