From: Timothy S. <pe...@us...> - 2004-11-30 08:00:43
|
Update of /cvsroot/pyode/pyode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26895 Modified Files: INSTALL MANIFEST.in setup.py Added Files: ode_notrimesh.c ode_trimesh.c Log Message: Modified setup.py to distribute ode_trimesh.c and ode_notrimesh.c instead of just ode.c to allow the user to disable trimesh without having to download pyrex. Index: MANIFEST.in =================================================================== RCS file: /cvsroot/pyode/pyode/MANIFEST.in,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MANIFEST.in 16 Nov 2004 06:19:48 -0000 1.1 --- MANIFEST.in 30 Nov 2004 08:00:24 -0000 1.2 *************** *** 5,8 **** --- 5,10 ---- include LICENSE-BSD include ChangeLog + include ode_trimesh.c + include ode_notrimesh.c recursive-include src *.pyx recursive-include examples *.py Index: setup.py =================================================================== RCS file: /cvsroot/pyode/pyode/setup.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** setup.py 16 Nov 2004 19:50:02 -0000 1.7 --- setup.py 30 Nov 2004 08:00:25 -0000 1.8 *************** *** 3,7 **** ###################################################################### ! # ODE itself must already be compiled from distutils.core import setup, Extension --- 3,15 ---- ###################################################################### ! # Note: ODE itself must already be compiled ! ! # Set to the base of your ODE installation. ! #ODE_BASE = '../ode' ! ! # Set to True or False to force trimesh support to be enabled or disabled. ! #TRIMESH_SUPPORT_OVERRIDE = True ! ! ###################################################################### from distutils.core import setup, Extension *************** *** 10,21 **** from stat import * - # Should the wrapper support trimesh geoms? - TRIMESH_SUPPORT = True - # Windows? if sys.platform=="win32": ! ! ODE_BASE = "../ode_single_trimesh" ! # ODE_BASE = "../ode_double_notrimesh" INC_DIRS = [os.path.join(ODE_BASE, "include")] --- 18,29 ---- from stat import * # Windows? if sys.platform=="win32": ! ! try: ! base = ODE_BASE ! except NameError: ! ODE_BASE = "../ode_single_trimesh" ! #ODE_BASE = "../ode_double_notrimesh" INC_DIRS = [os.path.join(ODE_BASE, "include")] *************** *** 27,31 **** else: ! ODE_BASE = "../ode" INC_DIRS = [os.path.join(ODE_BASE, "include")] --- 35,42 ---- else: ! try: ! base = ODE_BASE ! except NameError: ! ODE_BASE = "../ode" INC_DIRS = [os.path.join(ODE_BASE, "include")] *************** *** 36,61 **** ###################################################################### ! def determinePrecision(): filename = os.path.normpath(os.path.join(ODE_BASE, "config", "user-settings")) ! print 'Reading "%s" to determine precision...'%filename ! precision = None try: ! for s in file(filename): ! s = s.strip() ! a = s.split("=") ! if len(a)==2 and a[0].upper()=="PRECISION": ! precision = a[1] except IOError, e: ! print "ERROR:",e raise RuntimeError ! if precision==None: ! print "ERROR: No precision setting found." ! raise RuntimeError ! if precision not in ["SINGLE", "DOUBLE"]: ! print 'ERROR: Invalid precision setting: "%s"'%precision ! raise RuntimeError ! ! return precision ###################################################################### --- 47,81 ---- ###################################################################### ! def readODEConfig(): ! config = {} ! filename = os.path.normpath(os.path.join(ODE_BASE, "config", "user-settings")) ! print 'Reading ODE configuration "%s"...' % filename ! try: ! f = file(filename) except IOError, e: ! print "ERROR:", e raise RuntimeError + + for line in f.readlines(): + s = line.strip() ! # remove comments ! i = s.find('#') ! if (i != -1): ! s = s[:i] ! ! if (s == ''): ! continue ! ! s = s.upper() ! ! a = s.split('=') ! if (len(a) == 2): ! k, v = a ! config[k] = v ! ! return config ###################################################################### *************** *** 77,80 **** --- 97,144 ---- # sys.exit() + + + + # Generate the C source file (if necessary) + def generate(name, trimesh_support): + # Generate the trimesh_switch file + + f = file("_trimesh_switch.pyx", "wt") + print >>f, '# This file was generated by the setup script and is included in ode.pyx.\n' + if (trimesh_support): + print >>f, 'include "trimeshdata.pyx"' + print >>f, 'include "trimesh.pyx"' + else: + print >>f, 'include "trimesh_dummy.pyx"' + f.close() + + cmd = "pyrexc -o %s -I. -Isrc src/ode.pyx" % name + pyrex_out = name + + # Check if the pyrex output is still up to date or if it has to be generated + # (ode.c will be updated if any of the *.pyx files in the directory "src" + # is newer than ode.c) + if os.access(pyrex_out, os.F_OK): + ctime = os.stat(pyrex_out)[ST_MTIME] + for pyx in glob.glob("src/*.pyx"): + pytime = os.stat(pyx)[ST_MTIME] + if pytime>ctime: + print "Updating",pyrex_out + print cmd + err = os.system(cmd) + break + else: + print pyrex_out,"is up to date" + err = 0 + else: + print "Creating",pyrex_out + print cmd + err = os.system(cmd) + + # Check if calling pyrex produced an error + if err!=0: + print "An error occured while generating the C source file." + sys.exit(err) + # Check if the ODE_BASE path does exist if not os.path.exists(ODE_BASE): *************** *** 87,130 **** sys.exit() ! # Generate the trimesh_switch file ! f = file("_trimesh_switch.pyx", "wt") ! print >>f, '# This file was generated by the setup script and is included in ode.pyx.\n' ! if TRIMESH_SUPPORT: ! print >>f, 'include "trimeshdata.pyx"' ! print >>f, 'include "trimesh.pyx"' ! else: ! print >>f, 'include "trimesh_dummy.pyx"' ! f.close() ! # Generate the C source file (if necessary) ! cmd = "pyrexc -o ode.c -I. -Isrc src/ode.pyx" ! pyrex_out = "ode.c" ! # Check if the pyrex output is still up to date or if it has to be generated ! # (ode.c will be updated if any of the *.pyx files in the directory "src" ! # is newer than ode.c) ! if os.access(pyrex_out, os.F_OK): ! ctime = os.stat(pyrex_out)[ST_MTIME] ! for pyx in glob.glob("src/*.pyx"): ! pytime = os.stat(pyx)[ST_MTIME] ! if pytime>ctime: ! print "Updating",pyrex_out ! print cmd ! err = os.system(cmd) ! break ! else: ! print pyrex_out,"is up to date" ! err = 0 else: ! print "Creating",pyrex_out ! print cmd ! err = os.system(cmd) ! ! # Check if calling pyrex produced an error ! if err!=0: ! print "An error occured while generating the C source file." ! sys.exit(err) ! # Compile the module --- 151,170 ---- sys.exit() ! config = readODEConfig() + generate('ode_trimesh.c', True) + generate('ode_notrimesh.c', False) ! try: ! wrap_trimesh = TRIMESH_SUPPORT_OVERRIDE ! except NameError, e: ! wrap_trimesh = config.get('OPCODE_DIRECTORY', '') ! if (wrap_trimesh): ! print "Installing with trimesh support." ! install = 'ode_trimesh.c' else: ! print "Installing without trimesh support." ! install = 'ode_notrimesh.c' # Compile the module *************** *** 137,141 **** url = "http://pyode.sourceforge.net/", packages = ["xode"], ! ext_modules = [Extension("ode", ["ode.c"] ,libraries=LIBS ,include_dirs=INC_DIRS --- 177,181 ---- url = "http://pyode.sourceforge.net/", packages = ["xode"], ! ext_modules = [Extension("ode", [install] ,libraries=LIBS ,include_dirs=INC_DIRS --- NEW FILE: ode_notrimesh.c --- /* Generated by Pyrex 0.9.2.1 on Sun Nov 28 08:35:22 2004 */ #include "Python.h" #include "structmember.h" #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #include "stdlib.h" #include "stdio.h" #include "ode/ode.h" typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ static PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/ static int __Pyx_EndUnpack(PyObject *, int); /*proto*/ static int __Pyx_PrintItem(PyObject *); /*proto*/ static int __Pyx_PrintNewline(void); /*proto*/ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ [...18108 lines suppressed...] empty_string /*PyObject *lnotab*/ ); if (!py_code) goto bad; py_frame = PyFrame_New( PyThreadState_Get(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ py_globals, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = __pyx_lineno; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); Py_XDECREF(empty_tuple); Py_XDECREF(empty_string); Py_XDECREF(py_code); Py_XDECREF(py_frame); } Index: INSTALL =================================================================== RCS file: /cvsroot/pyode/pyode/INSTALL,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** INSTALL 29 Jul 2004 20:17:13 -0000 1.3 --- INSTALL 30 Nov 2004 08:00:21 -0000 1.4 *************** *** 8,17 **** http://www.python.org/ - - Pyrex 0.9.3 (or higher) - http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/ - - ODE 0.5 http://ode.org/ Installation: --- 8,18 ---- http://www.python.org/ - ODE 0.5 http://ode.org/ + - Pyrex 0.9.3 (or higher) + http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/ + This is only required for PyODE development; you don't need it to install + and run PyODE. Installation: *************** *** 38,44 **** system. ! ODE can either be compiled with or without trimesh support. If you disabled ! trimesh support you also have to disable it in this wrapper. You do that ! by setting the variable TRIMESH_SUPPORT to False in the setup script. ! In that case the TriMeshData and GeomTriMesh classes will still be there ! but they will raise a NotImplementedError exception in their constructor. --- 39,47 ---- system. ! ODE can either be compiled with or without trimesh support. The setup script ! checks your ODE user-settings file to determine whether is is supported. If ! trimesh support disabled, PyODE's TriMeshData and GeomTriMesh classes will ! still be there but they will raise a NotImplementedError exception in their ! constructor. If you want to force PyODE to install with trimesh support ! regardless of your ODE user-settings, uncomment the variable ! TRIMESH_SUPPORT_OVERRIDE in setup.py. \ No newline at end of file --- NEW FILE: ode_trimesh.c --- /* Generated by Pyrex 0.9.2.1 on Sun Nov 28 08:35:18 2004 */ #include "Python.h" #include "structmember.h" #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #include "stdlib.h" #include "stdio.h" #include "ode/ode.h" typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ static PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/ static int __Pyx_EndUnpack(PyObject *, int); /*proto*/ static int __Pyx_PrintItem(PyObject *); /*proto*/ static int __Pyx_PrintNewline(void); /*proto*/ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ [...18634 lines suppressed...] empty_string /*PyObject *lnotab*/ ); if (!py_code) goto bad; py_frame = PyFrame_New( PyThreadState_Get(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ py_globals, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = __pyx_lineno; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); Py_XDECREF(empty_tuple); Py_XDECREF(empty_string); Py_XDECREF(py_code); Py_XDECREF(py_frame); } |