From 7d9be739fe05c7dee15e2c14f2809fd0b5c0eae5 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 8 Aug 2020 16:24:24 +0100 Subject: [PATCH 1/4] 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 | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 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..21a9af60df2 100644 --- a/src/pip/_internal/locations.py +++ b/src/pip/_internal/locations.py @@ -75,16 +75,27 @@ def get_src_prefix(): except AttributeError: user_site = site.USER_SITE + +def _get_bin_user(): + # type: (...) -> 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') + bin_user = os.path.join(os.path.dirname(bin_user), '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 From 0ecbce24161aa26bdfaa9e7d4e3998fa66173424 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam <3275593+pradyunsg@users.noreply.github.com> Date: Thu, 10 Sep 2020 17:53:48 +0530 Subject: [PATCH 2/4] Simplify type annotation Co-authored-by: Tzu-ping Chung --- src/pip/_internal/locations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pip/_internal/locations.py b/src/pip/_internal/locations.py index 21a9af60df2..a5426c36163 100644 --- a/src/pip/_internal/locations.py +++ b/src/pip/_internal/locations.py @@ -77,7 +77,7 @@ def get_src_prefix(): def _get_bin_user(): - # type: (...) -> str + # type: () -> str scheme = "{}_user".format(os.name) if scheme not in sysconfig.get_scheme_names(): scheme = "posix_user" # Default to POSIX for unknown platforms. From 3932c31fa71fe554521e85dfe459a1462e2e6da4 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Thu, 25 Feb 2021 13:59:55 +0800 Subject: [PATCH 3/4] Update news fragment from review suggestions Co-authored-by: Pradyun Gedam <3275593+pradyunsg@users.noreply.github.com> --- news/8733.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/8733.bugfix b/news/8733.bugfix index b07ed95698b..95fd675397f 100644 --- a/news/8733.bugfix +++ b/news/8733.bugfix @@ -1 +1 @@ -Correctly uninstall scripts installed with --user +Correctly uninstall script files (from setuptools' ``scripts`` argument), when installed with ``--user``. From c63e5d320994954ecd3fe6cb96cb5a9b9de4e346 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Thu, 25 Feb 2021 14:00:44 +0800 Subject: [PATCH 4/4] Add .rst suffix to news fragment --- news/{8733.bugfix => 8733.bugfix.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename news/{8733.bugfix => 8733.bugfix.rst} (100%) diff --git a/news/8733.bugfix b/news/8733.bugfix.rst similarity index 100% rename from news/8733.bugfix rename to news/8733.bugfix.rst