mirror of https://github.com/pypa/pip
Merge pull request #8727 from uranusjr/new-resolver-constraint-markers
This commit is contained in:
parent
516c7431bc
commit
0ebe453140
|
@ -0,0 +1,2 @@
|
|||
2020 Resolver: Correctly handle marker evaluation in constraints and exclude
|
||||
them if their markers do not match the current environment.
|
|
@ -90,7 +90,8 @@ class Resolver(BaseResolver):
|
|||
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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
from pip._vendor.packaging.utils import canonicalize_name
|
||||
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue