pip: Warn users if there is a higher package version that cannot be installed

What’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

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 8
  • Comments: 19 (9 by maintainers)

Most upvoted comments

I’m not sure I understand. Pip already throws a [Notice] a new release of pip is available... when you aren’t using the latest version of pip. I’m thinking of just doing something like that. Considering how often people just want to install the latest version of a package and they don’t realize they are silently getting an outdated version, this seems to fall under the scope of pip installs packages. Also see PEP 20 In the face of ambiguity, refuse the temptation to guess..

Perhaps a simpler solution than working out why each dist was ignored/filtered, is to just look up what is the highest version number available after resolving which one to install. If pip didn’t end up having the latest version out there, then a little warning saying: WARNING: installing version x.x.x because the higher version y.y.y is incompatible would already let people know to hunt for a reason why this might happen rather than silently giving unexpected behavior.

Obviously the error would not be thrown if the user requested a specific version.

A similar warning could be thrown if there is no compatible version like: WARNING: no compatible package found, the latest y.y.y is incompatible.

Pip is short for pip installs packages

It’s not a lifecycle management system

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).