From: <hba...@us...> - 2010-07-16 18:28:44
|
Revision: 11090 http://plplot.svn.sourceforge.net/plplot/?rev=11090&view=rev Author: hbabcock Date: 2010-07-16 18:28:37 +0000 (Fri, 16 Jul 2010) Log Message: ----------- Apply Simon's patch to add plsmem support to the Python binding. Modify the Python build system to check for a recent enough version of swig and Python to build plsmem properly. Modified Paths: -------------- trunk/bindings/python/CMakeLists.txt trunk/bindings/python/Plframe.py trunk/bindings/swig-support/plplotcapi.i trunk/cmake/modules/python.cmake Modified: trunk/bindings/python/CMakeLists.txt =================================================================== --- trunk/bindings/python/CMakeLists.txt 2010-07-15 22:14:33 UTC (rev 11089) +++ trunk/bindings/python/CMakeLists.txt 2010-07-16 18:28:37 UTC (rev 11090) @@ -64,6 +64,10 @@ set(CMAKE_SWIG_FLAGS -DSWIG_PYTHON) endif(PL_DOUBLE) + if(PYTHON_HAVE_PYBUFFER) + set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DPYTHON_HAVE_PYBUFFER) + endif(PYTHON_HAVE_PYBUFFER) + set(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR}) set(SWIG_MODULE_plplotcmodule_EXTRA_DEPS Modified: trunk/bindings/python/Plframe.py =================================================================== --- trunk/bindings/python/Plframe.py 2010-07-15 22:14:33 UTC (rev 11089) +++ trunk/bindings/python/Plframe.py 2010-07-16 18:28:37 UTC (rev 11090) @@ -1249,6 +1249,9 @@ ## min_col, min_wid, max_col, max_wid, rect, ## pltr, xg, yg, wrap ) + def plsmem( ny, ny, plotmem ): + s.cmd('plsmem', nx, ny plotmem ) + def plssub( s, nx, ny ): s.cmd( 'plssub', nx, ny ) Modified: trunk/bindings/swig-support/plplotcapi.i =================================================================== --- trunk/bindings/swig-support/plplotcapi.i 2010-07-15 22:14:33 UTC (rev 11089) +++ trunk/bindings/swig-support/plplotcapi.i 2010-07-16 18:28:37 UTC (rev 11090) @@ -774,14 +774,15 @@ void plsmaj(PLFLT def, PLFLT scale); -#if 0 -/* plsmem not implemented because don't know how to make block -of memory available from python. */ -%feature("autodoc", "Set the memory area to be plotted (with the 'mem' -driver).") plsmem +#ifdef PYTHON_HAVE_PYBUFFER +%include <pybuffer.i> +%pybuffer_mutable_string(void * plotmem) + +%feature("autodoc", "Set the memory area to be plotted (with the 'mem' driver).") plsmem; void plsmem(PLINT maxx, PLINT maxy, void *plotmem); + #endif %feature("autodoc", "Set up lengths of minor tick marks.") plsmin; Modified: trunk/cmake/modules/python.cmake =================================================================== --- trunk/cmake/modules/python.cmake 2010-07-15 22:14:33 UTC (rev 11089) +++ trunk/cmake/modules/python.cmake 2010-07-16 18:28:37 UTC (rev 11090) @@ -156,4 +156,27 @@ OUTPUT_VARIABLE PYTHON_INSTDIR OUTPUT_STRIP_TRAILING_WHITESPACE ) + # Get the Python version. + execute_process( + COMMAND + ${PYTHON_EXECUTABLE} -c "import sys; print sys.version.split()[0]" + OUTPUT_VARIABLE PYTHON_version_output + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + SET(PYTHON_VERSION ${PYTHON_version_output} CACHE STRING "Python version") + + # Enable plsmem if the Python and Swig versions support it + transform_version(NUMERICAL_SWIG_MINIMUM_VERSION_FOR_PLSMEM "1.3.38") + transform_version(NUMERICAL_PYTHON_MINIMUM_VERSION_FOR_PLSMEM "2.6.0") + transform_version(NUMERICAL_SWIG_VERSION "${SWIG_VERSION}") + transform_version(NUMERICAL_PYTHON_VERSION "${PYTHON_version_output}") + + SET(PYTHON_HAVE_PYBUFFER OFF) + IF(NUMERICAL_SWIG_MINIMUM_VERSION_FOR_PLSMEM LESS NUMERICAL_SWIG_VERSION) + IF(NUMERICAL_PYTHON_MINIMUM_VERSION_FOR_PLSMEM LESS NUMERICAL_PYTHON_VERSION) + message(STATUS "Building Python binding with plsmem() support") + SET(PYTHON_HAVE_PYBUFFER ON) + ENDIF(NUMERICAL_PYTHON_MINIMUM_VERSION_FOR_PLSMEM LESS NUMERICAL_PYTHON_VERSION) + ENDIF(NUMERICAL_SWIG_MINIMUM_VERSION_FOR_PLSMEM LESS NUMERICAL_SWIG_VERSION) + endif(ENABLE_python) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |