uv icon indicating copy to clipboard operation
uv copied to clipboard

Suggestion: read Python versions from PyPI Trove Classifiers

Open RomainBrault opened this issue 1 year ago • 2 comments

Would it be possible to have an option to read Python versions from trove classifiers ?

I.e. read

Programming Language :: Python :: 3.13

in pyproject.toml instead of .python-version(s).

Rational:

  • Many people using pypi will set this metadata. I guess it is wildly adopted.
  • It is used in some Github actions as metadata (e.g. https://github.com/hynek/build-and-inspect-python-package)
  • It would help maintenance by avoiding duplication of information

Bonus:

  • In this case accessing the python versions would require some toml parsing and string splitting. Thus it would be helpful to have in uv something that give a clean list of the project Python versions or even the intersection of the project Python versions and the set of UV available Python.

RomainBrault avatar Dec 15 '24 09:12 RomainBrault

The classifiers are for all supported versions, right? This should already be available via requires-python, with the exception of whether or not the latest version is supported in some cases?

zanieb avatar Dec 15 '24 16:12 zanieb

requires-python are just some bounds and not a list of Python versions. You don´t need to provide an upper one or set it very loose like python<4.0. You can also set exception on minor version in the requires-python segment.

On the other hand the trove classifiers are usually a list of labels of major python versions supported, which looks similar in purpose (while still a bit different) to the .python-versions file.

Maybe I miss the intended purpose of .python-version file. From what I understood from the doc, it provide a convenient way to do uv python install for a bunch of Python versions/interpreter listed in .python-versions. In the case where this list is just a bunch of major python version this information is already in the trove classifiers.

Trove classifier are related but independent from requires-python, as requires-python can have loose bound for forward compatibility (library). For a major version of Python represented by a trove classifier, the user (or uv) should pull the latest Python version for this major, respecting the bound given by requires-python.

RomainBrault avatar Dec 16 '24 07:12 RomainBrault