diff --git a/news/8733.bugfix b/news/8733.bugfix new file mode 100644 index 00000000000..027e85f6496 --- /dev/null +++ b/news/8733.bugfix @@ -0,0 +1 @@ +Correctly uninstall console scripts installed to ~/.local/bin diff --git a/src/pip/_internal/locations.py b/src/pip/_internal/locations.py index 0c1235488d6..0984a11cef1 100644 --- a/src/pip/_internal/locations.py +++ b/src/pip/_internal/locations.py @@ -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