File: 0001-Load-libscalene-so-with-Python-ABI-suffix

package info (click to toggle)
scalene 1.5.54-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,980 kB
  • sloc: cpp: 22,870; python: 14,493; javascript: 12,297; ansic: 817; makefile: 196; sh: 45
file content (25 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
--- a/scalene/scalene_preload.py
+++ b/scalene/scalene_preload.py
@@ -12,6 +12,10 @@ from typing import Dict
 import scalene
 
 
+# To patch loader to use Python ABI renamed files
+from importlib.machinery import EXTENSION_SUFFIXES
+
+
 class ScalenePreload:
     @staticmethod
     def get_preload_environ(args: argparse.Namespace) -> Dict[str, str]:
@@ -72,7 +76,10 @@ class ScalenePreload:
                         f'{library_path}:{os.environ["LD_LIBRARY_PATH"]}'
                     )
 
-                new_ld_preload = "libscalene.so"
+                # Debianize the path to so file which has been suffixed with arch and Python version
+                library_filename = "libscalene" + EXTENSION_SUFFIXES[0]
+                new_ld_preload = os.path.join(scalene.__path__[0], library_filename)
+
                 if "LD_PRELOAD" not in os.environ:
                     env["LD_PRELOAD"] = new_ld_preload
                 elif new_ld_preload not in os.environ["LD_PRELOAD"].split(":"):