Skip to content

Commit 9344ab3

Browse files
cdce8pDanielNoord
authored andcommitted
Fix STD_LIB_DIRS for PyPy 3.7+
1 parent 419367e commit 9344ab3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

astroid/modutils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,18 @@
8484
except AttributeError:
8585
pass
8686

87-
if platform.python_implementation() == "PyPy":
87+
if platform.python_implementation() == "PyPy" and sys.version_info < (3, 8):
8888
# PyPy stores the stdlib in two places: sys.prefix/lib_pypy and sys.prefix/lib-python/3
8989
# sysconfig.get_path on PyPy returns the first, but without an underscore so we patch this manually.
90+
# Beginning with 3.8 the stdlib is only stored in: sys.prefix/pypy{py_version_short}
9091
STD_LIB_DIRS.add(str(Path(sysconfig.get_path("stdlib")).parent / "lib_pypy"))
91-
STD_LIB_DIRS.add(
92-
sysconfig.get_path("stdlib", vars={"implementation_lower": "python/3"})
93-
)
92+
STD_LIB_DIRS.add(str(Path(sysconfig.get_path("stdlib")).parent / "lib-python/3"))
93+
9494
# TODO: This is a fix for a workaround in virtualenv. At some point we should revisit
9595
# whether this is still necessary. See https://github.com/PyCQA/astroid/pull/1324.
9696
STD_LIB_DIRS.add(str(Path(sysconfig.get_path("platstdlib")).parent / "lib_pypy"))
9797
STD_LIB_DIRS.add(
98-
sysconfig.get_path("platstdlib", vars={"implementation_lower": "python/3"})
98+
str(Path(sysconfig.get_path("platstdlib")).parent / "lib-python/3")
9999
)
100100

101101
if os.name == "posix":

0 commit comments

Comments
 (0)