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 26 27 28 29 30
|
Index: scalene-0.7.5/scalene/scalene_preload.py
===================================================================
--- scalene-0.7.5.orig/scalene/scalene_preload.py 2022-12-14 19:06:14.064984348 -0300
+++ scalene-0.7.5/scalene/scalene_preload.py 2022-12-15 12:45:48.620071626 -0300
@@ -11,6 +11,10 @@
import scalene
+# To patch loader to use Python ABI renamed files
+from imp import get_suffixes, C_EXTENSION
+
+
class ScalenePreload:
@staticmethod
def get_preload_environ(args: argparse.Namespace) -> Dict[str, str]:
@@ -36,9 +40,11 @@
elif sys.platform == "linux":
if args.memory:
# Prepend the Scalene library to the LD_PRELOAD list, if any
- new_ld_preload = os.path.join(
- scalene.__path__[0].replace(" ", r"\ "), "libscalene.so"
- )
+ # Debianize the path to so file which has been suffixed with arch and Python version
+ best_suffix = [ suffix for suffix in get_suffixes() if suffix[2] == C_EXTENSION ][0][0]
+ library_filename = "libscalene" + best_suffix
+ new_ld_preload = os.path.join(scalene.__path__[0], library_filename)
+
if "LD_PRELOAD" in env:
old_ld_preload = env["LD_PRELOAD"]
env["LD_PRELOAD"] = new_ld_preload + ":" + old_ld_preload
|