summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorTomas Kulhanek <tomas.kulhanek@stfc.ac.uk>2019-02-28 16:24:01 +0000
committerGitHub <noreply@github.com>2019-02-28 16:24:01 +0000
commit879c87c5709ee194a8c7a2207f5a21d4a757f723 (patch)
treeeddf7bc14a998ffabc7e9e01f0cca2ac44b1d88a /build
parent4c728cf72345f7ab7967380cb536529fd9b1403d (diff)
parent68e6f3397e8a450854f39a5d514e1f747b9031a4 (diff)
downloadregularization-879c87c5709ee194a8c7a2207f5a21d4a757f723.tar.gz
regularization-879c87c5709ee194a8c7a2207f5a21d4a757f723.tar.bz2
regularization-879c87c5709ee194a8c7a2207f5a21d4a757f723.tar.xz
regularization-879c87c5709ee194a8c7a2207f5a21d4a757f723.zip
Merge pull request #104 from vais-ral/newdirstructure
New directory structure, Merged other changes. The build script checks old and new structure.
Diffstat (limited to 'build')
-rw-r--r--build/FindAnacondaEnvironment.cmake154
-rwxr-xr-xbuild/build-install.sh4
-rw-r--r--build/run.sh22
3 files changed, 180 insertions, 0 deletions
diff --git a/build/FindAnacondaEnvironment.cmake b/build/FindAnacondaEnvironment.cmake
new file mode 100644
index 0000000..6475128
--- /dev/null
+++ b/build/FindAnacondaEnvironment.cmake
@@ -0,0 +1,154 @@
+# Copyright 2017 Edoardo Pasca
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# #.rst:
+# FindAnacondaEnvironment
+# --------------
+#
+# Find Python executable and library for a specific Anaconda environment
+#
+# This module finds the Python interpreter for a specific Anaconda enviroment,
+# if installed and determines where the include files and libraries are.
+# This code sets the following variables:
+#
+# ::
+# PYTHONINTERP_FOUND - if the Python interpret has been found
+# PYTHON_EXECUTABLE - the Python interpret found
+# PYTHON_LIBRARY - path to the python library
+# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated)
+# PYTHON_INCLUDE_DIRS - path to where Python.h is found
+# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8)
+# PYTHON_VERSION_MAJOR - major Python version
+# PYTHON_VERSION_MINOR - minor Python version
+# PYTHON_VERSION_PATCH - patch Python version
+
+
+
+function (findPythonForAnacondaEnvironment env)
+ if (WIN32)
+ file(TO_CMAKE_PATH ${env}/python.exe PYTHON_EXECUTABLE)
+ elseif (UNIX)
+ file(TO_CMAKE_PATH ${env}/bin/python PYTHON_EXECUTABLE)
+ endif()
+
+
+ message("findPythonForAnacondaEnvironment Found Python Executable" ${PYTHON_EXECUTABLE})
+ ####### FROM FindPythonInterpr ########
+ # determine python version string
+ if(PYTHON_EXECUTABLE)
+ execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c
+ "import sys; sys.stdout.write(';'.join([str(x) for x in sys.version_info[:3]]))"
+ OUTPUT_VARIABLE _VERSION
+ RESULT_VARIABLE _PYTHON_VERSION_RESULT
+ ERROR_QUIET)
+ if(NOT _PYTHON_VERSION_RESULT)
+ string(REPLACE ";" "." _PYTHON_VERSION_STRING "${_VERSION}")
+ list(GET _VERSION 0 _PYTHON_VERSION_MAJOR)
+ list(GET _VERSION 1 _PYTHON_VERSION_MINOR)
+ list(GET _VERSION 2 _PYTHON_VERSION_PATCH)
+ if(PYTHON_VERSION_PATCH EQUAL 0)
+ # it's called "Python 2.7", not "2.7.0"
+ string(REGEX REPLACE "\\.0$" "" _PYTHON_VERSION_STRING "${PYTHON_VERSION_STRING}")
+ endif()
+ else()
+ # sys.version predates sys.version_info, so use that
+ execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.version)"
+ OUTPUT_VARIABLE _VERSION
+ RESULT_VARIABLE _PYTHON_VERSION_RESULT
+ ERROR_QUIET)
+ if(NOT _PYTHON_VERSION_RESULT)
+ string(REGEX REPLACE " .*" "" _PYTHON_VERSION_STRING "${_VERSION}")
+ string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" _PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}")
+ string(REGEX REPLACE "^[0-9]+\\.([0-9])+.*" "\\1" _PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}")
+ if(PYTHON_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.([0-9]+)")
+ set(PYTHON_VERSION_PATCH "${CMAKE_MATCH_1}")
+ else()
+ set(PYTHON_VERSION_PATCH "0")
+ endif()
+ else()
+ # sys.version was first documented for Python 1.5, so assume
+ # this is older.
+ set(PYTHON_VERSION_STRING "1.4" PARENT_SCOPE)
+ set(PYTHON_VERSION_MAJOR "1" PARENT_SCOPE)
+ set(PYTHON_VERSION_MINOR "4" PARENT_SCOPE)
+ set(PYTHON_VERSION_PATCH "0" PARENT_SCOPE)
+ endif()
+ endif()
+ unset(_PYTHON_VERSION_RESULT)
+ unset(_VERSION)
+ endif()
+ ###############################################
+
+ set (PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} PARENT_SCOPE)
+ set (PYTHONINTERP_FOUND "ON" PARENT_SCOPE)
+ set (PYTHON_VERSION_STRING ${_PYTHON_VERSION_STRING} PARENT_SCOPE)
+ set (PYTHON_VERSION_MAJOR ${_PYTHON_VERSION_MAJOR} PARENT_SCOPE)
+ set (PYTHON_VERSION_MINOR ${_PYTHON_VERSION_MINOR} PARENT_SCOPE)
+ set (PYTHON_VERSION_PATCH ${_PYTHON_VERSION_PATCH} PARENT_SCOPE)
+ message("My version found " ${PYTHON_VERSION_STRING})
+ ## find conda executable
+ if (WIN32)
+ set (CONDA_EXECUTABLE ${env}/Script/conda PARENT_SCOPE)
+ elseif(UNIX)
+ set (CONDA_EXECUTABLE ${env}/bin/conda PARENT_SCOPE)
+ endif()
+endfunction()
+
+
+
+set(Python_ADDITIONAL_VERSIONS 3.5)
+
+find_package(PythonInterp)
+if (PYTHONINTERP_FOUND)
+
+ message("Found interpret " ${PYTHON_EXECUTABLE})
+ message("Python Library " ${PYTHON_LIBRARY})
+ message("Python Include Dir " ${PYTHON_INCLUDE_DIR})
+ message("Python Include Path " ${PYTHON_INCLUDE_PATH})
+
+ foreach(pv ${PYTHON_VERSION_STRING})
+ message("Found interpret " ${pv})
+ endforeach()
+endif()
+
+
+
+find_package(PythonLibs)
+if (PYTHONLIB_FOUND)
+ message("Found PythonLibs PYTHON_LIBRARIES " ${PYTHON_LIBRARIES})
+ message("Found PythonLibs PYTHON_INCLUDE_PATH " ${PYTHON_INCLUDE_PATH})
+ message("Found PythonLibs PYTHON_INCLUDE_DIRS " ${PYTHON_INCLUDE_DIRS})
+ message("Found PythonLibs PYTHONLIBS_VERSION_STRING " ${PYTHONLIBS_VERSION_STRING} )
+else()
+ message("No PythonLibs Found")
+endif()
+
+
+
+
+function(findPythonPackagesPath)
+ execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print (get_python_lib())"
+ RESULT_VARIABLE PYTHON_CVPY_PROCESS
+ OUTPUT_VARIABLE PYTHON_STD_PACKAGES_PATH
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ #message("STD_PACKAGES " ${PYTHON_STD_PACKAGES_PATH})
+ if("${PYTHON_STD_PACKAGES_PATH}" MATCHES "site-packages")
+ set(_PYTHON_PACKAGES_PATH "python${PYTHON_VERSION_MAJOR_MINOR}/site-packages")
+ endif()
+
+ SET(PYTHON_PACKAGES_PATH "${PYTHON_STD_PACKAGES_PATH}" PARENT_SCOPE)
+
+endfunction()
+
+
diff --git a/build/build-install.sh b/build/build-install.sh
new file mode 100755
index 0000000..def66a4
--- /dev/null
+++ b/build/build-install.sh
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+export CCPI_BUILD_ARGS="--numpy 1.12 --python 3.6"
+bash <(curl -L https://raw.githubusercontent.com/vais-ral/CCPi-VirtualMachine/master/scripts/jenkins-build.sh)
+conda install -y ccpi-regulariser --use-local --force \ No newline at end of file
diff --git a/build/run.sh b/build/run.sh
new file mode 100644
index 0000000..332d660
--- /dev/null
+++ b/build/run.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+echo "Building CCPi-regularisation Toolkit using CMake"
+rm -r build
+# Requires Cython, install it first:
+# pip install cython
+mkdir build
+cd build/
+make clean
+# install Python modules without CUDA
+#cmake ../ -DBUILD_PYTHON_WRAPPER=ON -DBUILD_MATLAB_WRAPPER=OFF -DBUILD_CUDA=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./install
+# install Python modules with CUDA
+# cmake ../ -DBUILD_PYTHON_WRAPPER=ON -DBUILD_MATLAB_WRAPPER=OFF -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./install
+# install Matlab modules with CUDA
+cmake ../ -DBUILD_PYTHON_WRAPPER=OFF -DMatlab_ROOT_DIR=/dls_sw/apps/matlab/r2014a/ -DBUILD_MATLAB_WRAPPER=ON -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./install
+make install
+# cp install/lib/libcilreg.so install/python/ccpi/filters
+#cd install/python
+#export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../lib
+# spyder
+# one can also run Matlab in Linux as:
+#PATH="/path/to/mex/:$PATH" LD_LIBRARY_PATH="/path/to/library:$LD_LIBRARY_PATH" matlab
+PATH="/home/kjy41806/Documents/SOFT/CCPi-Regularisation-Toolkit/build/install/matlab/:$PATH" LD_LIBRARY_PATH="/home/kjy41806/Documents/SOFT/CCPi-Regularisation-Toolkit/build/install/lib:$LD_LIBRARY_PATH" matlab