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

Fix Python constraint propagation for package to dependency conversion #84

Merged
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
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