diff --git a/poetry/core/masonry/api.py b/poetry/core/masonry/api.py index 0c53b2b50..c14a6d5cf 100644 --- a/poetry/core/masonry/api.py +++ b/poetry/core/masonry/api.py @@ -85,7 +85,7 @@ def build_editable( config_settings: Optional[Dict[str, Any]] = None, metadata_directory: Optional[str] = None, ) -> str: - poetry = Factory().create_poetry(Path(".").resolve(), with_dev=False) + poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False) return WheelBuilder.make_in(poetry, Path(wheel_directory), editable=True) diff --git a/poetry/core/packages/constraints/base_constraint.py b/poetry/core/packages/constraints/base_constraint.py index a428b2e4b..5d6a5c8ba 100644 --- a/poetry/core/packages/constraints/base_constraint.py +++ b/poetry/core/packages/constraints/base_constraint.py @@ -6,6 +6,9 @@ class BaseConstraint(object): + def allows(self, other: "ConstraintTypes") -> bool: + raise NotImplementedError() + def allows_all(self, other: "ConstraintTypes") -> bool: raise NotImplementedError() diff --git a/poetry/core/packages/constraints/empty_constraint.py b/poetry/core/packages/constraints/empty_constraint.py index d8a789ded..b6be2f586 100644 --- a/poetry/core/packages/constraints/empty_constraint.py +++ b/poetry/core/packages/constraints/empty_constraint.py @@ -17,6 +17,9 @@ def matches(self, _: "ConstraintTypes") -> bool: def is_empty(self) -> bool: return True + def allows(self, other: "ConstraintTypes") -> bool: + return False + def allows_all(self, other: "ConstraintTypes") -> bool: return True diff --git a/poetry/core/version/markers.py b/poetry/core/version/markers.py index ffea9beb1..29ee74fac 100644 --- a/poetry/core/version/markers.py +++ b/poetry/core/version/markers.py @@ -224,7 +224,17 @@ def __init__(self, name: str, constraint: Union[str, "VersionTypes"]) -> None: else: self._constraint = self._parser(self._constraint_string) else: - self._constraint = self._parser(self._constraint_string) + # if we have a in/not in operator we split the constraint + # into a union/multi-constraint of single constraint + constraint_string = self._constraint_string + if self._operator in {"in", "not in"}: + op, glue = ("==", " || ") if self._operator == "in" else ("!=", ", ") + values = re.split("[ ,]+", self._value) + constraint_string = glue.join( + ("{} {}".format(op, value) for value in values) + ) + + self._constraint = self._parser(constraint_string) @property def name(self) -> str: diff --git a/tests/version/test_markers.py b/tests/version/test_markers.py index f31bd4442..389d25c13 100644 --- a/tests/version/test_markers.py +++ b/tests/version/test_markers.py @@ -36,6 +36,34 @@ def test_single_marker(): assert m.constraint_string == "not in 2.7, 3.0, 3.1" assert str(m.constraint) == "<2.7.0 || >=2.8.0,<3.0.0 || >=3.2.0" + m = parse_marker( + "platform_machine in 'x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32'" + ) + + assert isinstance(m, SingleMarker) + assert m.name == "platform_machine" + assert ( + m.constraint_string + == "in x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32" + ) + assert str(m.constraint) == ( + "x86_64 || X86_64 || aarch64 || AARCH64 || ppc64le || PPC64LE || amd64 || AMD64 || win32 || WIN32" + ) + + m = parse_marker( + "platform_machine not in 'x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32'" + ) + + assert isinstance(m, SingleMarker) + assert m.name == "platform_machine" + assert ( + m.constraint_string + == "not in x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32" + ) + assert str(m.constraint) == ( + "!=x86_64, !=X86_64, !=aarch64, !=AARCH64, !=ppc64le, !=PPC64LE, !=amd64, !=AMD64, !=win32, !=WIN32" + ) + def test_single_marker_intersect(): m = parse_marker('sys_platform == "darwin"') @@ -476,6 +504,26 @@ def test_multi_marker_removes_duplicates(): {"python_version": "2.7"}, False, ), + ( + "platform_machine in 'x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32'", + {"platform_machine": "foo"}, + False, + ), + ( + "platform_machine in 'x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32'", + {"platform_machine": "x86_64"}, + True, + ), + ( + "platform_machine not in 'x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32'", + {"platform_machine": "foo"}, + True, + ), + ( + "platform_machine not in 'x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32'", + {"platform_machine": "x86_64"}, + False, + ), ], ) def test_validate(marker_string, environment, expected):