From 09ea6dd2e4851668566a119857f65e037ba9b65f Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Mon, 9 Jan 2017 12:35:40 +0300 Subject: [PATCH] Fix recursive call on Windows For some reason sys.argv[0] may contain path to the python wrapper (hererocks-script.py) or just "hererocks". Use inspect.getsourcefile to get hererocks file location instead. --- hererocks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hererocks.py b/hererocks.py index e152712..bbf1141 100755 --- a/hererocks.py +++ b/hererocks.py @@ -6,6 +6,7 @@ import argparse import hashlib +import inspect import json import os import platform @@ -1645,7 +1646,7 @@ def setup_vs_and_rerun(vs_version, arch): argv_name = os.path.join(temp_dir, "argv") setup_output_name = os.path.join(temp_dir, "setup_out") - script_arg = '"{}"'.format(sys.argv[0]) + script_arg = '"{}"'.format(inspect.getsourcefile(main)) if sys.executable: script_arg = '"{}" {}'.format(sys.executable, script_arg)