[cig-commits] [commit] master: Check for h5py (d709f75)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Dec 10 10:00:50 PST 2014


Repository : https://github.com/geodynamics/vq

On branch  : master
Link       : https://github.com/geodynamics/vq/compare/4d339b3a383b69e1552cfeef4ca20868a1377289...d0edc6ddd56f9105f6d2488db4a9f36368529695

>---------------------------------------------------------------

commit d709f75ab8134954b5cc355e554ed36cdb0e8594
Author: Eric Heien <emheien at ucdavis.edu>
Date:   Fri Dec 5 16:26:35 2014 -0800

    Check for h5py


>---------------------------------------------------------------

d709f75ab8134954b5cc355e554ed36cdb0e8594
 examples/CMakeLists.txt               | 12 +++++++++---
 quakelib/cmake/FindPythonModule.cmake | 25 +++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 0bca211..77464ba 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -11,6 +11,9 @@ SET(TAPER_METHODS none taper taper_renorm)
 SET(METHOD_MEANSLIP 100.4 0 0)
 SET(METHOD_INTEREVENT 49.2 0 0)
 
+INCLUDE(FindPythonModule)
+FIND_PYTHON_MODULE(h5py)
+
 # If MPI is available, set up MPI based tests as well
 IF(DEFINED MPI_C_FOUND AND MPI_CXX_FOUND)
     SET(NUM_PROCS 1 2 4)
@@ -209,9 +212,12 @@ IF (HDF5_FOUND)
             COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${NPROC} ${VQ_BINARY_DIR}/vq params_gen_${RES}.prm)
         SET_TESTS_PROPERTIES (run_gen_${TEST_SUFFIX} PROPERTIES DEPENDS param_run_${TEST_SUFFIX})
 
-        ADD_TEST(NAME check_${TEST_SUFFIX} WORKING_DIRECTORY ${TEST_DIR}
-            COMMAND ${PYTHON_EXECUTABLE} ${GREENS_SCRIPT} greens_3000.h5 6.93247959318e-08 -92400201.204)
-        SET_TESTS_PROPERTIES (check_${TEST_SUFFIX} PROPERTIES DEPENDS run_gen_${TEST_SUFFIX})
+        # If h5py is available, confirm the values in the Greens file sum to the correct value
+        IF(PY_H5PY)
+            ADD_TEST(NAME check_sum_${TEST_SUFFIX} WORKING_DIRECTORY ${TEST_DIR}
+                COMMAND ${PYTHON_EXECUTABLE} ${GREENS_SCRIPT} greens_3000.h5 6.93247959318e-08 -92400201.204)
+            SET_TESTS_PROPERTIES (check_sum_${TEST_SUFFIX} PROPERTIES DEPENDS run_gen_${TEST_SUFFIX})
+        ENDIF(PY_H5PY)
 
         # Test that the simulation runs with the resulting mesh
         ADD_TEST(NAME run_full_${TEST_SUFFIX} WORKING_DIRECTORY ${TEST_DIR}
diff --git a/quakelib/cmake/FindPythonModule.cmake b/quakelib/cmake/FindPythonModule.cmake
new file mode 100644
index 0000000..a024118
--- /dev/null
+++ b/quakelib/cmake/FindPythonModule.cmake
@@ -0,0 +1,25 @@
+# Find if a Python module is installed
+# Found at http://www.cmake.org/pipermail/cmake/2011-January/041666.html
+# To use do: find_python_module(PyQt4 REQUIRED)
+function(find_python_module module)
+	string(TOUPPER ${module} module_upper)
+	if(NOT PY_${module_upper})
+		if(ARGC GREATER 1 AND ARGV1 STREQUAL "REQUIRED")
+			set(${module}_FIND_REQUIRED TRUE)
+		endif()
+		# A module's location is usually a directory, but for binary modules
+		# it's a .so file.
+		execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" 
+			"import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))"
+			RESULT_VARIABLE _${module}_status 
+			OUTPUT_VARIABLE _${module}_location
+			ERROR_QUIET 
+			OUTPUT_STRIP_TRAILING_WHITESPACE)
+		if(NOT _${module}_status)
+			set(PY_${module_upper} ${_${module}_location} CACHE STRING 
+				"Location of Python module ${module}")
+		endif(NOT _${module}_status)
+	endif(NOT PY_${module_upper})
+	find_package_handle_standard_args(PY_${module} DEFAULT_MSG PY_${module_upper})
+endfunction(find_python_module)
+



More information about the CIG-COMMITS mailing list