2009-12-24 19:27:15 +08:00
|
|
|
import py
|
2008-08-21 18:18:58 +08:00
|
|
|
|
2009-12-24 19:27:15 +08:00
|
|
|
bindir = py.path.local(__file__).dirpath().dirpath("bin")
|
2009-08-19 23:12:02 +08:00
|
|
|
assert bindir.check(), bindir
|
2008-08-21 18:18:58 +08:00
|
|
|
|
|
|
|
def getbasename(name):
|
|
|
|
assert name[:2] == "py"
|
|
|
|
return "py." + name[2:]
|
|
|
|
|
|
|
|
def genscript_unix(name):
|
|
|
|
basename = getbasename(name)
|
2009-08-19 23:12:02 +08:00
|
|
|
path = bindir.join(basename)
|
2008-08-21 18:18:58 +08:00
|
|
|
path.write(py.code.Source("""
|
|
|
|
#!/usr/bin/env python
|
|
|
|
from _findpy import py
|
|
|
|
py.cmdline.%s()
|
|
|
|
""" % name).strip())
|
|
|
|
path.chmod(0755)
|
|
|
|
|
|
|
|
def genscript_windows(name):
|
|
|
|
basename = getbasename(name)
|
|
|
|
winbasename = basename + ".cmd"
|
2009-08-19 23:12:02 +08:00
|
|
|
path = bindir.join("win32").join(winbasename)
|
2008-08-21 18:18:58 +08:00
|
|
|
path.write(py.code.Source("""
|
|
|
|
@echo off
|
|
|
|
python "%%~dp0\..\%s" %%*
|
|
|
|
""" % (basename)).strip())
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
for name in dir(py.cmdline):
|
|
|
|
if name[0] != "_":
|
|
|
|
genscript_unix(name)
|
|
|
|
genscript_windows(name)
|