Commit bdd7909c by Sébastien Eustace

Fix Python-Requires being invalid for single Python versions

parent 857052a0
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
- Fixed possible errors when resolving dependencies for specific packages. - Fixed possible errors when resolving dependencies for specific packages.
- Fixed handling of Python versions compatibility. - Fixed handling of Python versions compatibility.
- Fixed the dependency resolver picking up unnecessary dependencies due to not using the `python_full_version` marker. - Fixed the dependency resolver picking up unnecessary dependencies due to not using the `python_full_version` marker.
- Fixed the `Python-Requires` metadata being invalid for single Python versions.
## [0.12.4] - 2018-10-21 ## [0.12.4] - 2018-10-21
......
...@@ -21,7 +21,10 @@ def format_python_constraint(constraint): ...@@ -21,7 +21,10 @@ def format_python_constraint(constraint):
This helper will help in transforming This helper will help in transforming
disjunctive constraint into proper constraint. disjunctive constraint into proper constraint.
""" """
if isinstance(constraint, Version) and constraint.precision < 3: if isinstance(constraint, Version):
if constraint.precision >= 3:
return "=={}".format(str(constraint))
# Transform 3.6 or 3 # Transform 3.6 or 3
if constraint.precision == 2: if constraint.precision == 2:
# 3.6 # 3.6
......
[tool.poetry]
name = "single-python"
version = "0.1"
description = "Some description."
authors = [
"Sébastien Eustace <sebastien@eustace.io>"
]
license = "MIT"
readme = "README.rst"
homepage = "https://poetry.eustace.io/"
[tool.poetry.dependencies]
python = "2.7.15"
...@@ -471,7 +471,7 @@ def test_default_with_excluded_data(mocker): ...@@ -471,7 +471,7 @@ def test_default_with_excluded_data(mocker):
assert "my-package-1.2.3/PKG-INFO" in names assert "my-package-1.2.3/PKG-INFO" in names
def test_proper_python_requires_if_single_version_specified(): def test_proper_python_requires_if_two_digits_precision_version_specified():
poetry = Poetry.create(project("simple_version")) poetry = Poetry.create(project("simple_version"))
builder = SdistBuilder(poetry, NullEnv(), NullIO()) builder = SdistBuilder(poetry, NullEnv(), NullIO())
...@@ -480,3 +480,14 @@ def test_proper_python_requires_if_single_version_specified(): ...@@ -480,3 +480,14 @@ def test_proper_python_requires_if_single_version_specified():
parsed = p.parsestr(to_str(pkg_info)) parsed = p.parsestr(to_str(pkg_info))
assert parsed["Requires-Python"] == ">=3.6,<3.7" assert parsed["Requires-Python"] == ">=3.6,<3.7"
def test_proper_python_requires_if_three_digits_precision_version_specified():
poetry = Poetry.create(project("single_python"))
builder = SdistBuilder(poetry, NullEnv(), NullIO())
pkg_info = builder.build_pkg_info()
p = Parser()
parsed = p.parsestr(to_str(pkg_info))
assert parsed["Requires-Python"] == "==2.7.15"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment