pip: "pip uninstall" stuck for long if no "-v" is given for some package

Description

When uninstalling smashpy, pip stuck for long in listing the file to delete (and keep). WIth -v this stuck does not happen.

IMO, the function compress_for_output_listing has some problem with this package:

https://github.com/pypa/pip/blob/bef589d8cbaa74264c2cbffc839dda0917e2c7cb/src/pip/_internal/req/req_uninstall.py#L427-L428

Expected behavior

pip uninstall is generally expected to respond more quickly without -v than with it.

pip version

21.1.3

Python version

3.9.6

OS

Arch Linux

How to Reproduce

  1. pip install smashpy
  2. pip uninstall smashpy
    • pip displays the uninstall information slowly
  3. pip uninstall smashpy -v
    • pip displays the uninstall information quickly

Output

$ pip uninstall smashpy
Found existing installation: smashpy 0.0.8
Uninstalling smashpy-0.0.8:
  Would remove:
    /tmp/venv/lib/python3.9/site-packages/*
  Would not remove (might be manually added):
    /tmp/venv/lib/python3.9/site-packages/Keras-2.4.3.dist-info/INSTALLER
    /tmp/venv/lib/python3.9/site-packages/Keras-2.4.3.dist-info/LICENSE
    /tmp/venv/lib/python3.9/site-packages/Keras-2.4.3.dist-info/METADATA
    /tmp/venv/lib/python3.9/site-packages/Keras-2.4.3.dist-info/RECORD
    (thousands of lines omitted)

$ pip uninstall smashpy -v
Found existing installation: smashpy 0.0.8
Uninstalling smashpy-0.0.8:
  Would remove:
    /tmp/venv/lib/python3.9/site-packages/__init__.py
    /tmp/venv/lib/python3.9/site-packages/__pycache__/__init__.cpython-39.pyc
    /tmp/venv/lib/python3.9/site-packages/__pycache__/_version.cpython-39.pyc
    /tmp/venv/lib/python3.9/site-packages/__pycache__/pySMaSH.cpython-39.pyc
    /tmp/venv/lib/python3.9/site-packages/__pycache__/smashpy.cpython-39.pyc
    /tmp/venv/lib/python3.9/site-packages/_version.py
    /tmp/venv/lib/python3.9/site-packages/pySMaSH.py
    /tmp/venv/lib/python3.9/site-packages/smashpy-0.0.8.dist-info/INSTALLER
    /tmp/venv/lib/python3.9/site-packages/smashpy-0.0.8.dist-info/LICENSE
    /tmp/venv/lib/python3.9/site-packages/smashpy-0.0.8.dist-info/METADATA
    /tmp/venv/lib/python3.9/site-packages/smashpy-0.0.8.dist-info/RECORD
    /tmp/venv/lib/python3.9/site-packages/smashpy-0.0.8.dist-info/REQUESTED
    /tmp/venv/lib/python3.9/site-packages/smashpy-0.0.8.dist-info/WHEEL
    /tmp/venv/lib/python3.9/site-packages/smashpy-0.0.8.dist-info/top_level.txt
    /tmp/venv/lib/python3.9/site-packages/smashpy.py
  Will actually move:
    /tmp/venv/lib/python3.9/site-packages/__init__.py
    /tmp/venv/lib/python3.9/site-packages/__pycache__/__init__.cpython-39.pyc
    /tmp/venv/lib/python3.9/site-packages/__pycache__/_version.cpython-39.pyc
    /tmp/venv/lib/python3.9/site-packages/__pycache__/pySMaSH.cpython-39.pyc
    /tmp/venv/lib/python3.9/site-packages/__pycache__/smashpy.cpython-39.pyc
    /tmp/venv/lib/python3.9/site-packages/_version.py
    /tmp/venv/lib/python3.9/site-packages/pySMaSH.py
    /tmp/venv/lib/python3.9/site-packages/smashpy-0.0.8.dist-info/
    /tmp/venv/lib/python3.9/site-packages/smashpy.py

Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

This looks like a bug in the packaging of smashpy - it’s installing files (including an __init__.py entry) direct into site-packages, and that’s somehow making pip think it needs to remove all of the site-packages directory!

Pip should probably protect better against badly packaged projects like this, but smashpy needs fixing as well…