diff options
author | Daniil Kazantsev <dkazanc3@googlemail.com> | 2018-08-15 21:46:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-15 21:46:44 +0100 |
commit | ccc74f7906f77c0f4483dc549bf05d2567b288fb (patch) | |
tree | 156f47a438c518a670ff0e78a855ca9fe2489a07 /Wrappers/Python | |
parent | ae957063126a421ee0892eff18c44cf8b4e99042 (diff) | |
parent | 50739856921f8aeb980f790724b5117308bf9b0e (diff) | |
download | regularization-ccc74f7906f77c0f4483dc549bf05d2567b288fb.tar.gz regularization-ccc74f7906f77c0f4483dc549bf05d2567b288fb.tar.bz2 regularization-ccc74f7906f77c0f4483dc549bf05d2567b288fb.tar.xz regularization-ccc74f7906f77c0f4483dc549bf05d2567b288fb.zip |
Merge pull request #60 from vais-ral/cmaking
Cmaking
Diffstat (limited to 'Wrappers/Python')
-rw-r--r-- | Wrappers/Python/CMakeLists.txt | 122 | ||||
-rw-r--r-- | Wrappers/Python/conda-recipe/bld.bat | 15 | ||||
-rw-r--r-- | Wrappers/Python/conda-recipe/build.sh | 15 | ||||
-rw-r--r-- | Wrappers/Python/conda-recipe/meta.yaml | 6 | ||||
-rw-r--r-- | Wrappers/Python/setup-regularisers.py.in | 4 |
5 files changed, 115 insertions, 47 deletions
diff --git a/Wrappers/Python/CMakeLists.txt b/Wrappers/Python/CMakeLists.txt index fa1a30b..d86d0ea 100644 --- a/Wrappers/Python/CMakeLists.txt +++ b/Wrappers/Python/CMakeLists.txt @@ -6,7 +6,7 @@ project(regulariserPython) # The version number. -set (CIL_VERSION $ENV{CIL_VERSION} CACHE INTERNAL "Core Imaging Library version" FORCE) +#set (CIL_VERSION $ENV{CIL_VERSION} CACHE INTERNAL "Core Imaging Library version" FORCE) # conda orchestrated build message("CIL_VERSION ${CIL_VERSION}") @@ -41,31 +41,101 @@ elseif(UNIX) endif() # GPU regularisers - -find_package(CUDA) -if (CUDA_FOUND) - message("CUDA FOUND") - set (SETUP_GPU_WRAPPERS "extra_libraries += ['cilregcuda']\n\ +if (BUILD_CUDA) + find_package(CUDA) + if (CUDA_FOUND) + message("CUDA FOUND") + set (SETUP_GPU_WRAPPERS "extra_libraries += ['cilregcuda']\n\ setup( \n\ - name='ccpi', \n\ - description='CCPi Core Imaging Library - Image regularisers GPU',\n\ - version=cil_version,\n\ - cmdclass = {'build_ext': build_ext},\n\ - ext_modules = [Extension('ccpi.filters.gpu_regularisers',\n\ - sources=[ \n\ - os.path.join('.' , 'src', 'gpu_regularisers.pyx' ),\n\ - ],\n\ - include_dirs=extra_include_dirs, \n\ - library_dirs=extra_library_dirs, \n\ - extra_compile_args=extra_compile_args, \n\ - libraries=extra_libraries ), \n\ - ],\n\ - zip_safe = False, \n\ - packages = {'ccpi','ccpi.filters'},\n\ -)") -else() - message("CUDA NOT FOUND") - set(SETUP_GPU_WRAPPERS "#CUDA NOT FOUND") + name='ccpi', \n\ + description='CCPi Core Imaging Library - Image regularisers GPU',\n\ + version=cil_version,\n\ + cmdclass = {'build_ext': build_ext},\n\ + ext_modules = [Extension('ccpi.filters.gpu_regularisers',\n\ + sources=[ \n\ + os.path.join('.' , 'src', 'gpu_regularisers.pyx' ),\n\ + ],\n\ + include_dirs=extra_include_dirs, \n\ + library_dirs=extra_library_dirs, \n\ + extra_compile_args=extra_compile_args, \n\ + libraries=extra_libraries ), \n\ + ],\n\ + zip_safe = False, \n\ + packages = {'ccpi','ccpi.filters'},\n\ + )") + else() + message("CUDA NOT FOUND") + set(SETUP_GPU_WRAPPERS "#CUDA NOT FOUND") + endif() +endif() +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/setup-regularisers.py.in" "${CMAKE_CURRENT_BINARY_DIR}/setup-regularisers.py") + + +find_package(PythonInterp) +find_package(PythonLibs) +if (PYTHONINTERP_FOUND) + message(STATUS "Found PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}") + message(STATUS "Python version ${PYTHON_VERSION_STRING}") +endif() +if (PYTHONLIBS_FOUND) + message(STATUS "Found PYTHON_INCLUDE_DIRS=${PYTHON_INCLUDE_DIRS}") + message(STATUS "Found PYTHON_LIBRARIES=${PYTHON_LIBRARIES}") endif() -configure_file("setup-regularisers.py.in" "setup-regularisers.py") +if (PYTHONINTERP_FOUND) + message("Python found " ${PYTHON_EXECUTABLE}) + set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup-regularisers.py.in") + set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup-regularisers.py") + #set(DEPS "${CMAKE_CURRENT_SOURCE_DIR}/module/__init__.py") + set (DEPS "${CMAKE_BINARY_DIR}/Core/") + set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build/timestamp") + + configure_file(${SETUP_PY_IN} ${SETUP_PY}) + + message("Core binary dir " ${CMAKE_BINARY_DIR}/Core/${CMAKE_BUILD_TYPE}) + + if (CONDA_BUILD) + add_custom_command(OUTPUT ${OUTPUT} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/ccpi ${CMAKE_CURRENT_BINARY_DIR}/ccpi + COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION} + PREFIX=${CMAKE_SOURCE_DIR}/Core + LIBRARY_INC=${CMAKE_SOURCE_DIR}/Core + LIBRARY_LIB=${CMAKE_BINARY_DIR}/Core + ${PYTHON_EXECUTABLE} ${SETUP_PY} install + COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT} + DEPENDS cilreg) + + else() + if (WIN32) + add_custom_command(OUTPUT ${OUTPUT} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/ccpi ${CMAKE_CURRENT_BINARY_DIR}/ccpi + COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION} + PREFIX=${CMAKE_SOURCE_DIR}/Core + LIBRARY_INC=${CMAKE_SOURCE_DIR}/Core + LIBRARY_LIB=${CMAKE_BINARY_DIR}/Core/${CMAKE_BUILD_TYPE} + ${PYTHON_EXECUTABLE} ${SETUP_PY} build_ext --inplace + COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT} + DEPENDS cilreg) + else() + add_custom_command(OUTPUT ${OUTPUT} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/ccpi ${CMAKE_CURRENT_BINARY_DIR}/ccpi + COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION} + PREFIX=${CMAKE_SOURCE_DIR}/Core + LIBRARY_INC=${CMAKE_SOURCE_DIR}/Core + LIBRARY_LIB=${CMAKE_BINARY_DIR}/Core + ${PYTHON_EXECUTABLE} ${SETUP_PY} build_ext --inplace + COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT} + DEPENDS cilreg) + endif() + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ccpi + DESTINATION ${PYTHON_DEST}) + endif() + + + add_custom_target(PythonWrapper ALL DEPENDS ${OUTPUT}) + + #install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)") +endif() diff --git a/Wrappers/Python/conda-recipe/bld.bat b/Wrappers/Python/conda-recipe/bld.bat index e47f8d9..6c84355 100644 --- a/Wrappers/Python/conda-recipe/bld.bat +++ b/Wrappers/Python/conda-recipe/bld.bat @@ -6,12 +6,15 @@ exit 1 mkdir "%SRC_DIR%\ccpi" ROBOCOPY /E "%RECIPE_DIR%\..\.." "%SRC_DIR%\ccpi" ROBOCOPY /E "%RECIPE_DIR%\..\..\..\Core" "%SRC_DIR%\Core" -cd %SRC_DIR%\ccpi\Python +::cd %SRC_DIR%\ccpi\Python +cd %SRC_DIR% :: issue cmake to create setup.py -cmake . +cmake -G "NMake Makefiles" %RECIPE_DIR%\..\..\..\ -DBUILD_PYTHON_WRAPPERS=ON -DCONDA_BUILD=ON -DBUILD_CUDA=OFF -DCMAKE_BUILD_TYPE="Release" -DLIBRARY_LIB="%CONDA_PREFIX%\lib" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%PREFIX%\Library" -%PYTHON% setup-regularisers.py build_ext -if errorlevel 1 exit 1 -%PYTHON% setup-regularisers.py install -if errorlevel 1 exit 1 +::%PYTHON% setup-regularisers.py build_ext +::if errorlevel 1 exit 1 +::%PYTHON% setup-regularisers.py install +::if errorlevel 1 exit 1 +nmake install +if errorlevel 1 exit 1
\ No newline at end of file diff --git a/Wrappers/Python/conda-recipe/build.sh b/Wrappers/Python/conda-recipe/build.sh index 8b05663..54bc8e2 100644 --- a/Wrappers/Python/conda-recipe/build.sh +++ b/Wrappers/Python/conda-recipe/build.sh @@ -1,19 +1,16 @@ -if [ -z "$CIL_VERSION" ]; then - echo "Need to set CIL_VERSION" - exit 1 -fi mkdir "$SRC_DIR/ccpi" cp -rv "$RECIPE_DIR/../.." "$SRC_DIR/ccpi" cp -rv "$RECIPE_DIR/../../../Core" "$SRC_DIR/Core" -cd $SRC_DIR/ccpi/Python +cd $SRC_DIR -echo "$SRC_DIR/ccpi/Python" +cmake -G "Unix Makefiles" $RECIPE_DIR/../../../ -DBUILD_PYTHON_WRAPPER=ON -DCONDA_BUILD=ON -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE="Release" -DLIBRARY_LIB=$CONDA_PREFIX/lib -DLIBRARY_INC=$CONDA_PREFIX -DCMAKE_INSTALL_PREFIX=$PREFIX -cmake . -$PYTHON setup-regularisers.py build_ext -$PYTHON setup-regularisers.py install +make install + +#$PYTHON setup-regularisers.py build_ext +#$PYTHON setup-regularisers.py install diff --git a/Wrappers/Python/conda-recipe/meta.yaml b/Wrappers/Python/conda-recipe/meta.yaml index ca28bae..9286cc4 100644 --- a/Wrappers/Python/conda-recipe/meta.yaml +++ b/Wrappers/Python/conda-recipe/meta.yaml @@ -1,12 +1,10 @@ package: name: ccpi-regulariser - version: {{ environ['CIL_VERSION'] }} + version: 0.10.1 build: preserve_egg_dir: False - script_env: - - CIL_VERSION # number: 0 test: @@ -21,7 +19,6 @@ requirements: - numpy x.x - setuptools - cython - - cil_regulariser =={{ environ['CIL_VERSION'] }} - vc 14 # [win and py36] - vc 14 # [win and py35] - vc 9 # [win and py27] @@ -30,7 +27,6 @@ requirements: run: - python - numpy x.x - - cil_regulariser =={{ environ['CIL_VERSION'] }} - vc 14 # [win and py36] - vc 14 # [win and py35] - vc 9 # [win and py27] diff --git a/Wrappers/Python/setup-regularisers.py.in b/Wrappers/Python/setup-regularisers.py.in index 7108683..542dcb4 100644 --- a/Wrappers/Python/setup-regularisers.py.in +++ b/Wrappers/Python/setup-regularisers.py.in @@ -27,11 +27,13 @@ except: extra_include_dirs = [numpy.get_include(), library_include_path] #extra_library_dirs = [os.path.join(library_include_path, "..", "lib")] extra_compile_args = [] -extra_library_dirs = [] +extra_library_dirs = [library_lib_path] extra_compile_args = [] extra_link_args = [] extra_libraries = ['cilreg'] +print ("extra_library_dirs " , extra_library_dirs) + extra_include_dirs += [os.path.join(".." , ".." , "Core"), os.path.join(".." , ".." , "Core", "regularisers_CPU"), os.path.join(".." , ".." , "Core", "inpainters_CPU"), |