Skip to content

Commit

Permalink
WIP --prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Mar 9, 2022
1 parent 2f2c772 commit 10b4400
Show file tree
Hide file tree
Showing 29 changed files with 473 additions and 270 deletions.
10 changes: 10 additions & 0 deletions pex/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
DETERMINISTIC_DATETIME_TIMESTAMP = (DETERMINISTIC_DATETIME - _UNIX_EPOCH).total_seconds()


def find_site_packages(prefix_dir):
# type: (str) -> Optional[str]
"""Return the absolute path to the site-packages directory of the given Python installation."""
for root, dirs, _ in os.walk(prefix_dir):
for d in dirs:
if "site-packages" == d:
return os.path.join(root, d)
return None


def filter_pyc_dirs(dirs):
# type: (Iterable[str]) -> Iterator[str]
"""Return an iterator over the input `dirs` filtering out Python bytecode cache directories."""
Expand Down
3 changes: 2 additions & 1 deletion pex/finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os

from pex.common import is_python_script
from pex.pep_376 import InstalledWheel
from pex.third_party.pkg_resources import Distribution
from pex.typing import TYPE_CHECKING, cast

Expand All @@ -27,7 +28,7 @@ def find(
name, # type: str
):
# type: (...) -> Optional[DistributionScript]
script_path = os.path.join(dist.location, "bin", name)
script_path = InstalledWheel.load(dist.location).stashed_path("bin", name)
return cls(dist=dist, path=script_path) if os.path.isfile(script_path) else None

dist = attr.ib() # type: Distribution
Expand Down
Loading

0 comments on commit 10b4400

Please sign in to comment.