diff --git a/pyproject.toml b/pyproject.toml index 76023b5..a7ac6e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,6 @@ dependencies = [ "click", "tomli; python_version < '3.11'", "colorama; platform_system == 'Windows'", - "pywin32; platform_system == 'Windows'", "importlib_metadata >= 7" ] dynamic = ['version'] diff --git a/spin/cmds/meson.py b/spin/cmds/meson.py index 1f51f2e..c2afa01 100644 --- a/spin/cmds/meson.py +++ b/spin/cmds/meson.py @@ -5,7 +5,6 @@ import re import shutil import signal -import subprocess import sys from enum import Enum from pathlib import Path @@ -819,43 +818,26 @@ def run(ctx, *, args, build_dir=None): _set_pythonpath(build_dir, quiet=True) is_windows = sys.platform == "win32" - is_posix = not is_windows - if is_posix: + if not is_windows: # Let the subprocess handle its own signals + # Except on Windows, where it already seems to work as intended, + # and `preexec_fn` is not supported signal.signal(signal.SIGINT, signal.SIG_IGN) def attach_sigint(): # Reset SIGINT handler to default signal.signal(signal.SIGINT, signal.SIG_DFL) - kwargs = ( - {"creationflags": subprocess.CREATE_NEW_PROCESS_GROUP} if is_windows else {} - ) - # --- launch subprocess --- p = _run( cmd_args, echo=False, shell=shell, sys_exit=False, - preexec_fn=attach_sigint if is_posix else None, - **kwargs, + preexec_fn=None if is_windows else attach_sigint, ) - # Handle Ctrl+C (SIGINT) on Windows - def windows_ctrl_handler(ctrl_type): - if ctrl_type == signal.CTRL_C_EVENT: - # Forward CTRL_BREAK_EVENT to the child process - p.send_signal(signal.CTRL_BREAK_EVENT) - return True - return False - - if is_windows: - import win32api - - win32api.SetConsoleCtrlHandler(windows_ctrl_handler, True) - # Is the user trying to run a Python script, without calling the Python interpreter? executable = args[0] if (