From 723113b3b96a4aaec11001441cbd1d7c0c2a9027 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 5 Sep 2019 08:34:08 +0200 Subject: [PATCH] Add small shell script templates to simplify Python development --- CMakeLists.txt | 12 ++++++++++++ python/enable-python.sh.in | 5 +++++ python/setup-build.sh.in | 17 +++++++++++++++++ python/setup-test.sh.in | 17 +++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 python/enable-python.sh.in create mode 100644 python/setup-build.sh.in create mode 100644 python/setup-test.sh.in diff --git a/CMakeLists.txt b/CMakeLists.txt index ef99304f2..3fa022fd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -270,6 +270,18 @@ if (OPM_ENABLE_PYTHON) set_target_properties(opmcommon PROPERTIES POSITION_INDEPENDENT_CODE ON) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/python/python) + + configure_file(python/setup-build.sh.in tmp/setup-build.sh) + file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-build.sh + DESTINATION ${PROJECT_BINARY_DIR} + FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE ) + + configure_file(python/setup-test.sh.in tmp/setup-test.sh) + file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-test.sh + DESTINATION ${PROJECT_BINARY_DIR} + FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE ) + + configure_file(python/enable-python.sh.in enable-python.sh) endif() diff --git a/python/enable-python.sh.in b/python/enable-python.sh.in new file mode 100644 index 000000000..e6929ed39 --- /dev/null +++ b/python/enable-python.sh.in @@ -0,0 +1,5 @@ +#!/bin/bash + +export PYTHONPATH=@PROJECT_BINARY_DIR@/python/python:$PYTHONPATH +export LD_LIBRARY_PATH=@PROJECT_BINARY_DIR@/lib:@_setup_lib_dirs@:$LD_LIBRARY_PATH + diff --git a/python/setup-build.sh.in b/python/setup-build.sh.in new file mode 100644 index 000000000..b5e84c85b --- /dev/null +++ b/python/setup-build.sh.in @@ -0,0 +1,17 @@ +#!/bin/bash +# This cmake template file can be used to create a small shell script which can +# be used to simplify the Python development process. The cmake step will create +# script setup-build.sh from this templated file - that script can be used to +# run the python setup.py process without going through cmake. +# +# The script in question is purely a convenience for Python development, it is +# fully optional to use it, and it is not used by the main cmake based build +# system. + +cp -r @PROJECT_SOURCE_DIR@/python @PROJECT_BINARY_DIR@ +cd @PROJECT_BINARY_DIR@/python +rm -f python/opm/libopmcommon_python.so + +python setup.py build build_ext --build-lib=python/opm \ +--library-dirs=@_setup_lib_dirs@ \ +--include-dirs=@_setup_include_dirs@ diff --git a/python/setup-test.sh.in b/python/setup-test.sh.in new file mode 100644 index 000000000..265c78d17 --- /dev/null +++ b/python/setup-test.sh.in @@ -0,0 +1,17 @@ +#!/bin/bash +# This cmake template file can be used to create a small shell script which can +# be used to simplify the Python development process. The cmake step will create +# script setup-test.sh from this templated file - that script can be used to run +# the tests through the setup.py macinery without going through cmake/ctest. +# +# The script in question is purely a convenience for Python development, it is +# fully optional to use it, and it is not used by the main cmake based build +# system. + +cp -r @PROJECT_SOURCE_DIR@/python @PROJECT_BINARY_DIR@ +cd @PROJECT_BINARY_DIR@/python +export PYTHONPPATH=@PROJECT_BINARY_DIR@/python/python:$PYTHONPATH +export LD_LIBRARY_PATH=@PROJECT_BINARY_DIR@/lib:@_setup_lib_dirs@:$LD_LIBRARY_PATH + + +python setup.py build_ext --dry-run --build-lib=python/opm test