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 uninstall doesn't remove unc links from pth files #6516

Closed
MHendricks opened this issue May 20, 2019 · 1 comment

Comments

@MHendricks
Copy link
Contributor

@MHendricks MHendricks commented May 20, 2019

Environment

  • pip version: 19.1.1
  • Python version: 2.7
  • OS: Windows

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.

@MHendricks

This comment has been minimized.

Copy link
Contributor Author

@MHendricks MHendricks commented May 21, 2019

UNC paths are not supported by os.path.splitdrive in python older than 2.7.8. See #6517 for details.

@MHendricks MHendricks closed this May 21, 2019
@lock lock bot added the S: auto-locked label Jun 20, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
1 participant
You can’t perform that action at this time.