Skip to content

Commit

Permalink
Fix uninstallation of user scripts
Browse files Browse the repository at this point in the history
User scripts are installed to ~/.local/bin. pip was looking for scripts
to uninstall in ~/.local/lib/python3.8/site-packages/bin. This commit
makes it look in ~/.local/bin instead.
  • Loading branch information
DaanDeMeyer committed Aug 8, 2020
1 parent 2e4d748 commit 781108f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/8733.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Correctly uninstall console scripts installed to ~/.local/bin
12 changes: 10 additions & 2 deletions src/pip/_internal/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,27 @@ def get_src_prefix():
# Use getusersitepackages if this is present, as it ensures that the
# value is initialised properly.
user_site = site.getusersitepackages()
user_base = site.getuserbase()
except AttributeError:
user_site = site.USER_SITE
user_base = site.USER_BASE

if WINDOWS:
bin_py = os.path.join(sys.prefix, 'Scripts')
bin_user = os.path.join(user_site, 'Scripts')
if running_under_virtualenv():
bin_user = os.path.join(user_site, 'Scripts')
else:
bin_user = os.path.join(user_base, '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')
else:
bin_py = os.path.join(sys.prefix, 'bin')
bin_user = os.path.join(user_site, 'bin')
if running_under_virtualenv():
bin_user = os.path.join(user_site, 'bin')
else:
bin_user = os.path.join(user_base, '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

0 comments on commit 781108f

Please sign in to comment.