pip uninstall doesn't remove unc links from pth files · Issue #6516 · pypa/pip (original) (raw)

Environment

Description
If uninstalling a editable package in Python 2.7 that was installed using a UNC file path, the path is not removed from the easy-install.pth file.

Expected behavior
In python 3.7 the unc file path is removed from the pth file when pip uninstall is run. This should also work in python 2.7. The problem is that in python 2, os.path.splitdrive does not work on unc file paths. Pip is checking for absolute paths, this can be handled by the os.path.isabs function, that works in both python 2 and 3 and is specifically for checking if a path is absolute.

While Python 2 is being deprecated at the end of the year, this fix makes the code clearer, and adds unit tests for .pth files. The main reason I would like to see this go through is because I will need to support the python that ships with Maya/3ds Max/Nuke, etc on windows until we stop using them. Given that python 3 support is only just getting added to these applications, I'm going to have to support python 2 for a while on windows environments.

How to Reproduce

  1. pip install -e \\source\source\dev\mikeh\_checkouts\qtpy
  2. Verify that \\source\source\dev\mikeh\_checkouts\qtpy was added to easy-install.pth
  3. pip uninstall Qt.py
  4. \\source\source\dev\mikeh\_checkouts\qtpy was not removed from easy-install.pth.

Substitute Qt.py for your pip package checkout of choice.

Output

C:\>pip install -e \\source\source\dev\mikeh\_checkouts\qtpy
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Looking in indexes: https://pip.blur.com/blur/dev/+simple/
Obtaining file://source/source/dev/mikeh/_checkouts/qtpy
Installing collected packages: Qt.py
  Running setup.py develop for Qt.py
Successfully installed Qt.py

C:\>type C:\Python27_64\Lib\site-packages\easy-install.pth
\\source\source\dev\mikeh\_checkouts\qtpy

C:\>pip uninstall qt.py
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for
 Python 2.7.
Uninstalling Qt.py-1.0.0b3:
  Would remove:
    c:\python27_64\lib\site-packages\qt.py.egg-link
Proceed (y/n)? y
  Successfully uninstalled Qt.py-1.0.0b3

C:\>type C:\Python27_64\Lib\site-packages\easy-install.pth
\\source\source\dev\mikeh\_checkouts\qtpy

I will submit a pull request shortly.