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

Fix uninstallation of user scripts #8733

Merged
merged 4 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/8733.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Correctly uninstall scripts installed with --user
uranusjr marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 14 additions & 3 deletions src/pip/_internal/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,27 @@ def get_src_prefix():
except AttributeError:
user_site = site.USER_SITE


def _get_bin_user():
# type: (...) -> str
pradyunsg marked this conversation as resolved.
Show resolved Hide resolved
scheme = "{}_user".format(os.name)
if scheme not in sysconfig.get_scheme_names():
scheme = "posix_user" # Default to POSIX for unknown platforms.
path = sysconfig.get_path("scripts", scheme=scheme)
assert path is not None
return path


bin_user = _get_bin_user()

if WINDOWS:
bin_py = os.path.join(sys.prefix, 'Scripts')
bin_user = os.path.join(user_site, 'Scripts')
# buildout uses 'bin' on Windows too?
if not os.path.exists(bin_py):
bin_py = os.path.join(sys.prefix, 'bin')
bin_user = os.path.join(user_site, 'bin')
bin_user = os.path.join(os.path.dirname(bin_user), 'bin')
else:
bin_py = os.path.join(sys.prefix, 'bin')
DaanDeMeyer marked this conversation as resolved.
Show resolved Hide resolved
bin_user = os.path.join(user_site, 'bin')

# Forcing to use /usr/local/bin for standard macOS framework installs
# Also log to ~/Library/Logs/ for use with the Console.app log viewer
Expand Down