Skip to content

Commit

Permalink
Fix Python constraint propagation for package to dependency conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater authored and abn committed Sep 23, 2020
1 parent a056c46 commit 3acc3ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions poetry/core/packages/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions tests/packages/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 3acc3ab

Please sign in to comment.