#!/usr/bin/env python3 import os import sys from subprocess import call if len(sys.argv) < 2: print("You must give a file argument") sys.exit(1) fn = sys.argv[1] opts = sys.argv[2:] if fn.startswith('-'): print("sage-run received unknown option: {}".format(fn)) print("usage: sage [options]") print("Try 'sage -h' for more information.") sys.exit(1) if fn.endswith('.sage'): if call(['sage-preparse', fn]) != 0: sys.exit(1) os.execvp('python3', ['python3', fn + '.py'] + opts) elif fn.endswith('.pyx') or fn.endswith('.spyx'): os.execvp('sage-run-cython', ['sage-run-cython', fn] + opts) else: os.execvp('python3', ['python3', fn] + opts)