Skip to content

Commit

Permalink
Fix test for Python >=3.13. (#2650)
Browse files Browse the repository at this point in the history
The sysconfig module became a package in 3.13; so the test strategy for
ammending getsitepackages was broken. Robustify with a sys.path common
prefix match against the sysconfig module location.
  • Loading branch information
jsirois authored Jan 24, 2025
1 parent c81fe25 commit 173eaab
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/test_pex.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from pex import resolver
from pex.common import environment_as, safe_mkdir, safe_open, temporary_dir
from pex.compatibility import PY2, WINDOWS, to_bytes
from pex.compatibility import PY2, WINDOWS, commonpath, to_bytes
from pex.dist_metadata import Distribution
from pex.interpreter import PythonIdentity, PythonInterpreter
from pex.pex import PEX, IsolatedSysPath
Expand Down Expand Up @@ -235,7 +235,14 @@ def test_site_libs_symlink(tmpdir):
# bit of stdlib is on the sys.path. We get this by grabbing its sys.path entry, which contains
# the whole stdlib in addition to it.
assert sysconfig.__file__
sys_path_entry = os.path.dirname(sysconfig.__file__)

sys_path_entries = tuple(
entry
for entry in PythonIdentity.get().sys_path
if entry == commonpath((entry, sysconfig.__file__))
)
assert len(sys_path_entries) == 1
sys_path_entry = sys_path_entries[0]

sys_path_entry_link = os.path.join(str(tmpdir), "lib-link")
os.symlink(sys_path_entry, sys_path_entry_link)
Expand Down

0 comments on commit 173eaab

Please sign in to comment.