test_ok1/bin-for-dist/genscripts.py

36 lines
900 B
Python
Raw Normal View History

from _findpy import py
2009-08-19 23:12:02 +08:00
bindir = py.magic.autopath().dirpath().dirpath("py").join("bin")
assert bindir.check(), bindir
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)
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)
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)