2011-02-26 04:49:23 -06:00
|
|
|
import sys
|
|
|
|
import os.path
|
2011-03-03 13:33:48 -06:00
|
|
|
import compileall
|
2011-02-26 04:49:23 -06:00
|
|
|
path=os.path.join(sys.exec_prefix,"include","python%s"%sys.version[:3])
|
|
|
|
#print "headers at ",repr(path)
|
|
|
|
#-lpython2.3 -lm -L/usr/lib/python2.3/config
|
|
|
|
args="-lpython%s -lm -L%s"%(sys.version[:3],os.path.join(sys.exec_prefix,"lib","python%s"%sys.version[:3],"config"))
|
|
|
|
print " linux args are"
|
|
|
|
print args,"-I%s"%path
|
|
|
|
|
|
|
|
path=os.path.join(sys.exec_prefix,"include")
|
|
|
|
args="-lpython%s -lm -L%s"%(sys.version[:3],os.path.join(sys.exec_prefix,"lib","config"))#,"python%s"%sys.version[:3]
|
|
|
|
print "\n windows args are"
|
2011-03-03 13:33:48 -06:00
|
|
|
print args,"-I%s"%path
|
|
|
|
|
|
|
|
#unsigned char tpt_console_pyc[] = { 0x1B, 0x57};
|
|
|
|
lst=[]
|
|
|
|
compileall.compile_dir("./src/python", force=1)
|
|
|
|
|
2011-03-05 08:09:15 -06:00
|
|
|
print "generating pyconsole.h"
|
2011-03-03 13:33:48 -06:00
|
|
|
|
|
|
|
fname="./src/python/tpt_console.pyc"
|
|
|
|
try:
|
|
|
|
fid=open(fname,"r")
|
|
|
|
except IOError:
|
|
|
|
fname="./src/python/tpt_console.pyo"
|
|
|
|
finally:
|
|
|
|
fid.close()
|
|
|
|
|
|
|
|
with open(fname,"r") as fid:
|
|
|
|
for char in fid.read():
|
2011-03-03 14:12:57 -06:00
|
|
|
lst.append(hex(ord(char)))
|
2011-03-03 13:33:48 -06:00
|
|
|
tmp=",".join(lst)
|
2011-03-03 14:12:57 -06:00
|
|
|
out=''.join(["#include <Python.h>\nunsigned char tpt_console_pyc[] = {",tmp,"};"])
|
2011-03-03 13:33:48 -06:00
|
|
|
with open("./includes/pyconsole.h","w") as fid:
|
|
|
|
fid.write(out)
|
|
|
|
print "done"
|