-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
Environment
- pip version: 20.2.2
- Python version: 2.7.17
- OS: MacOSX 10.15.5
Description
When downgrading a python package that is already installed by reinstalling it with using pip install --upgrade to a directory, the pip.get_installed_distributions() function gets confused and returns the later version. For example, if Flask 1.1.2 is installed and we change it so using pip install flask==1.1.0 --upgrade, the installation proceeds correctly and the flask version is updated but pip.get_installed_distributions() still returns Flask 1.1.2.
How to Reproduce
Steps to reproduce the behavior:
- Create a new directory and a requirements.txt file with Flask version 1.1.2.
- Install using pip install --target lib -r requirements.txt.
- Change directories into lib and use the python shell.
- Import get_installed_distributions from pip._internal.utils.misc import get_installed_distributions.
- Run it on the current directory by using get_installed_distributions(skip=[], paths=['/path/to/lib'])
- Version should be correct.
- Now change the requirements.txt file to any version of Flask that is earlier than 1.1.2 (e.g 1.1.0).
- Run pip install --target lib -r requirements.txt --upgrade.
- Repeat steps 3-5.
- Version is still 1.1.2 on Flask.
Expected behavior
The version should be correct. I made sure by importing the flask library and printing out flask.version and confirmed that the installation proceeded correctly. However, the get_installed_distribution() function does not return the correct version.
Output
Detailed in the "To Reproduce" section.