From fa840380d8a9eaefc4db87e93eb1bb67855c561b Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 8 Aug 2020 16:24:24 +0100 Subject: [PATCH] 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. --- news/8733.bugfix | 1 + src/pip/_internal/locations.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 news/8733.bugfix diff --git a/news/8733.bugfix b/news/8733.bugfix new file mode 100644 index 00000000000..b07ed95698b --- /dev/null +++ b/news/8733.bugfix @@ -0,0 +1 @@ +Correctly uninstall scripts installed with --user diff --git a/src/pip/_internal/locations.py b/src/pip/_internal/locations.py index 0c1235488d6..5683ecb0ba9 100644 --- a/src/pip/_internal/locations.py +++ b/src/pip/_internal/locations.py @@ -75,16 +75,24 @@ def get_src_prefix(): except AttributeError: user_site = site.USER_SITE +def _get_bin_user() -> str: + 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') 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