no need to include tpt_console.py on 64bit anymore.

This commit is contained in:
Lieuwe 2011-03-15 19:18:31 +01:00
parent 59c0414ab4
commit 34051303cf
5 changed files with 50 additions and 23 deletions

Binary file not shown.

View File

@ -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"

View File

@ -68,7 +68,9 @@ extern unsigned char ZSIZE;
#define BRUSH_NUM 2
#define PYCONSOLE
//#define PYEXT //enable this on 64bit to prevent segfault
//#define PYEXT
//WARNING pyext must be defined on 64bit!
//also, don't add a comment on that line, it breaks.
#ifdef PIX16
typedef unsigned short pixel;

File diff suppressed because one or more lines are too long

View File

@ -27,10 +27,8 @@
#ifdef PYCONSOLE
#include "Python.h"
#ifndef PYEXT
#include "pyconsole.h"
#endif
#endif
#include <stdio.h>
#include <stdlib.h>
@ -2009,6 +2007,7 @@ int main(int argc, char *argv[])
PyRun_SimpleString("print 'python present.'");
//load the console module and whatnot
#ifdef PYEXT
PyRun_SimpleString(tpt_console_py);
printf("using external python console file.\n");
pname=PyString_FromString("tpt_console");//create string object
pmodule = PyImport_Import(pname);//import module