Created
June 28, 2009 13:04
-
-
Save gvx/137261 to your computer and use it in GitHub Desktop.
A Python script to enable #! for Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
import sys | |
import subprocess | |
f = open (sys.argv[1], "r") | |
r = f.readline()[:-1] | |
f.close() | |
special = { | |
#for example: | |
#'python2.6': "C:\\Python26\\python.exe", | |
#'python3.1': "C:\\Python31\\python.exe", | |
} | |
if r.startswith("#!"): | |
r = r[2:].strip() | |
if r in special: | |
line = special[r] | |
else: | |
line = r | |
subprocess.call([line] + sys.argv[1:]) | |
else: | |
sys.exit("Could not execute: file does not start with shebang.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment