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
@@ -10,6 +10,10 @@
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]:
@@ -67,7 +71,10 @@
elif library_path not in os.environ['LD_LIBRARY_PATH']:
env['LD_LIBRARY_PATH'] = 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" in os.environ and new_ld_preload not in os.environ["LD_PRELOAD"]:
old_ld_preload = os.environ["LD_PRELOAD"]
env["LD_PRELOAD"] = new_ld_preload + ":" + old_ld_preload
|