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
|
|
|
|
|
2011-03-15 13:18:31 -05:00
|
|
|
ext=False
|
2011-03-20 11:46:29 -05:00
|
|
|
"""#see if we're on 64bit.
|
2011-03-15 13:18:31 -05:00
|
|
|
with open("./includes/defines.h") as fid:
|
|
|
|
for line in fid:
|
|
|
|
if(line.startswith("#define") and line.count("PYEXT")>0):
|
|
|
|
print "using external console.py"
|
2011-03-20 11:46:29 -05:00
|
|
|
ext=True"""
|
2011-03-20 12:04:40 -05:00
|
|
|
#print sys.argv
|
2011-03-26 10:45:38 -05:00
|
|
|
if(len(sys.argv)>=2 and sys.argv[1]=="--ext"):
|
2011-03-20 11:46:29 -05:00
|
|
|
ext=True
|
2011-03-20 12:04:40 -05:00
|
|
|
print "YEAHS"
|
|
|
|
#raw_input("")
|
2011-03-03 13:33:48 -06:00
|
|
|
|
2011-03-15 13:18:31 -05:00
|
|
|
if(ext):
|
|
|
|
print "external"
|
2011-03-20 12:04:40 -05:00
|
|
|
#raw_input(sys.argv)
|
2011-03-15 13:18:31 -05:00
|
|
|
with open("./src/python/tpt_console.py") as fid:
|
|
|
|
consolepy=fid.read()
|
|
|
|
script="""
|
|
|
|
import tempfile,os.path,sys
|
|
|
|
dir=tempfile.gettempdir()
|
|
|
|
sys.path.append(dir)
|
|
|
|
tmp=%s
|
|
|
|
print "making console.py @ %%s"%%os.path.join(dir,"tpt_console.py")
|
|
|
|
with open(os.path.join(dir,"tpt_console.py"),"w") as fid:
|
|
|
|
fid.write(tmp)
|
|
|
|
"""%repr(consolepy)
|
|
|
|
tmp=[hex(ord(char)) for char in script]
|
|
|
|
out=["unsigned char tpt_console_py[] = {",','.join(tmp),"};"]
|
|
|
|
with open("./includes/pyconsole.h","w") as fid:
|
|
|
|
fid.write(''.join(out))
|
|
|
|
else:
|
|
|
|
print "internal"
|
2011-03-20 12:04:40 -05:00
|
|
|
#raw_input(sys.argv)
|
2011-03-15 13:18:31 -05:00
|
|
|
#unsigned char tpt_console_pyc[] = { 0x1B, 0x57};
|
|
|
|
lst=[]
|
2011-03-18 11:04:51 -05:00
|
|
|
compileall.compile_dir("./src/python", force=0)
|
2011-03-03 13:33:48 -06:00
|
|
|
|
2011-03-15 13:18:31 -05:00
|
|
|
print "generating pyconsole.h"
|
2011-03-03 13:33:48 -06:00
|
|
|
|
2011-03-15 13:18:31 -05: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():
|
|
|
|
lst.append(hex(ord(char)))
|
|
|
|
tmp=",".join(lst)
|
|
|
|
out=''.join(["#include <Python.h>\nunsigned char tpt_console_pyc[] = {",tmp,"};"])
|
|
|
|
with open("./includes/pyconsole.h","w") as fid:
|
|
|
|
fid.write(out)
|
2011-03-03 13:33:48 -06:00
|
|
|
print "done"
|