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

Wrong metadata generated for old Python versions #3791

Open
2 of 3 tasks
tueda opened this issue Mar 16, 2021 · 3 comments
Open
2 of 3 tasks

Wrong metadata generated for old Python versions #3791

tueda opened this issue Mar 16, 2021 · 3 comments
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@tueda
Copy link

tueda commented Mar 16, 2021

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

Although Poetry doesn't run with old Python versions like 2.6, as far as I understand, developing packages supporting Python 2.6 should be still supported by Poetry (running with a newer Python).

But it seems that source distributions and wheels generated by poetry build have wrong metadata for old Python versions.
Example:

[tool.poetry.dependencies]
python = "~2.6 || ~2.7 || ^3.2"

Poetry generates:

Metadata-Version: 2.1
Name: example
Version: 0.1.0
Summary: 
Author: Your Name
Author-email: you@example.com
Requires-Python: >=2.7, !=3.0.*, !=3.1.*
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9

So, 2.6 is omitted in Requires-Python (same for python_requires in setup.py). 3.2 and 3.3 are also missing in the classifiers.

@tueda tueda added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Mar 16, 2021
tueda added a commit to tueda/formset that referenced this issue Mar 25, 2021
NOTE: python-poetry/poetry#3791 would be
a blocking issue when we publish this package (or we need to decide to
drop old Python version supports, or we have to give up Poetry and write
`setup.py` by ourselves).
@finswimmer
Copy link
Member

The problem is that we hardcode the available python versions here: https://github.com/python-poetry/poetry-core/blob/8d5e5c5d070940736ab72c5dec09cd7deab07cf3/poetry/core/packages/package.py#L31

We have another place where we do this: https://github.com/python-poetry/poetry-core/blob/8d5e5c5d070940736ab72c5dec09cd7deab07cf3/poetry/core/version/helpers.py#L12

I'm not sure if there is a better way to implement it 🤔

@finswimmer finswimmer added the area/build-system Related to PEP 517 packaging (see poetry-core) label Dec 30, 2021
@jleclanche
Copy link
Contributor

Im not sure this is the same issue, but we're seeing similar issues in dj-stripe.

dj-stripe/dj-stripe#1647

the python 3.7 classifier is not generated with python = "^3.7.12".

@dimbleby
Copy link
Contributor

@jleclanche it's easy to fix poetry to behave the way you expect, if you can find some sort of reference to confirm that the intended meaning of (say) the "Python :: 3.7" classifier is to cover any python 3.7.x then I expect a merge request would be accepted

--- a/src/poetry/core/packages/package.py
+++ b/src/poetry/core/packages/package.py
@@ -297,10 +297,7 @@ class Package(PackageSpecification):
         for version in sorted(
             self.AVAILABLE_PYTHONS, key=lambda x: tuple(map(int, x.split(".")))
         ):
-            if len(version) == 1:
-                constraint = parse_constraint(version + ".*")
-            else:
-                constraint = Version.parse(version)
+            constraint = parse_constraint(version + ".*")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

4 participants