Debian Codegraph @

debian/patches/0001-Load-libscalene-so-with-Python-ABI-suffix

raw
1 --- a/scalene/scalene_preload.py
2 +++ b/scalene/scalene_preload.py
3 @@ -12,6 +12,10 @@ from typing import Dict
4 import scalene
5
6
7 +# To patch loader to use Python ABI renamed files
8 +from importlib.machinery import EXTENSION_SUFFIXES
9 +
10 +
11 class ScalenePreload:
12 @staticmethod
13 def get_preload_environ(args: argparse.Namespace) -> Dict[str, str]:
14 @@ -72,7 +76,10 @@ class ScalenePreload:
15 f'{library_path}:{os.environ["LD_LIBRARY_PATH"]}'
16 )
17
18 - new_ld_preload = "libscalene.so"
19 + # Debianize the path to so file which has been suffixed with arch and Python version
20 + library_filename = "libscalene" + EXTENSION_SUFFIXES[0]
21 + new_ld_preload = os.path.join(scalene.__path__[0], library_filename)
22 +
23 if "LD_PRELOAD" not in os.environ:
24 env["LD_PRELOAD"] = new_ld_preload
25 elif new_ld_preload not in os.environ["LD_PRELOAD"].split(":"):