--- 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(":"):