问题
I notice that, most projects released on PyPI contain a "Py Version" meta data in their project page, but their values vary.
If the package is not a universal package or not a pure python package, their values are understandably different, in order to denote their targeted platform, such as this nose page and this simplejson page.
But some other universal pure (as far as I can tell) Python packages still contain slightly different content. For example:
- search "Py Version" in this requests PyPI page you will find "2.7"
- In this rsa page you will find "3.5"
- In six page it is "py2.py3"
- In python-dateutil page you will see "any"
So my question is, are they caused by different tool chain the author use to build their release package? My attempt of running python2 setup.py sdist bdist_wheel --universal upload
gives me a "2.7" Py Version value. Next time I will try python3 ...
and then twine ...
to see what I will get.
More importantly, do all these matter? My aforementioned command line still builds a universal package suitable to be consumed by others on Python 2 AND Python 3 environment, doesn't it?
回答1:
Anywhere you see 2.7
or 3.5
or another Python version, that column was set by the bdist_wheel command, based on the current Python version used to build with, but this is the wrong value. This is bug 102 in the Wheels project issue tracker.
This was also reported as a bug in the PyPI project. It really should say py2.py3
for all those projects. Luckily, it doesn't matter to the tools used to install wheels what that column says, you still have a universal wheel, it'll be used for installations on either Python 2 or Python 3.
This is not PyPI's fault however, the field is set by the tool doing the uploading. The file_upload() XML-RPC handler takes the value unchanged from the uploader and inserts that into the database for later display. When using setuptools upload
that value is ultimately sourced from the code that built the distribution file, so bdist_wheel
in this case.
If you care deeply about your own project listing the correct information there, then I recommend you use the twine uploader instead; this package extracts the pyversion field from the wheel filename. Any project that has py2.py3
set in the Py Version column, used that tool to do the uploading. Twine has many other advantages, not least that you can use it to securely upload your files over HTTPS.
As for the any
value, that's either set by manually uploading a file in the PyPI interface , or perhaps another tool or a previous version of twine
or setuptools bdist_wheel
I'm not aware about.
回答2:
Since this question was asked, the PyPI design has removed "Py Version" from project pages; the Py Version seems to have been related to the wheel tags or the version of Python used to upload the package, and would not affect which versions of Python can download a source package.
PyPI does feature the Requires-Python metadata Requires: Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
if it is available. This tag is independent of the package format, and a relatively new feature in pip, that controls whether or not the installer will attempt to install a particular project in the target version of Python.
来源:https://stackoverflow.com/questions/40415349/what-does-the-py-version-in-pypi-project-page-mean-and-does-it-matter