Skip to content

Commit

Permalink
Remove getsitepackages() implementation (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterebden authored Nov 19, 2024
1 parent 5b38e13 commit 79abc76
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions tools/please_pex/pex/pex_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from importlib.abc import MetaPathFinder
from importlib.metadata import Distribution
from importlib.util import spec_from_loader
from site import getsitepackages
import itertools
import os
import re
Expand All @@ -13,38 +14,6 @@
import tempfile
import zipfile


try:
from site import getsitepackages
except:
def getsitepackages(prefixes=[sys.prefix, sys.exec_prefix]):
"""Returns a list containing all global site-packages directories.
For each directory present in ``prefixes`` (or the global ``PREFIXES``),
this function will find its `site-packages` subdirectory depending on the
system environment, and will return a list of full paths.
"""
sitepackages = []
seen = set()

if prefixes is None:
prefixes = PREFIXES

for prefix in prefixes:
if not prefix or prefix in seen:
continue
seen.add(prefix)

if os.sep == '/':
sitepackages.append(os.path.join(prefix, "lib",
"python%d.%d" % sys.version_info[:2],
"site-packages"))
else:
sitepackages.append(prefix)
sitepackages.append(os.path.join(prefix, "lib", "site-packages"))

return sitepackages

# Put this pex on the path before anything else.
PEX = os.path.abspath(sys.argv[0])
# This might get overridden down the line if the pex isn't zip-safe.
Expand Down

0 comments on commit 79abc76

Please sign in to comment.