summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdoardo Pasca <edo.paskino@gmail.com>2017-10-23 14:47:43 +0100
committerEdoardo Pasca <edo.paskino@gmail.com>2017-10-23 14:47:43 +0100
commit99b106a2ced10136a2a71b42440d8c1ffa4f8d2c (patch)
tree8004f5a1981805fbdb657913bac610333d806632
parent808167b9a333e5f351d39c8a791104c1b7a08aab (diff)
downloadregularization-99b106a2ced10136a2a71b42440d8c1ffa4f8d2c.tar.gz
regularization-99b106a2ced10136a2a71b42440d8c1ffa4f8d2c.tar.bz2
regularization-99b106a2ced10136a2a71b42440d8c1ffa4f8d2c.tar.xz
regularization-99b106a2ced10136a2a71b42440d8c1ffa4f8d2c.zip
Bugfixes for UNIX compilation
-rw-r--r--src/Python/CMakeLists.txt93
-rw-r--r--src/Python/FindAnacondaEnvironment.cmake41
-rw-r--r--src/Python/compile.sh.in2
3 files changed, 52 insertions, 84 deletions
diff --git a/src/Python/CMakeLists.txt b/src/Python/CMakeLists.txt
index 707f006..e539eda 100644
--- a/src/Python/CMakeLists.txt
+++ b/src/Python/CMakeLists.txt
@@ -25,73 +25,52 @@ set (NUMPY_VERSION 1.12)
#https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/R9gWjl09UFs
#set (CONDA_ENVIRONMENT "cil")
+## Tries to parse the output of conda env list to determine the current
+## active conda environment
execute_process(COMMAND "conda" "env" "list"
OUTPUT_VARIABLE _CONDA_ENVS
RESULT_VARIABLE _CONDA_RESULT
ERROR_VARIABLE _CONDA_ERR)
if(NOT _CONDA_RESULT)
- #message("conda envs list " ${_CONDA_ENVS})
string(REPLACE "\n" ";" ENV_LIST ${_CONDA_ENVS})
- #string(REGEX MATCHALL "^.*[\t\n]" matches ${_CONDA_ENVS})
foreach(line ${ENV_LIST})
- message("line='${line}'")
string(REGEX MATCHALL "(.+)[*](.+)" match ${line})
- #list(LENGTH ${match} N)
- #string(LENGTH ${match} Ns)
- #string(REPLACE "*" ";" env_dir )
- #message("list length " ${N} " string length " ${Ns})
- #list(GET ${env_dir} 0 CONDA_ENVIRONMENT)
- #list(GET ${env_dir} 1 CONDA_PATH)
if (NOT ${match} EQUAL "")
- message("match='${match}'")
- string(REPLACE "*" ";" ENV_DIR ${match})
- #string(MATCHALL "(.*)[*](.*)" ENV_DIR ${match})
- list (APPEND cc "")
- foreach(conda ${ENV_DIR})
- message("THERE YOU ARE " ${conda})
- list(APPEND cc ${conda})
- endforeach()
- list(LENGTH cc Ns)
- message("cc " ${cc} " " ${Ns})
- if (${Ns} EQUAL 2)
- list(GET cc 0 CONDA_ENVIRONMENT)
- list(GET cc 1 CONDA_ENVIRONMENT_PATH)
- message("Current conda environmnet " ${CONDA_ENVIRONMENT})
- message("Current conda environmnet path" ${CONDA_ENVIRONMENT_PATH})
-
- endif()
-
- #list(GET ${env_dir} 0 CONDA_ENVIRONMENT)
- #list(GET ${env_dir} 1 CONDA_PATH)
- #message("******" ${env_dir})
- #message("******" ${CONDA_ENVIRONMENT} " " ${CONDA_PATH} )
+ string(REPLACE "*" ";" ENV_DIR ${match})
+ list (APPEND cc "")
+ foreach(conda ${ENV_DIR})
+ string(STRIP ${conda} stripped)
+ list(APPEND cc ${stripped})
+ endforeach()
+ list(LENGTH cc Ns)
+ if (${Ns} EQUAL 2)
+ list(GET cc 0 CONDA_ENVIRONMENT)
+ list(GET cc 1 CONDA_ENVIRONMENT_PATH)
+ endif()
endif()
endforeach()
- #string(REGEX REPLACE "^.*[*].*" "" CONDA_ENVIRONMENT ${_CONDA_ENVS})
else()
message("conda result false" ${_CONDA_ERR})
endif()
-message("**********************************************************")
-message("Current conda environmnet " ${CONDA_ENVIRONMENT})
-message("Current conda environmnet path" ${CONDA_ENVIRONMENT_PATH})
-
-if (WIN32)
- set (CONDA_ENVIRONMENT_PATH "C:\\Apps\\Miniconda2\\envs\\${CONDA_ENVIRONMENT}" CACHE PATH "Main environment directory")
- set (CONDA_ENVIRONMENT_PREFIX "${CONDA_ENVIRONMENT_PATH}\\Library" CACHE PATH "env dir")
- set (CONDA_ENVIRONMENT_LIBRARY_INC "${CONDA_ENVIRONMENT_PREFIX}\\include" CACHE PATH "env dir")
-elseif (UNIX)
- set (CONDA_ENVIRONMENT_PATH "/apps/anaconda/2.4/envs/${CONDA_ENVIRONMENT}" CACHE PATH "Main environment directory")
- set (CONDA_ENVIRONMENT_PREFIX "${CONDA_ENVIRONMENT_PATH}" CACHE PATH "env dir")
- set (CONDA_ENVIRONMENT_LIBRARY_INC "${CONDA_ENVIRONMENT_PREFIX}/include" CACHE PATH "env dir")
+if (${CONDA_ENVIRONMENT} AND ${CONDA_ENVIRONMENT_PATH})
+ message (FATAL_ERROR "CONDA NOT FOUND")
+else()
+ message("**********************************************************")
+ message("Using current conda environmnet " ${CONDA_ENVIRONMENT})
+ message("Using current conda environmnet path" ${CONDA_ENVIRONMENT_PATH})
endif()
+
+
message("CIL VERSION " ${CIL_VERSION})
# set the Python variables for the Conda environment
include(FindAnacondaEnvironment.cmake)
findPythonForAnacondaEnvironment(${CONDA_ENVIRONMENT_PATH})
message("Python found " ${PYTHON_VERSION_STRING})
+message("Python found Major " ${PYTHON_VERSION_MAJOR})
+message("Python found Minor " ${PYTHON_VERSION_MINOR})
findPythonPackagesPath()
message("PYTHON_PACKAGES_FOUND " ${PYTHON_PACKAGES_PATH})
@@ -101,6 +80,15 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ccpi/__init__.py DESTINATION ${CMAKE_CURRE
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ccpi/imaging/__init__.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ccpi/imaging)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ccpi/imaging/Regularizer.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ccpi/imaging)
+if (WIN32)
+ #set (CONDA_ENVIRONMENT_PATH "C:\\Apps\\Miniconda2\\envs\\${CONDA_ENVIRONMENT}" CACHE PATH "Main environment directory")
+ set (CONDA_ENVIRONMENT_PREFIX "${CONDA_ENVIRONMENT_PATH}\\Library" CACHE PATH "env dir")
+ set (CONDA_ENVIRONMENT_LIBRARY_INC "${CONDA_ENVIRONMENT_PREFIX}\\include" CACHE PATH "env dir")
+elseif (UNIX)
+ #set (CONDA_ENVIRONMENT_PATH "/apps/anaconda/2.4/envs/${CONDA_ENVIRONMENT}" CACHE PATH "Main environment directory")
+ set (CONDA_ENVIRONMENT_PREFIX "${CONDA_ENVIRONMENT_PATH}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" CACHE PATH "env dir")
+ set (CONDA_ENVIRONMENT_LIBRARY_INC "${CONDA_ENVIRONMENT_PREFIX}/include" CACHE PATH "env dir")
+endif()
# Copy and configure the relative conda build and recipes
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
@@ -111,6 +99,7 @@ if (WIN32)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/conda-recipe/bld.bat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/conda-recipe/)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/compile.bat.in ${CMAKE_CURRENT_BINARY_DIR}/compile.bat)
elseif(UNIX)
+ message ("We are on UNIX")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/conda-recipe/build.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/conda-recipe/)
# assumes we will use bash
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/compile.sh.in ${CMAKE_CURRENT_BINARY_DIR}/compile.sh)
@@ -119,11 +108,11 @@ endif()
### add tests
#add_executable(RegularizersTest )
-find_package(tiff)
-if (TIFF_FOUND)
- message("LibTIFF Found")
- message("TIFF_INCLUDE_DIR " ${TIFF_INCLUDE_DIR})
- message("TIFF_LIBRARIES" ${TIFF_LIBRARIES})
-else()
- message("LibTIFF not found")
-endif()
+#find_package(tiff)
+#if (TIFF_FOUND)
+# message("LibTIFF Found")
+# message("TIFF_INCLUDE_DIR " ${TIFF_INCLUDE_DIR})
+# message("TIFF_LIBRARIES" ${TIFF_LIBRARIES})
+#else()
+# message("LibTIFF not found")
+#endif()
diff --git a/src/Python/FindAnacondaEnvironment.cmake b/src/Python/FindAnacondaEnvironment.cmake
index 6d91dba..fa4637a 100644
--- a/src/Python/FindAnacondaEnvironment.cmake
+++ b/src/Python/FindAnacondaEnvironment.cmake
@@ -36,14 +36,14 @@
function (findPythonForAnacondaEnvironment env)
- set (EXE "")
if (WIN32)
- set (EXE ".exe")
+ file(TO_CMAKE_PATH ${env}/python.exe PYTHON_EXECUTABLE)
+ elseif (UNIX)
+ file(TO_CMAKE_PATH ${env}/bin/python PYTHON_EXECUTABLE)
endif()
- file(TO_CMAKE_PATH ${env}/python${EXE} PYTHON_EXECUTABLE)
- message("Found " ${PYTHON_EXECUTABLE})
+ message("findPythonForAnacondaEnvironment Found Python Executable" ${PYTHON_EXECUTABLE})
####### FROM FindPythonInterpr ########
# determine python version string
if(PYTHON_EXECUTABLE)
@@ -133,37 +133,16 @@ endif()
function(findPythonPackagesPath)
-### https://openlab.ncl.ac.uk/gitlab/john.shearer/clappertracker/raw/549885e5decd37f7b23e9c1fd39e86f207156795/src/3rdparty/opencv/cmake/OpenCVDetectPython.cmake
-###
-if(CMAKE_HOST_UNIX)
- execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_python_lib()"
+ 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)
- if("${PYTHON_STD_PACKAGES_PATH}" MATCHES "site-packages")
+ #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")
- else() #debian based assumed, install to the dist-packages.
- set(_PYTHON_PACKAGES_PATH "python${PYTHON_VERSION_MAJOR_MINOR}/dist-packages")
- endif()
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${PYTHON_PACKAGES_PATH}")
- set(_PYTHON_PACKAGES_PATH "lib${LIB_SUFFIX}/${_PYTHON_PACKAGES_PATH}")
- else()
- set(_PYTHON_PACKAGES_PATH "lib/${_PYTHON_PACKAGES_PATH}")
- endif()
- elseif(CMAKE_HOST_WIN32)
- get_filename_component(PYTHON_PATH "${PYTHON_EXECUTABLE}" PATH)
- file(TO_CMAKE_PATH "${PYTHON_PATH}" PYTHON_PATH)
- if(NOT EXISTS "${PYTHON_PATH}/Lib/site-packages")
- unset(PYTHON_PATH)
- get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE)
- if(NOT PYTHON_PATH)
- get_filename_component(PYTHON_PATH "[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE)
- endif()
- file(TO_CMAKE_PATH "${PYTHON_PATH}" PYTHON_PATH)
- endif()
- set(_PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages")
- endif()
- SET(PYTHON_PACKAGES_PATH "${_PYTHON_PACKAGES_PATH}" PARENT_SCOPE)
+ endif()
+
+ SET(PYTHON_PACKAGES_PATH "${PYTHON_STD_PACKAGES_PATH}" PARENT_SCOPE)
endfunction()
diff --git a/src/Python/compile.sh.in b/src/Python/compile.sh.in
index ca9f310..93fdba2 100644
--- a/src/Python/compile.sh.in
+++ b/src/Python/compile.sh.in
@@ -6,4 +6,4 @@
export CIL_VERSION=@CIL_VERSION@
export LIBRARY_INC=@CONDA_ENVIRONMENT_LIBRARY_INC@
-conda build conda-recipe --python=@PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@ --numpy=@NUMPY_VERSION@ -c ccpi \ No newline at end of file
+conda build conda-recipe --python=@PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@ --numpy=@NUMPY_VERSION@ -c ccpi