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

repos: ensure wheel python constraints are merged #5616

Merged
merged 1 commit into from
May 16, 2022
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
9 changes: 9 additions & 0 deletions src/poetry/repositories/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from poetry.core.packages.dependency import Dependency
from poetry.core.packages.utils.link import Link
from poetry.core.semver.helpers import parse_constraint
from poetry.core.version.markers import parse_marker

from poetry.repositories.cached import CachedRepository
Expand Down Expand Up @@ -148,6 +149,14 @@ def _get_info_from_urls(self, urls: dict[str, list[str]]) -> PackageInfo:
info = self._get_info_from_wheel(universal_python2_wheel)

py3_info = self._get_info_from_wheel(universal_python3_wheel)

if info.requires_python or py3_info.requires_python:
info.requires_python = str(
parse_constraint(info.requires_python or "^2.7").union(
parse_constraint(py3_info.requires_python or "^3")
)
)

if py3_info.requires_dist:
if not info.requires_dist:
info.requires_dist = py3_info.requires_dist
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Links for poetry-test-py2-py3-metadata-merge</title>
</head>
<body>
<h1>Links for ipython</h1>
<a href="https://files.pythonhosted.org/packages/52/19/poetry_test_py2_py3_metadata_merge-0.1.0-py2-none-any.whl">poetry_test_py2_py3_metadata_merge-0.1.0-py2-none-any.whl</a><br/>
<a href="https://files.pythonhosted.org/packages/c7/b6/poetry_test_py2_py3_metadata_merge-0.1.0-py3-none-any.whl">poetry_test_py2_py3_metadata_merge-0.1.0-py3-none-any.whl</a><br/>
</body>
</html>
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/repositories/test_legacy_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ def test_get_package_from_both_py2_and_py3_specific_wheels():
assert str(required[5].marker) == 'sys_platform != "win32"'


def test_get_package_from_both_py2_and_py3_specific_wheels_python_constraint():
repo = MockRepository()

package = repo.package("poetry-test-py2-py3-metadata-merge", "0.1.0")

assert package.name == "poetry-test-py2-py3-metadata-merge"
assert package.version.text == "0.1.0"
assert package.python_versions == ">=2.7,<2.8 || >=3.7,<4.0"


def test_get_package_with_dist_and_universal_py3_wheel():
repo = MockRepository()

Expand Down