1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import os, sys import re PY_DIR = os.path.dirname(sys.executable) MY_DIR = os.path.dirname(os.path.abspath(__file__)) pat = re.compile('^#!.*$', re.M) for f in os.listdir(MY_DIR): if not f.endswith('.py') or f.endswith('.pyw') or f == 'fixps.py': continue f = os.path.join(MY_DIR, f) src = open(f).read() src = pat.sub('#!"%s\python.exe"' % PY_DIR, src) fo = open(f, 'w') fo.write(src) fo.close() |