Skip to content

Commit

Permalink
Cruft removal. (#890)
Browse files Browse the repository at this point in the history
  • Loading branch information
emeryberger authored Nov 24, 2024
1 parent d3992bb commit 79d7f61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
10 changes: 3 additions & 7 deletions scalene/scalene_preload.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class ScalenePreload:
@staticmethod
def get_preload_environ(args: argparse.Namespace, escape_spaces = False) -> Dict[str, str]:
def get_preload_environ(args: argparse.Namespace) -> Dict[str, str]:
env = {
"SCALENE_ALLOCATION_SAMPLING_WINDOW": str(
args.allocation_sampling_window
Expand All @@ -36,21 +36,17 @@ def get_preload_environ(args: argparse.Namespace, escape_spaces = False) -> Dict
if args.memory:

library_path = scalene.__path__[0]



# NOTE: you can't use escape sequences inside an f-string pre-3.12 either

# NOTE: you can't use escape sequences inside an f-string pre-3.12 either

# We use this function in two places:
# 1. in `setup_preload`
# 2. when calling into `redirect_python`
if 'LD_LIBRARY_PATH' not in os.environ:

env['LD_LIBRARY_PATH'] = library_path
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'
if "LD_PRELOAD" in os.environ and new_ld_preload not in os.environ["LD_PRELOAD"]:
old_ld_preload = os.environ["LD_PRELOAD"]
Expand Down
3 changes: 1 addition & 2 deletions scalene/scalene_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,7 @@ def __init__(
cmdline += f" --pid={os.getpid()} ---"
# Build the commands to pass along other arguments

# Since we're joining by spaces, we need to escape the spaces in the LD_LIBRARY_PATH.
environ = ScalenePreload.get_preload_environ(Scalene.__args, escape_spaces=True)
environ = ScalenePreload.get_preload_environ(Scalene.__args)
if sys.platform == "win32":
preface = "\n".join(
f"set {k}={str(v)}\n" for (k, v) in environ.items()
Expand Down

0 comments on commit 79d7f61

Please sign in to comment.