diff options
| author | Lieuwe <lieuwemo@gmail.com> | 2011-03-15 18:18:31 (GMT) |
|---|---|---|
| committer | Lieuwe <lieuwemo@gmail.com> | 2011-03-15 18:18:31 (GMT) |
| commit | 34051303cf888f7bd815f0686df9462bbf037d6d (patch) | |
| tree | 71c8f3a1a26ee7c66656998b7ff957afc4fbe30d /getheader.py | |
| parent | 59c0414ab4fa1751c0f014b3b8f6d705c5ad4e0b (diff) | |
| download | powder-34051303cf888f7bd815f0686df9462bbf037d6d.zip powder-34051303cf888f7bd815f0686df9462bbf037d6d.tar.gz | |
no need to include tpt_console.py on 64bit anymore.
Diffstat (limited to 'getheader.py')
| -rw-r--r-- | getheader.py | 63 |
1 files changed, 45 insertions, 18 deletions
diff --git a/getheader.py b/getheader.py index 43b20ec..dbe99ee 100644 --- a/getheader.py +++ b/getheader.py @@ -13,26 +13,53 @@ args="-lpython%s -lm -L%s"%(sys.version[:3],os.path.join(sys.exec_prefix,"lib"," print "\n windows args are" print args,"-I%s"%path -#unsigned char tpt_console_pyc[] = { 0x1B, 0x57}; -lst=[] -compileall.compile_dir("./src/python", force=1) +ext=False +#see if we're on 64bit. +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" + ext=True -print "generating pyconsole.h" +if(ext): + print "external" + 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" + #unsigned char tpt_console_pyc[] = { 0x1B, 0x57}; + lst=[] + compileall.compile_dir("./src/python", force=1) -fname="./src/python/tpt_console.pyc" -try: - fid=open(fname,"r") -except IOError: - fname="./src/python/tpt_console.pyo" -finally: - fid.close() + print "generating pyconsole.h" -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) + 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) print "done"
\ No newline at end of file |
