install-python/install-python

25 lines
585 B
Python
Executable File

#!/usr/bin/env python3
import argparse
import shutil
import sys
ap = argparse.ArgumentParser()
ap.add_argument("source")
ap.add_argument("destination")
args = ap.parse_args()
with open(args.source) as inf:
with open(args.destination, "w") as outf:
first_line = inf.readline()
if first_line.startswith("#!"):
print("#!", sys.executable, file=outf)
else:
print("#!", sys.executable, file=outf)
outf.write(first_line)
for line in inf:
outf.write(line)
shutil.copymode(args.source, args.destination)