From ba20eb3d9b596cd5017249b839aaa75957cea59d Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Thu, 3 Aug 2006 16:33:37 +0000 Subject: added message bundle functionality (pyext.Bundle class) enable compiled-only scripts (without .py) small optimizations and fixes small changes for numpy support enable module packages (module/__init__.py[co]), now also for Max compiler flag to exclude DSP objects some ASSERTs for explicitly created pyext classes (should be runtime checks i guess) added pyext._list and pyext._tuple to convert input lists to Python sequence objects let _inlets and _outlets default to 0 svn path=/trunk/; revision=5472 --- externals/grill/py/build/config-lnx.def | 8 +++++--- externals/grill/py/build/config-mac.def | 6 ++++-- externals/grill/py/build/config-win.def | 6 ++++-- externals/grill/py/readme.txt | 12 ++++++----- externals/grill/py/source/modmeth.cpp | 36 ++++++++++++++++++++++++++++++--- externals/grill/py/source/pybase.h | 7 ++----- externals/grill/py/source/pybuffer.cpp | 2 +- 7 files changed, 56 insertions(+), 21 deletions(-) diff --git a/externals/grill/py/build/config-lnx.def b/externals/grill/py/build/config-lnx.def index e24f8b17..e19f03bc 100644 --- a/externals/grill/py/build/config-lnx.def +++ b/externals/grill/py/build/config-lnx.def @@ -2,8 +2,10 @@ PYTHONPREFIX=/usr # which Python version do you want to compile against? -PYTHONVERSION=2.3 +PYTHONVERSION=2.4 -# uncomment if numarray support should be compiled in -# for info about numarray see http://numeric.scipy.org +# uncomment if numpy/numarray/numeric support should be compiled in +# for info see http://numeric.scipy.org +PY_NUMPY=1 # PY_NUMARRAY=1 +# PY_NUMERIC=1 diff --git a/externals/grill/py/build/config-mac.def b/externals/grill/py/build/config-mac.def index 684c70b3..57f6e3d5 100644 --- a/externals/grill/py/build/config-mac.def +++ b/externals/grill/py/build/config-mac.def @@ -1,3 +1,5 @@ -# uncomment if numarray support should be compiled in -# for info about numarray see http://numeric.scipy.org +# uncomment if numpy/numarray/numeric support should be compiled in +# for info see http://numeric.scipy.org +PY_NUMPY=1 # PY_NUMARRAY=1 +# PY_NUMERIC=1 diff --git a/externals/grill/py/build/config-win.def b/externals/grill/py/build/config-win.def index 40ac5ff5..fee70e7b 100644 --- a/externals/grill/py/build/config-win.def +++ b/externals/grill/py/build/config-win.def @@ -4,6 +4,8 @@ PYTHONVER=24 # where is the Python installation? PYTHONPATH=%programfiles%/python$(PYTHONVER) -# uncomment if numarray support should be compiled in -# for info about numarray see http://numeric.scipy.org +# uncomment if numpy/numarray/numeric support should be compiled in +# for info see http://numeric.scipy.org +PY_NUMPY=1 # PY_NUMARRAY=1 +# PY_NUMERIC=1 diff --git a/externals/grill/py/readme.txt b/externals/grill/py/readme.txt index 9ebe521f..cba59e07 100644 --- a/externals/grill/py/readme.txt +++ b/externals/grill/py/readme.txt @@ -23,16 +23,18 @@ Check out the sample patches and scripts ---------------------------------------------------------------------------- -Installation: +INSTALLATION +============ PD version >= 0.38 - Add "py" to the Startup items ("binaries to load") and add the folder "scripts" to the pd search path. -PD version < 0.38 - Load it as i library with e.g. "pd -lib py -path scripts" +PD version < 0.38 - Load it as a library with e.g. "pd -lib py -path scripts" Max/MSP - Copy py-objectmappings.txt into the init folder and py.mxe (Windows) or py.mxo (OSX) into the externals folder. ---------------------------------------------------------------------------- -Description: +DESCRIPTION +=========== With the py object you can load python modules and execute the functions therein. With the pyext you can use python classes to represent full-featured pd/Max message objects. @@ -45,11 +47,12 @@ Known bugs: - With standard PD 0.37, threaded py scripts will cause "Stack overflows" under some circumstances -> use PD 0.38 or the devel_0_37 cvs branch instead - It has been reported that pyext crashes on AMD64 with SSE enabled (for these CPUs, disable the respective compiler flags) +- Threading in pyext obviously crashes under linux with Python version 2.4.2 (only) ---------------------------------------------------------------------------- BUILDING from source --------------------- +==================== You will need the flext C++ layer for PD and Max/MSP externals to compile this. See http://grrrr.org/ext/flext @@ -198,7 +201,6 @@ TODO list: bugs: - crashes with long Python printouts -- pybase::GetModulePath should also look for .pyc and .pyo general: - Documentation and better example patches diff --git a/externals/grill/py/source/modmeth.cpp b/externals/grill/py/source/modmeth.cpp index a611690f..3d44d99e 100644 --- a/externals/grill/py/source/modmeth.cpp +++ b/externals/grill/py/source/modmeth.cpp @@ -2,7 +2,7 @@ py/pyext - python external object for PD and Max/MSP -Copyright (c)2002-2005 Thomas Grill (gr@grrrr.org) +Copyright (c)2002-2006 Thomas Grill (gr@grrrr.org) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. @@ -27,11 +27,15 @@ PyMethodDef pybase::func_tbl[] = { "_getvalue", pybase::py_getvalue, METH_VARARGS,"Get value of a 'value' object" }, { "_setvalue", pybase::py_setvalue, METH_VARARGS,"Set value of a 'value' object" }, #endif - {NULL, NULL, 0, NULL} // sentinel + + { "_list", pybase::py_list, METH_VARARGS,"Make a list from arguments" }, + { "_tuple", pybase::py_tuple, METH_VARARGS,"Make a tuple from arguments" }, + + {NULL, NULL, 0, NULL} // sentinel }; const char *pybase::py_doc = - "py/pyext - python external object for PD and Max/MSP, (C)2002-2005 Thomas Grill\n" + "py/pyext - python external object for PD and Max/MSP, (C)2002-2006 Thomas Grill\n" "\n" "This is the pyext module. Available function:\n" "_send(args...): Send a message to a send symbol\n" @@ -42,6 +46,9 @@ const char *pybase::py_doc = "_blocksize(): Get current blocksize\n" "_getvalue(name): Get value of a 'value' object\n" "_setvalue(name,float): Set value of a 'value' object\n" + + "_list(args...): Make a list from args\n" + "_tuple(args...): Make a tuple from args\n" ; @@ -240,3 +247,26 @@ PyObject *pybase::py_setvalue(PyObject *self,PyObject *args) return Py_None; } #endif + +PyObject *pybase::py_list(PyObject *,PyObject *args) +{ + // should always be a tuple + FLEXT_ASSERT(PyTuple_Check(args)); + + const int sz = PyTuple_GET_SIZE(args); + PyObject *ret = PyList_New(sz); + for(int i = 0; i < sz; ++i) { + PyObject *el = PyTuple_GET_ITEM(args,i); + Py_INCREF(el); + PyList_SET_ITEM(ret,i,el); + } + return ret; +} + +PyObject *pybase::py_tuple(PyObject *,PyObject *args) +{ + // should always be a tuple + FLEXT_ASSERT(PyTuple_Check(args)); + Py_INCREF(args); + return args; +} diff --git a/externals/grill/py/source/pybase.h b/externals/grill/py/source/pybase.h index 6b661268..b5cc8220 100644 --- a/externals/grill/py/source/pybase.h +++ b/externals/grill/py/source/pybase.h @@ -119,11 +119,8 @@ protected: static PyObject *py_setvalue(PyObject *,PyObject *args); #endif -#ifdef PY_NUMARRAY - static void setupNumarray(); - static PyObject *py_import(PyObject *,PyObject *args); - static PyObject *py_export(PyObject *,PyObject *args); -#endif + static PyObject *py_list(PyObject *,PyObject *args); + static PyObject *py_tuple(PyObject *,PyObject *args); // ----thread stuff ------------ diff --git a/externals/grill/py/source/pybuffer.cpp b/externals/grill/py/source/pybuffer.cpp index afc35e45..15b64c6d 100644 --- a/externals/grill/py/source/pybuffer.cpp +++ b/externals/grill/py/source/pybuffer.cpp @@ -13,7 +13,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #undef PY_ARRAYS -#if defined(PY_NUMERIC) +#if defined(PY_NUMERIC) || defined(PY_NUMPY) #define PY_ARRAYS 1 #elif defined(PY_NUMARRAY) #define PY_ARRAYS 1 -- cgit v1.2.1