diff --git a/pylib/gyp/common.py b/pylib/gyp/common.py index 762ae02..3b889bd 100644 --- a/pylib/gyp/common.py +++ b/pylib/gyp/common.py @@ -533,6 +533,10 @@ def CopyTool(flavor, out_path, generator_flags={}): with open(source_path) as source_file: source = source_file.readlines() + # Replace hash bang line with an absolute path to the Python interpreter. + # Note that we use shebang instead of source[0] in the output. + shebang = "#!" + sys.executable + "\n" + # Set custom header flags. header = "# Generated by gyp. Do not edit.\n" mac_toolchain_dir = generator_flags.get("mac_toolchain_dir", None) @@ -542,7 +546,7 @@ def CopyTool(flavor, out_path, generator_flags={}): # Add header and write it out. tool_path = os.path.join(out_path, "gyp-%s-tool" % prefix) with open(tool_path, "w") as tool_file: - tool_file.write("".join([source[0], header] + source[1:])) + tool_file.write("".join([shebang, header] + source[1:])) # Make file executable. os.chmod(tool_path, 0o755)