Warn users if there is a higher package version that cannot be installed
See original GitHub issueWhat’s the problem this feature will solve?
I’m the developer of a package whose current version requires at least Python 3.8. This is reflected in python_requires
in setup.py
. The last version to support 3.7 is rather old and broken in many ways. When people run into issues with it, the advice is naturally to upgrade to the latest version.
The problem here is that if you run pip install --upgrade $PACKAGE
under Python 3.7 (tested with Python 3.7.9, pip 21.3.1, setuptools 60.5.0), it will simply report that everything’s fine (‘Requirement already satisfied’). Most importantly, it does not indicate at all that there is a newer version of the package which is incompatible with the Python version. pip index versions $PACKAGE
, pip install ${PACKAGE}==
, and friends also only list the compatible versions. There are very good reasons for this, of course. However, in particular for people unfamiliar with python_requires
, this results in them thinking they already have the current version of a package when they don’t.
Describe the solution you’d like
I would like to see a warning on at least pip install --upgrade
and pip index versions
if higher version numbers get ignored, e.g.
WARNING: Ignoring newer versions of $PACKAGE (1.2.3, 1.2.4, …) which are not compatible with your version of Python.
I’m not all that familiar with the intricacies, so please excuse my ignorance about other reasons why package versions might get pruned from the installation candidates. A more generic warning than just the Python version might be needed instead. However, from a user perspective, ideally it would tell all the relevant details, e.g. also ‘requires at least Python 3.8’ in this particular case.
Alternative Solutions
Other than checking from within the package what the current version is and printing a warning at execution time (as PRAW is doing with update_checker, for example), which has always annoyed me as a user and is definitely not a route I want to take, I cannot think of other approaches since the package code is not involved at all in this step of the installation process to my knowledge.
Additional context
The specific package, if relevant, is snscrape. Version 0.3.4 is the last to support Python 3.7.
Code of Conduct
- I agree to follow the PSF Code of Conduct.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:13 (7 by maintainers)
Top GitHub Comments
Not sure if I understand you options. What I’m thinking is pip should keep a list of discarded candidates, and when it selects a candidate, go through the list and emit a message about why candidates with higher versions in the list were discarded. This way we could even expand the functionality to cover other reasons than Requires-Python.
Also note that pip checks Requires-Python in two places; once when it fetches the list of files from the index (
data-requires-python
from PEP 503), and another when the file is downloaded and metadata is built (Requires-Python
from Core Metadata).Just thinking out loud –
It seems like what’s required is one of the following:
The ability to emit a warning based upon metadata in a later distribution that pip has discarded (something like a
warn_if_discarded
flag, possibly with an argument that contains text for the warning)The ability to modify previous revisions in pypi to get them to emit a warning when installed (or otherwise change their metadata to get the desired effect)
Does that make sense, did I miss any options, and which one is more realistic to do?