restart action: support running as Python module (#1578)

This commit is contained in:
Alexander Piskun 2025-02-25 11:16:36 +03:00 committed by GitHub
parent d3d613cca9
commit 42b15ad4a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1578,6 +1578,9 @@ def restart(self):
if sys.platform.startswith('win32'):
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:
cmds = [sys.executable] + sys_argv