From 6961d90600a577ce7db8d3c98da5c4cc2df10928 Mon Sep 17 00:00:00 2001 From: chielP Date: Fri, 6 Oct 2023 20:25:10 +0200 Subject: [PATCH] remove old file --- py-polars/debug/launch.py | 78 --------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 py-polars/debug/launch.py diff --git a/py-polars/debug/launch.py b/py-polars/debug/launch.py deleted file mode 100644 index f83db37d16f..00000000000 --- a/py-polars/debug/launch.py +++ /dev/null @@ -1,78 +0,0 @@ -import os -import re -import sys -import time -from pathlib import Path - -""" -The following parameter determines the sleep time of the Python process after a signal -is sent that attaches the Rust LLDB debugger. If the Rust LLDB debugger attaches to the -current session too late, it might miss any set breakpoints. If this happens -consistently, it is recommended to increase this value. -""" -LLDB_DEBUG_WAIT_TIME_SECONDS = 1 - - -def launch_debugging() -> None: - """ - Debug Rust files via Python. - - Determine the pID for the current debugging session, attach the Rust LLDB launcher, - and execute the originally-requested script. - """ - if len(sys.argv) == 1: - raise RuntimeError( - "launch.py is not meant to be executed directly; please use the `Python: " - "Debug Rust` debugging configuration to run a python script that uses the " - "polars library." - ) - - # Get the current process ID. - pID = os.getpid() - - # Print to the debug console to allow VSCode to pick up on the signal and start the - # Rust LLDB configuration automatically. - launch_file = Path(__file__).parents[2] / ".vscode/launch.json" - if not launch_file.exists(): - raise RuntimeError(f"Cannot locate {launch_file}") - with launch_file.open("r") as f: - launch_info = f.read() - - # Overwrite the pid found in launch.json with the pid for the current process. - # Match the initial "Rust LLDB" definition with the pid defined immediately after. - pattern = re.compile('("Rust LLDB",\\s*"pid":\\s*")\\d+(")') - found = pattern.search(launch_info) - if not found: - raise RuntimeError( - "Cannot locate pid definition in launch.json for Rust LLDB configuration. " - "Please follow the instructions in CONTRIBUTING.md for creating the " - "launch configuration." - ) - - launch_info_with_new_pid = pattern.sub(rf"\g<1>{pID}\g<2>", launch_info) - with launch_file.open("w") as f: - f.write(launch_info_with_new_pid) - - # Print pID to the debug console. This auto-triggers the Rust LLDB configurations. - print(f"pID = {pID}") - - # Give the LLDB time to connect. Depending on how long it takes for your LLDB - # debugging session to initiatialize, you may have to adjust this setting. - time.sleep(LLDB_DEBUG_WAIT_TIME_SECONDS) - - # Update sys.argv so that when exec() is called, the first argument is the script - # name itself, and the remaining are the input arguments. - sys.argv.pop(0) - with Path(sys.argv[0]).open() as fh: - script_contents = fh.read() - - # Run the originally requested file by reading in the script, compiling, and - # executing the code. - file_to_execute = Path(sys.argv[0]) - exec( - compile(script_contents, file_to_execute, mode="exec"), {"__name__": "__main__"} - ) - - -if __name__ == "__main__": - launch_debugging()