diff --git a/poetry/core/packages/package.py b/poetry/core/packages/package.py index cae2e20c9..aac39afa7 100755 --- a/poetry/core/packages/package.py +++ b/poetry/core/packages/package.py @@ -357,6 +357,9 @@ def to_dependency(self): if not self.marker.is_any(): dep.marker = self.marker + if not self.python_constraint.is_any(): + dep.python_versions = self.python_versions + if self._source_type not in ["directory", "file", "url", "git"]: return dep diff --git a/tests/packages/test_package.py b/tests/packages/test_package.py index 10f23d581..40b980795 100644 --- a/tests/packages/test_package.py +++ b/tests/packages/test_package.py @@ -202,6 +202,16 @@ def test_to_dependency(): assert package.version == dep.constraint +def test_to_dependency_with_python_constraint(): + package = Package("foo", "1.2.3") + package.python_versions = ">=3.6" + dep = package.to_dependency() + + assert "foo" == dep.name + assert package.version == dep.constraint + assert ">=3.6" == dep.python_versions + + def test_to_dependency_with_features(): package = Package("foo", "1.2.3", features=["baz", "bar"]) dep = package.to_dependency()