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 e8b1614
Show file tree
Hide file tree
Showing 3 changed files with 5 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
4 changes: 2 additions & 2 deletions src/pip/_internal/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ def get_src_prefix():
except AttributeError:
user_site = site.USER_SITE

bin_user = sysconfig.get_path('scripts')

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')
else:
bin_py = os.path.join(sys.prefix, 'bin')
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
2 changes: 2 additions & 0 deletions src/pip/_internal/req/req_uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def _script_names(dist, script_name, is_gui):
bin_dir = bin_user
else:
bin_dir = bin_py
assert bin_dir is not None
exe_name = os.path.join(bin_dir, script_name)
paths_to_remove = [exe_name]
if WINDOWS:
Expand Down Expand Up @@ -562,6 +563,7 @@ def from_dist(cls, dist):
bin_dir = bin_user
else:
bin_dir = bin_py
assert bin_dir is not None
paths_to_remove.add(os.path.join(bin_dir, script))
if WINDOWS:
paths_to_remove.add(os.path.join(bin_dir, script) + '.bat')
Expand Down

0 comments on commit e8b1614

Please sign in to comment.