Skip to content

Commit

Permalink
Merge pull request #8733
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr authored Feb 25, 2021
2 parents 43b7f3f + c63e5d3 commit 410e82a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions news/8733.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Correctly uninstall script files (from setuptools' ``scripts`` argument), when installed with ``--user``.
17 changes: 14 additions & 3 deletions src/pip/_internal/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,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
Expand Down

0 comments on commit 410e82a

Please sign in to comment.