From e2022c6f0232d6fb2ac446bc0fb9b6e44fe51ecf Mon Sep 17 00:00:00 2001 From: Carles Cufi Date: Mon, 4 Feb 2019 21:16:26 +0100 Subject: [PATCH] main: Execute sys.argv[0] on Windows On Windows, sys.argv[0] is the path to an executable (.exe) instead of a Python script. Execute that file directly instead of relying on Python to do so. Signed-off-by: Carles Cufi --- src/west/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/west/main.py b/src/west/main.py index 8b51f1e..df7684e 100755 --- a/src/west/main.py +++ b/src/west/main.py @@ -505,7 +505,13 @@ def main(argv=None): except WestUpdated: # West has been automatically updated. Restart ourselves to run the # latest version, with the same arguments that we were given. - os.execv(sys.executable, [sys.executable] + [sys.argv[0]] + argv) + log.dbg("sys.executable:\"{}\" sys.argv[0]:\"{}\" argv:\"{}\"".format( + sys.executable, sys.argv[0], argv)) + if sys.platform == "win32": + # On Windows Python generates .exe executables + os.execv(sys.argv[0], argv) + else: + os.execv(sys.executable, [sys.executable] + [sys.argv[0]] + argv) except KeyboardInterrupt: sys.exit(0) except CalledProcessError as cpe: