From 27b2b1aabb22af15c942a7ea7de4f836ee251fad Mon Sep 17 00:00:00 2001
From: Stefan <stefanbienert@me.com>
Date: Thu, 31 Oct 2013 22:14:18 +0100
Subject: [PATCH] Shorten module path, extended documentationsystem for autodoc

---
 cmake_support/PROMOD3.cmake     | 13 +++++++------
 doc/CMakeLists.txt              |  5 ++++-
 doc/conf.py.in                  |  3 ++-
 meld/CMakeLists.txt             |  1 +
 meld/tests/CMakeLists.txt       |  8 ++++++++
 meld/tests/test_raw_modeling.py | 12 ++++++------
 scripts/pm.in                   |  8 ++++----
 7 files changed, 32 insertions(+), 18 deletions(-)
 create mode 100644 meld/tests/CMakeLists.txt

diff --git a/cmake_support/PROMOD3.cmake b/cmake_support/PROMOD3.cmake
index 4715b551..1f625e8b 100644
--- a/cmake_support/PROMOD3.cmake
+++ b/cmake_support/PROMOD3.cmake
@@ -163,7 +163,7 @@ endmacro()
 #          [HEADER_OUTPUT_DIR dir]
 #          [LINK link_cmds])
 # Description:
-#   Define an OpenStructure module.
+#   Define a ProMod3 module.
 #-------------------------------------------------------------------------------
 macro(module)
   #-----------------------------------------------------------------------------
@@ -513,9 +513,9 @@ macro(pymod)
     return()
   endif()
   if (_ARG_OUTPUT_DIR)
-    set(PYMOD_DIR "python${PYTHON_VERSION}/site-packages/promod3/${_ARG_OUTPUT_DIR}")
+    set(PYMOD_DIR "python${PYTHON_VERSION}/site-packages/${_ARG_OUTPUT_DIR}")
   else()
-    set(PYMOD_DIR "python${PYTHON_VERSION}/site-packages/promod3/${_ARG_PREFIX}/${_ARG_NAME}")
+    set(PYMOD_DIR "python${PYTHON_VERSION}/site-packages/${_ARG_PREFIX}/${_ARG_NAME}")
   endif()
   set(PYMOD_STAGE_DIR "${LIB_STAGE_PATH}/${PYMOD_DIR}")
   file(MAKE_DIRECTORY ${PYMOD_STAGE_DIR})
@@ -691,7 +691,8 @@ macro(promod3_unittest)
       if(python_path)
         set(python_path "${python_path}:")
       endif(python_path)
-      set(python_path "${python_path}${LIB_STAGE_PATH}/python${PYTHON_VERSION}/site-packages")
+      # we just add OST manually here until we find a more flexible way
+      set(python_path "${python_path}${LIB_STAGE_PATH}/python${PYTHON_VERSION}/site-packages:${OST_ROOT}/lib/python${PYTHON_VERSION}/site-packages")
       set (PY_TESTS_CMD "PYTHONPATH=${python_path}  ${PYTHON_BINARY}")
       add_custom_target("${py_test}_run"
                 sh -c "${PY_TESTS_CMD} ${CMAKE_CURRENT_SOURCE_DIR}/${py_test} || echo"
@@ -701,8 +702,8 @@ macro(promod3_unittest)
                 sh -c "${PY_TESTS_CMD} ${CMAKE_CURRENT_SOURCE_DIR}/${py_test} xml || echo"
                 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                 COMMENT "running checks ${py_test}" VERBATIM)
-      add_dependencies("${py_test}_run_xml" promod3_scripts "_${_ARG_PREFIX}_${_ARG_MODULE}")
-      add_dependencies("${py_test}_run" promod3_scripts "_${_ARG_PREFIX}_${_ARG_MODULE}")
+      add_dependencies("${py_test}_run_xml" "_${_ARG_PREFIX}_${_ARG_MODULE}")
+      add_dependencies("${py_test}_run" "_${_ARG_PREFIX}_${_ARG_MODULE}")
       add_dependencies(check "${py_test}_run")
       add_dependencies(check_xml "${py_test}_run_xml")
       
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index e36c9cfe..1e924ad4 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -14,7 +14,10 @@ set(_SPHINX_CONF_PY "${_RST_SOURCE_DIR}/conf.py")
 set(_SPHINX_CONF_SUBST_DICT PROMOD3_VERSION_MAJOR="${PROMOD3_VERSION_MAJOR}"
                             PROMOD3_VERSION_MINOR="${PROMOD3_VERSION_MINOR}"
                             PROMOD3_VERSION_PATCH="${PROMOD3_VERSION_PATCH}"
-                            PYTHON_DOC_URL="${PYTHON_DOC_URL}")
+                            PYTHON_DOC_URL="${PYTHON_DOC_URL}"
+                            LIB_STAGE_PATH="${LIB_STAGE_PATH}"
+                            PYTHON_VERSION="${PYTHON_VERSION}"
+                            OST_ROOT="${OST_ROOT}")
 set(_CONF_SUBST_DICT -DINPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in -DOUT_FILE=${_SPHINX_CONF_PY})
 foreach(_subst ${_SPHINX_CONF_SUBST_DICT})
   list(APPEND _CONF_SUBST_DICT -D${_subst})
diff --git a/doc/conf.py.in b/doc/conf.py.in
index 3d502970..77d7836d 100644
--- a/doc/conf.py.in
+++ b/doc/conf.py.in
@@ -19,7 +19,8 @@ import sys, os
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.insert(0, os.path.abspath('.'))
+sys.path.insert(0, '@LIB_STAGE_PATH@/python@PYTHON_VERSION@/site-packages')
+sys.path.insert(1, '@OST_ROOT@/lib/python@PYTHON_VERSION@/site-packages')
 
 # -- General configuration -----------------------------------------------------
 
diff --git a/meld/CMakeLists.txt b/meld/CMakeLists.txt
index 842ebb33..3cc88cad 100644
--- a/meld/CMakeLists.txt
+++ b/meld/CMakeLists.txt
@@ -1,4 +1,5 @@
 add_subdirectory(src)
 add_subdirectory(pymod)
 add_subdirectory(data)
+add_subdirectory(tests)
 add_subdirectory(doc)
diff --git a/meld/tests/CMakeLists.txt b/meld/tests/CMakeLists.txt
new file mode 100644
index 00000000..d64ff2df
--- /dev/null
+++ b/meld/tests/CMakeLists.txt
@@ -0,0 +1,8 @@
+set(OST_BASE_UNIT_TESTS
+  test_raw_modeling.py
+)
+
+promod3_unittest(MODULE base 
+             SOURCES "${OST_BASE_UNIT_TESTS}"
+             LINK ost_mol)
+
diff --git a/meld/tests/test_raw_modeling.py b/meld/tests/test_raw_modeling.py
index a24350ff..797f94a7 100644
--- a/meld/tests/test_raw_modeling.py
+++ b/meld/tests/test_raw_modeling.py
@@ -1,6 +1,7 @@
-from sm.core import *
-from sm.core.test import *
-from sm.meld import *
+import unittest
+from promod3 import *
+from promod3.meld import *
+from ost import seq
 
 class RawModelingTests(unittest.TestCase):
   def testRaiseNoAttachedView(self):
@@ -86,6 +87,5 @@ class RawModelingTests(unittest.TestCase):
 
 
 if __name__ == "__main__":
-  run()
-
-
+  from ost import testutils
+  testutils.RunTests()
diff --git a/scripts/pm.in b/scripts/pm.in
index de48aca8..24908896 100755
--- a/scripts/pm.in
+++ b/scripts/pm.in
@@ -8,7 +8,7 @@ SCRIPT_NAME=$0
 BIN_DIR=$( cd `dirname "$SCRIPT_NAME"`; pwd)
 export PROMOD3_ROOT="$BIN_DIR/.."
 PROMOD3_EXEC_PATH="$PROMOD3_ROOT/libexec"
-export PYTHONPATH="${PROMOD3_ROOT}/@LIBDIR@/python@PYTHON_VERSION@/site-packages/promod3:${PYTHONPATH}"
+export PYTHONPATH="${PROMOD3_ROOT}/@LIBDIR@/python@PYTHON_VERSION@/site-packages:${PYTHONPATH}"
 export PATH="$BIN_DIR:@OST_ROOT@/bin:$PATH"
 export LD_LIBRARY_PATH="${PROMOD3_ROOT}/@LIBDIR@:$LD_LIBRARY_PATH"
 if [ -n "@QMEAN_ROOT@" ] ; then
@@ -17,9 +17,9 @@ fi
 
 if [ $# == 0 ] ; then
   echo "usage:"
-  echo "  promod3 <action>"
+  echo "  pm <action>"
   echo ""
-  echo "type promod3 help to get a list of commonly used actions"
+  echo "type pm help to get a list of commonly used actions"
   exit
 fi
 
@@ -36,5 +36,5 @@ fi
 case "$ACTION_BASENAME" in
   *.py ) ost "$ACTION" $@;;
   * ) echo "unknown action '${ACTION}'"
-  echo "type promod3 help to get started" ;;
+  echo "type pm help to get started" ;;
 esac
-- 
GitLab