question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
uranusjrcommented, Mar 25, 2022

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

0reactions
mnotcommented, Mar 23, 2022

Just thinking out loud –

It seems like what’s required is one of the following:

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

  2. 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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is pip installing an old version of my package?
I've just uploaded a new version of my package to PyPi (1.2. 1.0-r4): I can download the egg file and install it with...
Read more >
NuGet Warning NU1603 - Microsoft Learn
Issue. A package dependency specified a version that could not be found. Typically, the package sources do not contain the expected lower bound ......
Read more >
Auditing package dependencies for security vulnerabilities
Security audits help you protect your package's users by enabling you to find and fix known vulnerabilities in dependencies that could cause data...
Read more >
pip install - pip documentation v22.3.1
Ignore the installed packages, overwriting them. This can break your system if the existing package is of a different version or was installed...
Read more >
Warning message---BiocManager::install
It's saying you already have that package, and the current version. Unless there is a problem with the package you can just use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found