#! /usr/bin/env python3 import sys, os, os.path, subprocess, time args = ["gcc"] + sys.argv[1:] try: output = args[args.index("-o", 1) + 1] if not output.endswith("Modules/_math.o"): raise ValueError(output) except ValueError: # Not compiling _math.c os.execvp("gcc", args) else: if os.path.exists(output): # Assume recompiling it print("RECOMPILE", file=sys.stderr) time.sleep(5) # Wait for initial compilation print("RECOMPIILE TRUNCATING", file=sys.stderr) with open(output, "wb"): # Emulate creating new empty file pass time.sleep(5) # Linker for other module may run here subprocess.check_call(args) print("RECOMPILE FINISHED", file=sys.stderr) else: # Assume initial compilation print("INITIAL COMPILE", file=sys.stderr) subprocess.check_call(args) time.sleep(9) # Wait for recompilation to truncate print("INITIAL COMPILE FINISHED", file=sys.stderr)