question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

python_requires is not compliant with PEP-345, PEP-566 and PEP-508

See original GitHub issue

Currently python_requires only accepts a version specifier per PEP-440. This is an error.

Pursuant to PEP-345, as sustained in PEP-566, the specification regarding environmental markers is as follows:

The fields that benefit from this marker are:

Requires-Python
Requires-External
Requires-Dist
Provides-Dist
Obsoletes-Dist
Classifier

PEP-566 further sustains this specification:

Usage of environment markers is otherwise unchanged from PEP 345.

Thus, according to PEP-345, PEP-566 and PEP-508 it should be possible to specify an extremely narrow constraint such as:

python_requires = ==3.9.1; implementation_name=='cpython' and implementation_version=='3.9.1b2'.

As of setuptools 41.4.0 this is an error:

setuptools.extern.packaging.specifiers.InvalidSpecifier: Invalid specifier: '<3.9;implementation_name=='cpython''

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:33 (18 by maintainers)

github_iconTop GitHub Comments

3reactions
xavfernandezcommented, Oct 23, 2019

I was under impression from @ncoghlan’s explanation that PEP-566 removed the metadata out of the PEP process and delegated it to Core Metadata Specification to avoid PEP process for every metadata update.

As far as I know, Core Metadata Specification is simply an aggregate view of the different PEP, cf Specification Update Process.

Are you saying we should just do nothing right now? If you don’t mind me asking, why?

I’m not saying we should do nothing 😃 I’m suggesting that to solve the current issue (i.e. the fact that “python_requires is not compliant with PEP-345, PEP-566 and PEP-508”) and given how the different major packaging tools (setuptools, pip, PyPI/warehouse and all the other tools that relied on the packaging library) interpreted the Requires-Python for the last 3 years, we should simply clarify/update the PEPs to match its defacto interpretation.

And it doesn’t mean that we should not investigate new ways to specify finer metadata regarding the required python version depending on the interpreter environment but it is likely to need new fields, a new metadata version and some PEP related work.

2reactions
ncoghlancommented, Oct 21, 2019

Fixing this definitely seems worthwhile to me, as it’s not uncommon for projects to be affected by platform-specific standard library limitations that mean they’ll need a newer base Python version in some environments. It also means that a project affected by a regression in a new feature release can clearly indicate that in their metadata:

python_requires = >=3.8.1; python_version=='3.8'

To be fully effective, it would need to be possible to supply multiple python_requires entries, merging the entries that share the same environment marker text.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PEP 508 – Dependency specification for Python Software ...
The language defined is a compact line based format which is already in widespread use in pip requirements files, though we do not...
Read more >
CHANGES.rst - platform/external/python/setuptools - Google Git
#1296: Setuptools now vendors its own direct dependencies, no ... #1210: Add support for PEP 345 Project-URL metadata. ... packaging 16.1 and PEP...
Read more >
Python packaging unpacked: Metadata | a w macpherson
Relevant PEPs: 301 (classifiers), 425 (compatibility tags), 440 (version numbering), 508 (dependency specification), 566 (metadata 2.1), PEP 621 ...
Read more >
vendor - setuptools-39.0.1 - CHANGES.rst - GitLab
#1296: Setuptools now vendors its own direct dependencies, no longer relying on the ... #1210: Add support for PEP 345 Project-URL metadata.
Read more >
Dependencies Management in Setuptools
... needs to be specified according to PEP 508 and PEP 440. ... Dependencies that are not available on a package index but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found