Skip to content

Commit 4d365f6

Browse files
maresbtwiecki
authored andcommitted
Fix PyPy by eliminating deprecated library detection code
PyPy fails when handled here as a special case. For example, the correct value for libname may be "pypy3.9-c" and can be inferred from LDLIBRARY, but setting it to "pypy3-c" leads to failure with `ld: cannot find -lpypy3-c: No such file or directory`.
1 parent 4ee3588 commit 4d365f6

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

pytensor/link/c/cmodule.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,30 +1751,23 @@ def std_lib_dirs_and_libs() -> Optional[tuple[list[str], ...]]:
17511751
elif sys.platform == "darwin":
17521752
std_lib_dirs_and_libs.data = [], []
17531753
else:
1754-
if platform.python_implementation() == "PyPy":
1755-
# Assume Linux (note: Ubuntu doesn't ship this .so)
1756-
libname = "pypy3-c"
1757-
# Unfortunately the only convention of this .so is that it appears
1758-
# next to the location of the interpreter binary.
1759-
libdir = os.path.dirname(os.path.realpath(sys.executable))
1760-
else:
1761-
# Assume Linux
1762-
# Typical include directory: /usr/include/python2.6
1754+
# Assume Linux
1755+
# Typical include directory: /usr/include/python2.6
17631756

1764-
# get the name of the python library (shared object)
1757+
# get the name of the python library (shared object)
17651758

1766-
libname = str(get_config_var("LDLIBRARY"))
1759+
libname = str(get_config_var("LDLIBRARY"))
17671760

1768-
if libname.startswith("lib"):
1769-
libname = libname[3:]
1761+
if libname.startswith("lib"):
1762+
libname = libname[3:]
17701763

1771-
# remove extension if present
1772-
if libname.endswith(".so"):
1773-
libname = libname[:-3]
1774-
elif libname.endswith(".a"):
1775-
libname = libname[:-2]
1764+
# remove extension if present
1765+
if libname.endswith(".so"):
1766+
libname = libname[:-3]
1767+
elif libname.endswith(".a"):
1768+
libname = libname[:-2]
17761769

1777-
libdir = str(get_config_var("LIBDIR"))
1770+
libdir = str(get_config_var("LIBDIR"))
17781771

17791772
std_lib_dirs_and_libs.data = [libname], [libdir]
17801773

0 commit comments

Comments
 (0)