-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Guide request: gracefully dropping support for older Python versions #450
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
Comments
It occurs to me that an even more conservative approach would be to start out by specifying That way, the release with the warning and updated |
@tonybaloney has investigated this further (by way of https://github.com/tonybaloney/friendly-deprecation-test), and found that while pip 9 won't install the incompatible version on older Pythons, the mere availability of that version still prevents installation of maintenance updates for the older version - you need to explicitly amend the installation command to request a compatible version. This means that for older versions of pip, the problem will need to be addressed at the That behaviour also becomes a feature request for future versions of |
Use case here is that package maintainers will continually drop support for out-of-support versions of Python, e.g. 2.6, 2.7 (soon), 3.2, 3.3 etc. Looking at the download stats of users on packages I maintain, most downloads are coming from 2.7. I'd like to drop support for 2.7-3.4 and start implementing async/await features. But, the users of older distributions probably aren't even aware that they're installing my package, it's part of an automated script, a CI/CD process. If most of the pip install'ing happens in background processes then user warnings are going to be largely ignored and erroring completely on installation is going to break their system. If there were instead a way to continually develop and evolve packages inline with the supported Python distributions, whilst having "legacy" releases where I can still apply security fixes. this could be a "large version that supported Python 2.6" tag on the metadata in the package API. Which I can periodically update, following semver. Imagining this timeline.. **July 2018: ** August 2018: September 2018 |
I think the current metadata can already express that OK - v2.0+ would have The problem is that |
Take Django as an example: https://pypi.python.org/simple/django/ and https://pypi.org/simple/django/ both set |
cc'ing @pradyunsg and @dstufft here before I turn this into an RFE for |
@pradyunsg Thanks for checking that - it seemed odd that it wasn't working that way, so I'm happy to hear the problem is somewhere else rather than in pip's handling of Your results made me realise I hadn't checked the link metadata at https://pypi.org/simple/friendly-deprecation-test/, and that shows that PyPI hasn't picked up the Checking https://pypi.org/project/friendly-deprecation-test/#files shows @tonybaloney hit the case where PyPI can't correctly infer |
Yeah. There's some discussion over at pypi/warehouse#474 IIRC. Basically, certain metadata is only loaded by warehouse when a wheel is uploaded first, and it's loaded from only that wheel. This might be one of those cases. |
The specific problem hit here was to only upload the sdist (which is an entirely reasonable thing to do, it just has the consequence that PyPI doesn't know how to pull metadata from it without running arbitrary user uploaded code). I filed pypi/warehouse#3138 to suggest making it possible for project admins to set the Having two potential "sources of truth" for this info is far from ideal, but it also makes it much easier to mitigate the consequences of incorrect metadata in a release (or uploading that metadata in a way that means PyPI doesn't infer the right value for |
I don't think it has anything to do with an sdist, you just need a new enough setuptools and twine when you do the upload. |
|
@ncoghlan it works when using setuptools 👍
|
Oh yea, distutils doesn't support it at all. |
I did post an article about this, happy to write another explaining the process. But considering I've fumbled my way into making it work I might not be the best person to do so :-) |
@tonybaloney Thanks for working through it with us! If nobody beats me to it, I'll turn your experience with this into a packaging.python.org guide this weekend :) |
@tonybaloney Thanks for the useful article! By the way, there's a autocorrect typo in |
I wrote:
Well, that didn't happen, and I'm no longer sure when I'll make time to do this myself (we're starting to get more feedback on the interpreter start-up changes in the 3.7 beta, so I have a few problems like https://bugs.python.org/issue33042 to find and fix). If anyone does want to take a go at writing this themselves:
|
I'll do it today. |
Raised PR. |
When old Python versions are dropped, this will help pip install the right version for people still running those old Python versions. For more info on how this works: * https://hackernoon.com/phasing-out-python-runtimes-gracefully-956f112f33c4 * pypa/packaging.python.org#450
#459 has been merged. Thanks again @tonybaloney, for both the original article and the guide! :) |
When botocore drops old Python versions, this will help pip install the right version for people still running those old Python versions. For more info on how this works: * https://hackernoon.com/phasing-out-python-runtimes-gracefully-956f112f33c4 * pypa/packaging.python.org#450
When botocore drops old Python versions, this will help pip install the right version for people still running those old Python versions. For more info on how this works: * https://hackernoon.com/phasing-out-python-runtimes-gracefully-956f112f33c4 * pypa/packaging.python.org#450
When botocore drops old Python versions, this will help pip install the right version for people still running those old Python versions. For more info on how this works: * https://hackernoon.com/phasing-out-python-runtimes-gracefully-956f112f33c4 * pypa/packaging.python.org#450
This guide has been written by @tonybaloney and can now be found here: https://packaging.python.org/guides/dropping-older-python-versions/
Talking to @tonybaloney about https://twitter.com/anthonypjshaw/status/970088412177776640, I discovered that our support for gracefully dropping support for older Python versions is currently better than I realised, but it's also far from obvious how to actually do it and the potential errors to avoid.
The key moving parts are:
Requires-Python
field in metadata 1.2+: https://packaging.python.org/specifications/core-metadata/#requires-pythondata-requires-python
link attribute in the index server release listing API: https://www.python.org/dev/peps/pep-0503/#specificationdata-requires-python
aware installer (e.g.pip
9+)Requires-Python
field in the project metadata (e.g. thepython_requires
setting insetuptools
24.2.0+)data-requires-python
correctly (e.g.pypi.python.org
since pypi/legacy@3e1ce8f)The most conservative approach to implicitly pinning older clients to the last compatible release would be to release an alpha or development release that sets "Requires-Python: >= 3.6" (for example) in the metadata, and includes an import-time warning snippet like the one below, but doesn't actually require the new version yet:
(Using
FutureWarning
ensures that the message will be visible by default even on versions whereDeprecationWarning
is hidden by default)This conservative approach has a few key benefits:
pip install --pre
while others on recentpip
versions will ignore it even ifRequires-Python
didn't get set correctly (since it's a pre-release)Requires-Python
in the metadata, you only end up with a pre-release that emits a spurious warning rather than one that's fundamentally broken, and can easily push a new version that sets that metadata correctly (since older clients should be updated to versions that default to ignoring pre-releases).The text was updated successfully, but these errors were encountered: