small fix for running as py-module on windows (#1615)

This commit is contained in:
Alexander Piskun 2025-03-06 15:48:08 +03:00 committed by GitHub
parent e87d616b7a
commit 8b16ef641b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -1599,11 +1599,11 @@ def restart(self):
if '--windows-standalone-build' in sys_argv:
sys_argv.remove('--windows-standalone-build')
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
if 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:]
elif sys.platform.startswith('win32'):
cmds = ['"' + sys.executable + '"', '"' + sys_argv[0] + '"'] + sys_argv[1:]
else:
cmds = [sys.executable] + sys_argv

View File

@ -816,11 +816,11 @@ if script_executed:
else:
sys_argv = sys.argv.copy()
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
if 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:]
elif sys.platform.startswith('win32'):
cmds = ['"' + sys.executable + '"', '"' + sys_argv[0] + '"'] + sys_argv[1:]
else:
cmds = [sys.executable] + sys_argv