Skip to content

Commit 82d5208

Browse files
committed
gh-98894: Fix DTrace test_check_probes for shared builds
When building with --enable-shared, the SystemTap/DTrace notes live in libpython. Add detection logic to be used by readelf.
1 parent 29a920e commit 82d5208

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

Lib/test/test_dtrace.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,28 @@ def get_readelf_version():
405405
return int(match.group(1)), int(match.group(2))
406406

407407
def get_readelf_output(self):
408-
command = ["readelf", "-n", sys.executable]
408+
binary = sys.executable
409+
if sysconfig.get_config_var("Py_ENABLE_SHARED"):
410+
lib_dir = sysconfig.get_config_var("LIBDIR")
411+
if not lib_dir or sysconfig.is_python_build():
412+
lib_dir = os.path.abspath(os.path.dirname(sys.executable))
413+
414+
lib_names = []
415+
for name in (
416+
sysconfig.get_config_var("INSTSONAME"),
417+
sysconfig.get_config_var("LDLIBRARY"),
418+
):
419+
if name and name not in lib_names:
420+
lib_names.append(name)
421+
422+
if lib_dir:
423+
for name in lib_names:
424+
libpython_path = os.path.join(lib_dir, name)
425+
if os.path.exists(libpython_path):
426+
binary = libpython_path
427+
break
428+
429+
command = ["readelf", "-n", binary]
409430
stdout, _ = subprocess.Popen(
410431
command,
411432
stdout=subprocess.PIPE,

0 commit comments

Comments
 (0)