restart action: support running as Python module

This commit is contained in:
bigcat88 2025-02-25 09:34:38 +02:00
parent d3d613cca9
commit ee47f25225
No known key found for this signature in database
GPG Key ID: 1F0BF0EC3CF22721

View File

@ -1578,6 +1578,9 @@ def restart(self):
if sys.platform.startswith('win32'): if sys.platform.startswith('win32'):
cmds = ['"' + sys.executable + '"', '"' + sys_argv[0] + '"'] + sys_argv[1:] cmds = ['"' + sys.executable + '"', '"' + sys_argv[0] + '"'] + sys_argv[1:]
elif sys_argv[0].endswith("__main__.py"): # this is a python module
module_name = os.path.basename(os.path.dirname(sys_argv[0]))
cmds = [sys.executable, '-m', module_name] + sys_argv[1:]
else: else:
cmds = [sys.executable] + sys_argv cmds = [sys.executable] + sys_argv