diff --git a/.travis.yml b/.travis.yml index 083aaaa..44a3623 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ git: env: global: - OTB_URL=https://www.orfeo-toolbox.org/packages/archives/OTB -# - OTB_URL=https://www.orfeo-toolbox.org/packages/ci/latest - OTB_VER=7.0.0 + - LIS_DATA_ROOT=$HOME/Data-LIS matrix: include: @@ -16,41 +16,54 @@ matrix: compiler: gcc sudo: required before_install: + - python --version + - sudo update-alternatives --remove python /usr/bin/python2 + - sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10 + - python --version - sudo apt-get install -y ninja-build libglvnd-dev libglu1-mesa-dev + python3-lxml python3-numpy + python3-scipy + python3-matplotlib python3-dev + python3-setuptools + python3-gdal + gdal-bin + curl + - curl -k https://zenodo.org/record/166511/files/Data-LIS.tar.gz?download=1 -o $HOME/Data-LIS.tar.gz + - cd $HOME && tar -xf Data-LIS.tar.gz env: - OTB_OS=Linux64 - OTB_PKG_EXT=run - - os: osx - osx_image: xcode10.2 - compiler: clang - before_install: - - brew install ninja libomp git-lfs - env: - - OTB_OS=Darwin64 - - OTB_PKG_EXT=run - - os: windows - before_install: - - choco install python3 --params "/InstallDir:C:\Python3" - - choco install ninja - - export PATH="/c/Python3:/c/ProgramData/chocolatey/lib/ninja/tools:$PATH" - - /c/Python3/Scripts/pip install numpy - - eval "$(python vcvars_proxy.py - 'c:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat' - '-arch=amd64' - '-host_arch=amd64' - '-vcvars_ver=14.0')" - - export CC=cl.exe - - export CXX=cl.exe - - export CC_FOR_BUILD=cl.exe - - export CXX_FOR_BUILD=cl.exe - env: - - OTB_OS=Win64 - - OTB_PKG_EXT=zip + # - os: osx + # osx_image: xcode10.2 + # compiler: clang + # before_install: + # - brew install ninja libomp git-lfs + # env: + # - OTB_OS=Darwin64 + # - OTB_PKG_EXT=run + # - os: windows + # before_install: + # - choco install python3 --params "/InstallDir:C:\Python3" + # - choco install ninja + # - export PATH="/c/Python3:/c/ProgramData/chocolatey/lib/ninja/tools:$PATH" + # - /c/Python3/Scripts/pip install numpy matplotlib scipy lxml + # - eval "$(python vcvars_proxy.py + # 'c:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat' + # '-arch=amd64' + # '-host_arch=amd64' + # '-vcvars_ver=14.0')" + # - export CC=cl.exe + # - export CXX=cl.exe + # - export CC_FOR_BUILD=cl.exe + # - export CXX_FOR_BUILD=cl.exe + # env: + # - OTB_OS=Win64 + # - OTB_PKG_EXT=zip install: - export OTB_PKG="OTB-${OTB_VER}-${OTB_OS}.${OTB_PKG_EXT}" @@ -70,4 +83,4 @@ install: # - git lfs install script: - - ctest -VV -S ./ci.cmake + - cd $TRAVIS_BUILD_DIR && ctest -VV -S ./ci.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5931e4a..868552b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,6 @@ -cmake_minimum_required(VERSION 3.10.2) -project(LIS) - if(NOT OTB_SOURCE_DIR) + cmake_minimum_required(VERSION 3.10.2) + project(LIS) # Handle the compilation outside OTB source tree: find where OTB is built/installed find_package(OTB REQUIRED) list(APPEND CMAKE_MODULE_PATH ${OTB_CMAKE_DIR}) diff --git a/.ci/ci.cmake b/ci.cmake similarity index 94% rename from .ci/ci.cmake rename to ci.cmake index 77d72f2..bc04b24 100644 --- a/.ci/ci.cmake +++ b/ci.cmake @@ -3,10 +3,7 @@ set(REMOTE_MODULE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) set (ENV{LANG} "C") # Only ascii output -# Get project name -file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" _project_match REGEX "^project *\\(") -string(REGEX REPLACE "^project *\\( *([a-zA-Z0-9]+) *\\)" "\\1" otb-module ${_project_match}) - +message(FATAL) # Build Configuration : Release, Debug.. if(ci_build_type) set (CTEST_BUILD_CONFIGURATION ${ci_build_type}) @@ -25,7 +22,7 @@ else() set(ci_short_sha "$ENV{TRAVIS_COMMIT}") endif() -set(CTEST_PROJECT_NAME "${otb-module}") +set(CTEST_PROJECT_NAME "LIS") set(CTEST_DROP_METHOD "https") set(CTEST_DROP_SITE "cdash.orfeo-toolbox.org") set(CTEST_DROP_LOCATION "/submit.php?project=OTB") @@ -73,7 +70,8 @@ BUILD_TESTING:BOOL=ON OTB_BUILD_MODULE_AS_STANDALONE:BOOL=ON CMAKE_PREFIX_PATH:PATH=${REMOTE_MODULE_SOURCE_DIR}/xdk CMAKE_INSTALL_PREFIX:PATH=${CTEST_INSTALL_DIRECTORY} -CMAKE_BUILD_TYPE=${CTEST_BUILD_CONFIGURATION}") +CMAKE_BUILD_TYPE=${CTEST_BUILD_CONFIGURATION} +LIS_DATA_ROOT:STRING=$ENV{LIS_DATA_ROOT}") if(UNIX AND NOT APPLE) set(all_options @@ -147,9 +145,9 @@ ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" CAPTURE_CMAKE_ERROR _configure_error ) # Configure log -file ( WRITE +file ( WRITE "${REMOTE_MODULE_SOURCE_DIR}/log/configure_return_value_log.txt" "${_configure_rv}") -file ( WRITE +file ( WRITE "${REMOTE_MODULE_SOURCE_DIR}/log/configure_cmake_error_log.txt" "${_configure_error}") if ( NOT _configure_rv EQUAL 0 ) @@ -176,9 +174,9 @@ ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" CAPTURE_CMAKE_ERROR _build_error ) # Build log -file ( WRITE +file ( WRITE "${REMOTE_MODULE_SOURCE_DIR}/log/build_return_value_log.txt" "${_build_rv}") -file ( WRITE +file ( WRITE "${REMOTE_MODULE_SOURCE_DIR}/log/build_cmake_error_log.txt" "${_build_error}") if ( NOT _build_rv EQUAL 0 ) @@ -195,9 +193,9 @@ else() CAPTURE_CMAKE_ERROR _test_error ) # Test log - file ( WRITE + file ( WRITE "${REMOTE_MODULE_SOURCE_DIR}/log/test_return_value_log.txt" "${_test_rv}") - file ( WRITE + file ( WRITE "${REMOTE_MODULE_SOURCE_DIR}/log/test_cmake_error_log.txt" "${_test_error}") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 34b93d4..8443a74 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,27 @@ +set(${otb-module}_DEPENDS) +if(NOT PROJECT_NAME STREQUAL "LIS") + set(${otb-module}_DEPENDS OTBSWIGWrapper-all) +endif() + add_custom_target(${otb-module}-py - COMMAND ${CMAKE_COMMAND} -E echo "Building python scrips ${CMAKE_CURRENT_BINARY_DIR}/python/" COMMAND ${PYTHON_EXECUTABLE} setup.py build --build-base ${CMAKE_CURRENT_BINARY_DIR}/python WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python - DEPENDS OTBSWIGWrapper-all + DEPENDS ${${otb-module}_DEPENDS} ) + otb_module_target_label(${otb-module}-py) + +install(CODE " +message(STATUS \"Installing s2snow python package\") +execute_process(COMMAND ${PYTHON_EXECUTABLE} setup.py install + --single-version-externally-managed \ + --record ${CMAKE_CURRENT_BINARY_DIR}/python/setup_install.log + --home=${CMAKE_INSTALL_PREFIX} --install-purelib=${CMAKE_INSTALL_PREFIX}/${OTB_INSTALL_PYTHON_DIR} --install-scripts=bin + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python + RESULT_VARIABLE _install_rv + OUTPUT_VARIABLE _install_ov + ERROR_VARIABLE _install_ev) + if(NOT \${_install_rv} EQUAL 0) + message(FATAL_ERROR \"Failed to install s2snow(LIS) because \${_install_ov} \\n \${_install_ev} \") + endif() +") diff --git a/src/python/setup.py b/src/python/setup.py index 3b608bc..a4ca864 100644 --- a/src/python/setup.py +++ b/src/python/setup.py @@ -9,6 +9,7 @@ 'numpy>=1.11.0', 'scipy>=0.17.0', 'matplotlib>=1.5.1', + 'setuptools>=20.7.0' ] pkg_resources.require(dependencies) @@ -26,13 +27,5 @@ 'scripts/run_snow_annual_map.py', 'scripts/run_snow_detector.py', 'scripts/build_json.py' - ], - # entry_points={ - # 'console_scripts': [ - # 'lis_run_cloud_removal=run_cloud_removal:main', - # 'lis_run_snow_annual_map=run_snow_annual_map:main', - # 'lis_run_snow_detector=run_snow_detector:main', - # 'lis_build_json=build_json:main' - # ], - # }, + ] ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ec42a8d..01b3cf8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -50,8 +50,16 @@ add_lis_json_test( OUTPUT_PATH "s2-small" ) +if(NOT PROJECT_NAME STREQUAL "LIS") + get_filename_component(PKG_PREFIX "${OTB_LIBRARY_DIRS}" PATH) + set(OTB_PYTHONPATH ${PKG_PREFIX}/${OTB_INSTALL_PYTHON_DIR}) +else() + set(OTB_PYTHONPATH ${CMAKE_BINARY_DIR}/${OTB_INSTALL_PYTHON_DIR}) +endif() + + set(LIS_TEST_DRIVER otbTestDriver - --add-before-env PYTHONPATH ${CMAKE_BINARY_DIR}/${OTB_INSTALL_PYTHON_DIR}:${PYTHON_PATH_DIR}:$ENV{PYTHONPATH} + --add-before-env PYTHONPATH ${OTB_PYTHONPATH}:${PYTHON_PATH_DIR}:$ENV{PYTHONPATH} --add-before-env OTB_APPLICATION_PATH $ --add-before-env LD_LIBRARY_PATH $ --add-before-env PATH ${PYTHON_SCRIPTS_DIR}:$ENV{PATH} @@ -68,12 +76,12 @@ foreach(test_name s2-small take5 l8 s2) set_tests_properties(${test_name}_test PROPERTIES DEPENDS ${test_name}_test_json_builder_test) set_tests_properties(${test_name}_test PROPERTIES LABELS LIS) - set_tests_properties(${test_name}_test PROPERTIES - ENVIRONMENT - PYTHONPATH=${PYTHON_PATH_DIR}:${CMAKE_BINARY_DIR}/lib/otb/python:$ENV{PYTHONPATH} - LD_LIBRARY_PATH=$:$ENV{LD_LIBRARY_PATH} - OTB_APPLICATION_PATH=$ - ) + # set_tests_properties(${test_name}_test PROPERTIES + # ENVIRONMENT + # PYTHONPATH=${PYTHON_PATH_DIR}:${CMAKE_BINARY_DIR}/lib/otb/python:$ENV{PYTHONPATH} + # LD_LIBRARY_PATH=$:$ENV{LD_LIBRARY_PATH} + # OTB_APPLICATION_PATH=$ + # ) add_test(NAME ${test_name}_compare_pass1_test COMMAND gdalcompare.py @@ -163,32 +171,31 @@ add_test(NAME snow_annual_map_compare_test # add_test(NAME compare_preprocessing_output_test # COMMAND ${CMAKE_COMMAND} -E compare_files -# "${OUTPUT_TEST}/landsat_bassies_srtm.tif" +# "${OUTPUT_TEST}/landsat_bassies_srtm.tif" # "${BASELINE}/landsat_bassies_srtm.tif" # ) # set_tests_properties(compare_preprocessing_output_test PROPERTIES DEPENDS s2snow_test) #gdalcompare.py doesn't work on dbf files #COMMENT this test for now -#TODO find an other way to compare vector files to validate this part +#TODO find an other way to compare vector files to validate this part # add_test(NAME compare_final_mask_vec_output_test # COMMAND ${CMAKE_COMMAND} -E compare_files # "${BASELINE}/final_mask_vec_highcloud.dbf" -# "${OUTPUT_TEST_TAKE5}/final_mask_vec.dbf" +# "${OUTPUT_TEST_TAKE5}/final_mask_vec.dbf" # ) # set_tests_properties(compare_final_mask_vec_output_test PROPERTIES DEPENDS s2snow_test) # C++ function compute_snowline is deprecated -# FIXME add test with the application? +# FIXME add test with the application? # ADD_EXECUTABLE(histo_utils_snowline_test histo_utils_snowline_test.cxx) # TARGET_LINK_LIBRARIES(histo_utils_snowline_test histo_utils) -ADD_EXECUTABLE(histo_utils_snowline_internal_test histo_utils_snowline_internal_test.cxx) -TARGET_LINK_LIBRARIES(histo_utils_snowline_internal_test histo_utils) - -ADD_EXECUTABLE(histo_utils_snow_fraction_test histo_utils_snow_fraction_test.cxx) -TARGET_LINK_LIBRARIES(histo_utils_snow_fraction_test histo_utils) +ADD_EXECUTABLE(histo_utils_snowline_internal_test histo_utils_snowline_internal_test.cxx ../src/histo_utils.cxx) +TARGET_LINK_LIBRARIES(histo_utils_snowline_internal_test ${OTBCommon_LIBRARIES} ${OTBImageIO_LIBRARIES} ${OTBApplicationEngine_LIBRARIES} ${OTBITK_LIBRARIES}) +ADD_EXECUTABLE(histo_utils_snow_fraction_test histo_utils_snow_fraction_test.cxx ../src/histo_utils.cxx) +TARGET_LINK_LIBRARIES(histo_utils_snow_fraction_test ${OTBCommon_LIBRARIES} ${OTBImageIO_LIBRARIES} ${OTBApplicationEngine_LIBRARIES} ${OTBITK_LIBRARIES}) # C++ function compute_snowline is deprecated # add_test(NAME histo_utils_snowline_test # COMMAND ${CMAKE_BINARY_DIR}/bin/histo_utils_snowline_test @@ -268,13 +275,13 @@ add_test(NAME compute_cloud_mask_test ) add_test(NAME cloud_removal_step3_test - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cloud_removal_step3_test.py) + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cloud_removal_step3_test.py) add_test(NAME cloud_removal_step4_test COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cloud_removal_step4_test.py) -ADD_EXECUTABLE(itkUnaryCloudMaskImageFilterTest itkUnaryCloudMaskImageFilterTest.cxx) -TARGET_LINK_LIBRARIES(itkUnaryCloudMaskImageFilterTest histo_utils) +ADD_EXECUTABLE(itkUnaryCloudMaskImageFilterTest itkUnaryCloudMaskImageFilterTest.cxx ../src/histo_utils.cxx) +TARGET_LINK_LIBRARIES(itkUnaryCloudMaskImageFilterTest ${OTBCommon_LIBRARIES} ${OTBImageIO_LIBRARIES} ${OTBApplicationEngine_LIBRARIES} ${OTBITK_LIBRARIES}) add_test(NAME TvitkUnaryCloudMaskImageFilterTest COMMAND ${CMAKE_BINARY_DIR}/bin/itkUnaryCloudMaskImageFilterTest diff --git a/.ci/vcvars_proxy.py b/vcvars_proxy.py similarity index 100% rename from .ci/vcvars_proxy.py rename to vcvars_proxy.py