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

New resolver constraint markers #8727

Merged
merged 2 commits into from
Aug 7, 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
2 changes: 2 additions & 0 deletions news/8724.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
2020 Resolver: Correctly handle marker evaluation in constraints and exclude
them if their markers do not match the current environment.
3 changes: 2 additions & 1 deletion src/pip/_internal/resolution/resolvelib/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def resolve(self, root_reqs, check_supported_wheels):
problem = check_invalid_constraint_type(req)
if problem:
raise InstallationError(problem)

if not req.match_markers():
continue
name = canonicalize_name(req.name)
if name in constraints:
constraints[name] = constraints[name] & req.specifier
Expand Down
25 changes: 25 additions & 0 deletions tests/functional/test_new_resolver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import sys
import textwrap

import pytest
from pip._vendor.packaging.utils import canonicalize_name
Expand Down Expand Up @@ -729,6 +730,30 @@ def test_new_resolver_constraint_on_path(script):
assert msg in result.stderr, str(result)


def test_new_resolver_constraint_only_marker_match(script):
create_basic_wheel_for_package(script, "pkg", "1.0")
create_basic_wheel_for_package(script, "pkg", "2.0")
create_basic_wheel_for_package(script, "pkg", "3.0")

constrants_content = textwrap.dedent(
"""
pkg==1.0; python_version == "{ver[0]}.{ver[1]}" # Always satisfies.
pkg==2.0; python_version < "0" # Never satisfies.
"""
).format(ver=sys.version_info)
constraints_txt = script.scratch_path / "constraints.txt"
constraints_txt.write_text(constrants_content)

script.pip(
"install", "--use-feature=2020-resolver",
"--no-cache-dir", "--no-index",
"-c", constraints_txt,
"--find-links", script.scratch_path,
"pkg",
)
assert_installed(script, pkg="1.0")


def test_new_resolver_upgrade_needs_option(script):
# Install pkg 1.0.0
create_basic_wheel_for_package(script, "pkg", "1.0.0")
Expand Down