Description
Description
When you uninstall a package with extra files (as described in #12445) you can end up in a bad state where pip
warns due to the existence of an invalid dist-info
directory e.g.
WARNING: Skipping .venv/lib/python3.11/site-packages/idna-3.6.dist-info due to invalid metadata entry 'name'
However, this warning is shown in cases where there is no METADATA file at all and it's not clear how to resolve this as a user.
Expected behavior
Instead of suggesting that the metadata has an invalid 'name', the warning should suggest that the dist-info is invalid
WARNING: Skipping .venv/lib/python3.11/site-packages/idna-3.6.dist-info due to invalid due to missing
METADATA
file
Perhaps there's even a better user experience to be had here? Curious to hear others' thoughts.
pip version
23.3.2
Python version
3.11.4
OS
macOS
How to Reproduce
Here, we construct a bad dist-info entry manually though a user can get in this state accidentally without editing site-packages
.
python -m venv .venv
source .venv/bin/activate
python -m pip install pip==23.3.2 > /dev/null 2>&1
set -eux
SITE_PACKAGES=$(python -c 'import site; print(site.getsitepackages()[0])')
# Create a bad dist-info entry
mkdir -p $SITE_PACKAGES/foo.dist-info
touch $SITE_PACKAGES/foo.dist-info/FOO
# Warning is not clear during `pip` command
pip list
rm -rf .venv
Output
++ python -c 'import site; print(site.getsitepackages()[0])'
+ SITE_PACKAGES=.venv/lib/python3.11/site-packages
+ mkdir -p .venv/lib/python3.11/site-packages/foo.dist-info
+ touch .venv/lib/python3.11/site-packages/foo.dist-info/FOO
+ pip list
WARNING: Skipping .venv/lib/python3.11/site-packages/foo.dist-info due to invalid metadata entry 'name'
Package Version
---------- -------
pip 23.3.2
setuptools 65.5.0
+ rm -rf .venv
Code of Conduct
- I agree to follow the PSF Code of Conduct.