Skip to content
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

'pip install --upgrade --target' does not uninstall existing installation #9605

Open
1 task done
wimglenn opened this issue Feb 12, 2021 · 0 comments · May be fixed by #12524
Open
1 task done

'pip install --upgrade --target' does not uninstall existing installation #9605

wimglenn opened this issue Feb 12, 2021 · 0 comments · May be fixed by #12524
Labels
C: target pip install's --target option's behaviour handling type: bug A confirmed bug or unintended behavior

Comments

@wimglenn
Copy link
Contributor

wimglenn commented Feb 12, 2021

pip version

21.0.1

Python version

3.9

OS

macOS

Additional information

No response

Description

  • pip can output "Successfully installed mypackage-1.0" even if it wasn't successfully installed
  • pip can leave a .dist-info subdirectory lying around if the installation wasn't successful

Expected behavior

  • don't log the message "Successfully installed mypackage-1.2.3" unless the installation was actually successful
  • if the installation was not successful, rollback any metadata files/subdirectory which was written

How to Reproduce

Setup:

$ mkdir /tmp/example
$ python3 -m pip install six==1.14 --target=/tmp/example
Collecting six==1.14
  Using cached six-1.14.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: six
Successfully installed six-1.14.0
$ ls /tmp/example
__pycache__          six-1.14.0.dist-info six.py

Reproducer:

$ python3 -m pip install six==1.15 --target=/tmp/example
Collecting six==1.15
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: six
Successfully installed six-1.15.0
WARNING: Target directory /tmp/example/__pycache__ already exists. Specify --upgrade to force replacement.
WARNING: Target directory /tmp/example/six.py already exists. Specify --upgrade to force replacement.
$ ls /tmp/example
__pycache__          six-1.14.0.dist-info six-1.15.0.dist-info six.py
$ grep __version__ /tmp/example/six.py
__version__ = "1.14.0"

Output

As you can see, it logged "Successfully installed six-1.15.0" but the code at the target is still the previous version.

Using --upgrade, as the warning message mentioned, does indeed replace files. However, it also leaves files from the old version around too (with six.py there is only one source file, though the old .dist-info subdir also remains). I would normally expect pip to fully remove the previous version before installing new version.

Code of Conduct

  • I agree to follow the PSF Code of Conduct
@wimglenn wimglenn added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Feb 12, 2021
@uranusjr uranusjr changed the title pip reports "Successfully installed mypackage-1.0" even though it didn't successfully install 'pip install --target' reports "Successfully installed mypackage-1.0" even though it didn't successfully install Feb 18, 2021
@uranusjr uranusjr changed the title 'pip install --target' reports "Successfully installed mypackage-1.0" even though it didn't successfully install 'pip install --upgrade --target' does not uninstall existing installation Feb 18, 2021
@uranusjr uranusjr added C: target pip install's --target option's behaviour handling and removed S: needs triage Issues/PRs that need to be triaged labels Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: target pip install's --target option's behaviour handling type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants