Skip to content

Commit e8b1614

Browse files
committed
Fix uninstallation of user scripts
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.
1 parent 2e4d748 commit e8b1614

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

news/8733.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Correctly uninstall console scripts installed to ~/.local/bin

src/pip/_internal/locations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ def get_src_prefix():
7575
except AttributeError:
7676
user_site = site.USER_SITE
7777

78+
bin_user = sysconfig.get_path('scripts')
79+
7880
if WINDOWS:
7981
bin_py = os.path.join(sys.prefix, 'Scripts')
80-
bin_user = os.path.join(user_site, 'Scripts')
8182
# buildout uses 'bin' on Windows too?
8283
if not os.path.exists(bin_py):
8384
bin_py = os.path.join(sys.prefix, 'bin')
8485
bin_user = os.path.join(user_site, 'bin')
8586
else:
8687
bin_py = os.path.join(sys.prefix, 'bin')
87-
bin_user = os.path.join(user_site, 'bin')
8888

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

src/pip/_internal/req/req_uninstall.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def _script_names(dist, script_name, is_gui):
4646
bin_dir = bin_user
4747
else:
4848
bin_dir = bin_py
49+
assert bin_dir is not None
4950
exe_name = os.path.join(bin_dir, script_name)
5051
paths_to_remove = [exe_name]
5152
if WINDOWS:
@@ -562,6 +563,7 @@ def from_dist(cls, dist):
562563
bin_dir = bin_user
563564
else:
564565
bin_dir = bin_py
566+
assert bin_dir is not None
565567
paths_to_remove.add(os.path.join(bin_dir, script))
566568
if WINDOWS:
567569
paths_to_remove.add(os.path.join(bin_dir, script) + '.bat')

0 commit comments

Comments
 (0)