Commit b154b9b4 authored by Antoine Regimbeau's avatar Antoine Regimbeau

Merge branch 'drop_python2' into 'develop'

Drop python2

See merge request !352
parents 735a69d9 b22c7c22
......@@ -63,7 +63,6 @@ set(CTEST_CUSTOM_COVERAGE_EXCLUDE
# Exclude SWIG wrappers files
".*/Modules/Wrappers/SWIG/src/python/otbApplicationPYTHON_wrap.*"
".*/Modules/Wrappers/SWIG/src/python3/otbApplicationPYTHON_wrap.*"
".*/Modules/Wrappers/SWIG/src/java/otbApplicationJAVA_wrap.*"
# Exclude Qt moc file
......
......@@ -26,7 +26,6 @@
# python is needed to verify the presence of the module name in the doxygen header
# Don't require it to not force the developers to install python to be able to build
# OTB. The tests will simply not be run if python is not available.
find_package(PythonInterp)
macro( otb_module_doxygen _name )
......
......@@ -26,7 +26,6 @@
# This does not force the developer to install python to be able to build OTB.
# The tests will simply not be run if python is unavailable.
find_package(PythonInterp)
# The maximum number of headers in a test. This helps limit memory issues,
# and the cppcheck tests. However, if this is not unity, there is a slight
......
......@@ -100,6 +100,19 @@ reset_qt_i18n_sources()
repository_status(${PROJECT_SOURCE_DIR} OTB_GIT_STATUS_MESSAGE)
# Find python stuff
# Version 3 is prefered before 2
set ( Python_ADDITIONAL_VERSIONS "3;2" )
set ( PythonInterp_FIND_REQUIRED ${OTB_WRAP_PYTHON} )
set ( PythonLibs_FIND_REQUIRED ${OTB_WRAP_PYTHON} )
find_package( PythonInterp )
if ( OTB_WRAP_PYTHON AND ( ${PYTHON_VERSION_MAJOR} EQUAL 2 ) )
message (WARNING "Python3 not found. There is no longer support of \
wrapping in python2 in OTB, but it can still be used.")
endif()
set (Python_ADDITIONAL_VERSIONS "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
find_package ( PythonLibs )
#-----------------------------------------------------------------------------
# Configure the default OTB_DATA_ROOT for the location of OTB Data.
find_path(OTB_DATA_ROOT
......@@ -152,9 +165,6 @@ endif()
if(NOT OTB_INSTALL_PYTHON_DIR)
set(OTB_INSTALL_PYTHON_DIR "${OTB_INSTALL_LIBRARY_DIR}/otb/python")
endif()
if(NOT OTB_INSTALL_PYTHON3_DIR)
set(OTB_INSTALL_PYTHON3_DIR "${OTB_INSTALL_LIBRARY_DIR}/otb/python3")
endif()
if(NOT OTB_INSTALL_JAVA_DIR)
set(OTB_INSTALL_JAVA_DIR "${OTB_INSTALL_LIBRARY_DIR}/otb/java")
endif()
......@@ -339,6 +349,7 @@ set(OTB_CONFIG_CODE "
set(OTB_MODULES_DIR \"${OTB_MODULES_DIR}\")")
set(OTB_CONFIG_CMAKE_DIR "${OTB_SOURCE_DIR}/CMake")
set(OTB_USE_FILE "${OTB_CONFIG_CMAKE_DIR}/UseOTB.cmake")
if(OTB_WRAP_PYTHON)
set(OTB_CONFIG_CODE "${OTB_CONFIG_CODE}
set(OTB_PYTHONPATH \"${OTB_BINARY_DIR}/${OTB_INSTALL_PYTHON_DIR}\")")
......@@ -366,10 +377,12 @@ set(OTB_CONFIG_CODE "${OTB_CONFIG_CODE}
set(OTB_MODULES_DIR \"\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}/Modules\")")
set(OTB_USE_FILE "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}/UseOTB.cmake")
set(OTB_CONFIG_CMAKE_DIR "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}")
if(OTB_WRAP_PYTHON)
set(OTB_CONFIG_CODE "${OTB_CONFIG_CODE}
set(OTB_PYTHONPATH \"\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PYTHON_DIR}\")")
endif()
set(OTB_CONFIG_APPLICATION_PATH "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_APP_DIR}")
set(OTB_CONFIG_TARGETS_CONDITION "")
set(OTB_CONFIG_TARGETS_FILE "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}/OTBTargets.cmake")
......
......@@ -66,9 +66,9 @@ foreach(cmd
endforeach()
# We need to set PYTHONPATH for the script otbGenerateWrappersRstDoc.py, depending on how the Python3 module was built
if (OTB_WRAP_PYTHON3)
set(PYTHONPATH_COOKBOOK "${CMAKE_BINARY_DIR}/lib/otb/python3")
elseif (OTB_WRAP_PYTHON)
if (OTB_WRAP_PYTHON)
set(PYTHONPATH_COOKBOOK "${CMAKE_BINARY_DIR}/lib/otb/python")
else()
# Cookbook only supports Python3
# But OTB_WRAP_PYTHON can wrap both python2 and python3
if (${PYTHONLIBS_VERSION_STRING} STRGREATER "3.0.0")
......
......@@ -84,23 +84,20 @@ necessary to install one of the following packages:
Python bindings
~~~~~~~~~~~~~~~
Starting from OTB 5.8.0, OTB bindings for Python 2.7 are distributed as a binary
package. With OTB 6.4.0, additional bindings for Python 3.5 are also included.
Since OTB 6.7.0 OTB bindings for Python 3.5 are distributed as a binary
package.
Please note that using a different Python version may not be compatible with
OTB wrappings. If no compatible Python 2.x version is found a
notification is generated during the installation process. If the installation completes
OTB wrappings. If the installation completes
without issue, information relating to your Python bindings will be provided.
You must have Python NumPy bindings installed in your system. They can be installed locally
without admin rights as follows: "pip install --user numpy". This is to give users the option
to select their own existing Python installation rather than the one distributed by the OTB package.
to select their own existing Python installation rather than the one dibstributed by the OTB package.
By default, bindings for Python 2.7 will be enabled with the ``otbenv`` script.
If you want to use bindings for Python 3.5, you can copy this script and modify:
- ``lib/python`` into ``lib/python3``, for variable PYTHONPATH
By default, bindings for Python 3.5 will be enabled with the ``otbenv`` script.
Notes:
~~~~~~
- You must use monteverdi and mapla through ``mapla.sh`` and ``monteverdi.sh`` helper scripts in extracted directory.
......
......@@ -44,23 +44,20 @@ supplied script ``tools/uninstall_otb.sh``.
Python bindings
~~~~~~~~~~~~~~~
Starting from OTB 5.8.0, OTB bindings for Python 2.7 are distributed as a binary
package. With OTB 6.4.0, additional bindings for Python 3.5 are also included.
Since OTB 6.7.0 OTB bindings for Python 3.5 are distributed as a binary
package.
Please note that using a different Python version may not be compatible with
OTB wrappings. If no compatible Python 2.x version is found a
notification is generated during the installation process. If the installation completes
OTB wrappings. If the installation completes
without issue, information relating to your Python bindings will be provided.
You must have Python numpy bindings installed in your system. They can be installed locally
without admin rights as follows: "pip install --user numpy". This is to give users the option
to select their own existing Python installation rather than the one dibstributed by the OTB package.
By default, bindings for Python 2.7 will be enabled with the ``otbenv`` script.
If you want to use bindings for Python 3.5, you can copy this script and modify:
- ``lib/python`` into ``lib/python3``, for variable PYTHONPATH
By default, bindings for Python 3.5 will be enabled with the ``otbenv`` script.
Notes:
~~~~~~
- If you want to use the otbcli and otbgui launchers, you must access
them via a terminal prompt.
......
......@@ -43,24 +43,20 @@ start Visual Studio.
Python bindings
~~~~~~~~~~~~~~~
Starting from OTB 5.8.0, OTB bindings for Python 2.7 are distributed as a binary
package. With OTB 6.4.0, additional bindings for Python 3.5 are also included.
Since OTB 6.7.0 OTB bindings for Python 3.5 are distributed as a binary
package.
Please note that using a different Python version may not be compatible with
OTB wrappings. If no compatible Python 2.x version is found a
notification is generated during the installation process. If the installation completes
OTB wrappings. If the installation completes
without issue, information relating to your Python bindings will be provided.
You must have Python numpy bindings installed in your system. They can be installed locally
without admin rights as follows: "pip install --user numpy". This is to give users the option
to select their own existing Python installation rather than the one dibstributed by the OTB package.
By default, bindings for Python 2.7 will be enabled with the ``otbenv`` script.
If you want to use bindings for Python 3.5, you can copy this script and modify:
By default, bindings for Python 3.5 will be enabled with the ``otbenv`` script.
- ``lib/python`` into ``lib/python3``, for variable PYTHONPATH
Notes
~~~~~
Notes:
~~~~~~
- You must have "Visual C++ Redistributable for Visual Studio 2015" installed for using this package.
It can be downloaded freely from `microsoft <https://www.microsoft.com/en-us/download/details.aspx?id=48145>`_
......
......@@ -19,10 +19,9 @@
#
option ( OTB_WRAP_PYTHON "Wrap Python" OFF )
option ( OTB_WRAP_PYTHON3 "Wrap Python 3" OFF )
option ( OTB_WRAP_JAVA "Wrap Java" OFF )
if ( OTB_WRAP_PYTHON OR OTB_WRAP_JAVA OR OTB_WRAP_PYTHON3)
if ( OTB_WRAP_PYTHON OR OTB_WRAP_JAVA )
find_package ( SWIG REQUIRED )
mark_as_advanced(SWIG_DIR)
mark_as_advanced(SWIG_EXECUTABLE)
......@@ -40,72 +39,18 @@ macro(check_PIC_flag Language)
endif()
endif()
endmacro()
# this macro should be removed
#
# Python SWIG configuration
#
if ( OTB_WRAP_PYTHON )
check_PIC_flag ( Python )
find_package ( PythonInterp REQUIRED )
find_package ( PythonLibs REQUIRED )
find_package ( Numpy )
endif()
macro(swap_cache_variable var1 var2)
# Only swap variable if var1 exists in the cmake cache
if (${var1})
set(_backup ${${var1}})
get_property(_var1_type CACHE ${var1} PROPERTY TYPE)
get_property(_var1_help CACHE ${var1} PROPERTY HELPSTRING)
get_property(_var2_type CACHE ${var2} PROPERTY TYPE)
get_property(_var2_help CACHE ${var2} PROPERTY HELPSTRING)
set(${var1} ${${var2}} CACHE ${_var1_type} "${_var1_help}" FORCE)
set(${var2} ${_backup} CACHE ${_var2_type} "${_var2_help}" FORCE)
find_package(Numpy)
if ( NOT NUMPY_FOUND )
message( WARNING
"OTB wrappers will be done without support for NumPy (not found).")
endif()
endmacro()
macro(swap_variable var1 var2)
set(_backup ${${var1}})
set(${var1} ${${var2}})
set(${var2} ${_backup})
endmacro()
if ( OTB_WRAP_PYTHON3 )
set(PYTHON3_EXECUTABLE "PYTHON3_EXECUTABLE-NOTFOUND" CACHE FILEPATH "Path to python 3 interpreter")
set(PYTHON3_INCLUDE_DIR "PYTHON3_INCLUDE_DIR-NOTFOUND" CACHE PATH "Path to python 3 include directory")
set(PYTHON3_LIBRARY "PYTHON3_LIBRARY-NOTFOUND" CACHE FILEPATH "Path to python 3 library")
set(PYTHON3_LIBRARY_DEBUG "PYTHON3_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to python 3 library (debug)")
set(PYTHON3_LIBRARY_RELEASE "PYTHON3_LIBRARY_RELEASE-NOTFOUND" CACHE FILEPATH "Path to python 3 library (release)")
set(NUMPY_PYTHON3_INCLUDE_DIR "NUMPY_PYTHON3_INCLUDE_DIR" CACHE PATH "Path to numpy module for Python 3")
# Swap cache variables between python and python3
swap_cache_variable(PYTHON_EXECUTABLE PYTHON3_EXECUTABLE)
swap_cache_variable(PYTHON_INCLUDE_DIR PYTHON3_INCLUDE_DIR)
swap_cache_variable(PYTHON_LIBRARY PYTHON3_LIBRARY)
swap_cache_variable(PYTHON_LIBRARY_DEBUG PYTHON3_LIBRARY_DEBUG)
swap_cache_variable(PYTHON_LIBRARY_RELEASE PYTHON3_LIBRARY_RELEASE)
swap_cache_variable(NUMPY_INCLUDE_DIR NUMPY_PYTHON3_INCLUDE_DIR)
swap_variable(PYTHON_LIBRARIES PYTHON3_LIBRARIES)
swap_variable(NUMPY_INCLUDE_DIRS NUMPY_PYTHON3_INCLUDE_DIRS)
swap_variable(NUMPY_FOUND NUMPY_PYTHON3_FOUND)
swap_variable(PYTHON_VERSION_STRING PYTHON3_VERSION_STRING)
check_PIC_flag ( Python )
find_package ( PythonInterp 3 REQUIRED )
find_package ( PythonLibs 3 REQUIRED )
find_package ( Numpy )
# Swap cache variables between python and python3
swap_cache_variable(PYTHON_EXECUTABLE PYTHON3_EXECUTABLE)
swap_cache_variable(PYTHON_INCLUDE_DIR PYTHON3_INCLUDE_DIR)
swap_cache_variable(PYTHON_LIBRARY PYTHON3_LIBRARY)
swap_cache_variable(PYTHON_LIBRARY_DEBUG PYTHON3_LIBRARY_DEBUG)
swap_cache_variable(PYTHON_LIBRARY_RELEASE PYTHON3_LIBRARY_RELEASE)
swap_cache_variable(NUMPY_INCLUDE_DIR NUMPY_PYTHON3_INCLUDE_DIR)
swap_variable(PYTHON_LIBRARIES PYTHON3_LIBRARIES)
swap_variable(NUMPY_INCLUDE_DIRS NUMPY_PYTHON3_INCLUDE_DIRS)
swap_variable(NUMPY_FOUND NUMPY_PYTHON3_FOUND)
swap_variable(PYTHON_VERSION_STRING PYTHON3_VERSION_STRING)
endif()
#
......
......@@ -18,7 +18,7 @@
# limitations under the License.
#
if ( OTB_WRAP_PYTHON OR OTB_WRAP_JAVA OR OTB_WRAP_PYTHON3)
if ( OTB_WRAP_PYTHON OR OTB_WRAP_JAVA )
include ( UseSWIGLocal )
list(APPEND SWIG_EXTRA_DEPS
otbWrapperSWIGIncludes.h
......@@ -34,11 +34,6 @@ if ( OTB_WRAP_PYTHON )
add_subdirectory(python)
endif()
# Python 3 SWIG configuration
if ( OTB_WRAP_PYTHON3 )
add_subdirectory(python3)
endif()
# JAVA SWIG configuration
if ( OTB_WRAP_JAVA )
add_subdirectory(java)
......
......@@ -19,7 +19,7 @@
#
include_directories ( ${PYTHON_INCLUDE_DIR} )
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} )
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR})
set_source_files_properties ( ../otbApplication.i PROPERTIES CPLUSPLUS ON )
# Run swig
set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_GLOBAL_FLAGS})
......@@ -36,6 +36,7 @@ set(SWIG_MODULE_otbApplication_EXTRA_DEPS
SWIG_add_module( otbApplication python ../otbApplication.i otbApplicationPYTHON_wrap.cxx itkPyCommand.cxx )
SWIG_link_libraries( otbApplication ${PYTHON_LIBRARIES} OTBApplicationEngine )
set_target_properties(_otbApplication PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SWIG_OUTDIR})
if(MSVC)
set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/otbApplicationPYTHON_wrap.cxx COMPILE_FLAGS "/wd4005" )
else()
......
#
# Copyright (C) 2005-2019 CS Systemes d'Information (CS SI)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# 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.
#
include_directories ( ${PYTHON3_INCLUDE_DIR} )
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/../python )
set_source_files_properties ( ../otbApplication.i PROPERTIES CPLUSPLUS ON )
# Run swig
set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_GLOBAL_FLAGS})
if(NUMPY_PYTHON3_FOUND)
include_directories(${NUMPY_PYTHON3_INCLUDE_DIRS})
list(APPEND CMAKE_SWIG_FLAGS "-DOTB_SWIGNUMPY=1")
endif()
set(CMAKE_SWIG_OUTDIR ${CMAKE_BINARY_DIR}/${OTB_INSTALL_PYTHON3_DIR})
set(SWIG_MODULE_otbApplication_EXTRA_DEPS
${CMAKE_CURRENT_SOURCE_DIR}/../Python.i
${CMAKE_CURRENT_SOURCE_DIR}/../PyCommand.i
itkPyCommand.h
OTBApplicationEngine)
SWIG_add_module( otbApplicationPy3 python ../otbApplication.i otbApplicationPYTHON_wrap.cxx ../python/itkPyCommand.cxx )
SWIG_link_libraries( otbApplicationPy3 ${PYTHON3_LIBRARIES} OTBApplicationEngine )
set_target_properties(_otbApplicationPy3 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SWIG_OUTDIR})
set_target_properties(_otbApplicationPy3 PROPERTIES LIBRARY_OUTPUT_NAME _otbApplication)
if(MSVC)
set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/otbApplicationPYTHON_wrap.cxx COMPILE_FLAGS "/wd4005" )
else()
set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/otbApplicationPYTHON_wrap.cxx COMPILE_FLAGS "-w" )
endif()
# byte-compile the resulting python file
add_custom_command(
TARGET _otbApplicationPy3
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Byte-compiling otbApplication.py"
COMMAND ${PYTHON3_EXECUTABLE}
${CMAKE_SOURCE_DIR}/CMake/PythonCompile.py
${CMAKE_SWIG_OUTDIR}/otbApplication.py
DEPENDS _otbApplicationPy3
)
otb_module_target_label( _otbApplicationPy3 )
install( TARGETS _otbApplicationPy3
DESTINATION ${OTB_INSTALL_PYTHON3_DIR}
COMPONENT RuntimeLibraries )
install( FILES ${CMAKE_SWIG_OUTDIR}/otbApplication.py
DESTINATION ${OTB_INSTALL_PYTHON3_DIR}
COMPONENT RuntimeLibraries )
if(PYTHON3_VERSION_STRING VERSION_LESS "3.2.0")
install( FILES ${CMAKE_SWIG_OUTDIR}/otbApplication.pyc
DESTINATION ${OTB_INSTALL_PYTHON3_DIR}
COMPONENT RuntimeLibraries )
else()
# TODO : pyc file is in a subfolder.
endif()
......@@ -51,10 +51,6 @@ if( "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(LINUX TRUE)
endif()
if(OTB_WRAP_PYTHON AND NOT PYTHON_EXECUTABLE)
find_package(PythonInterp REQUIRED)
endif()
find_program(FILE_COMMAND NAMES "file")
find_program(READLINK NAMES "readlink")
find_program(ZIP_EXECUTABLE NAMES 7z 7za)
......@@ -182,11 +178,6 @@ if(EXISTS "${SUPERBUILD_INSTALL_DIR}/lib/otb/python/_otbApplication${PYMODULE_EX
set(HAVE_PYTHON TRUE)
endif()
set(HAVE_PYTHON3 FALSE CACHE INTERNAL "Python3 wrappings")
if(EXISTS "${SUPERBUILD_INSTALL_DIR}/lib/otb/python3/_otbApplication${PYMODULE_EXT}")
set(HAVE_PYTHON3 TRUE)
endif()
set(HAVE_JAVA FALSE CACHE INTERNAL "Java wrappings")
if(EXISTS "${SUPERBUILD_INSTALL_DIR}/lib/otb/java/org.otb.application.jar")
set(HAVE_JAVA TRUE)
......
......@@ -24,5 +24,5 @@ set(CTEST_DROP_METHOD "https")
set(CTEST_DROP_SITE "dash.orfeo-toolbox.org")
set(CTEST_DROP_LOCATION "/submit.php?project=OTB")
set(CTEST_DROP_SITE_CDASH TRUE)
set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 4096)
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 4096)
set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 409600)
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 409600)
......@@ -180,7 +180,7 @@ goto :eof
:check_python_wrapping
setlocal
type NUL > tmp.log
python -c "import otbApplication" > tmp.log 2>&1
python3 -c "import otbApplication" > tmp.log 2>&1
call :nb_tmp_lines
if %nb_tmp_lines_out% gtr 0 (
echo ERROR : failed to run python wrapping
......
......@@ -159,7 +159,7 @@ for app in $OTB_APPS; do
done
# test python wrapping
PY_OUTPUT=$(python -c 'import otbApplication' 2>&1)
PY_OUTPUT=$(python3 -c 'import otbApplication' 2>&1)
if [ -n "$PY_OUTPUT" ]; then
echo_and_report "ERROR: python wrapping test failed :"
echo_and_report "$PY_OUTPUT"
......
......@@ -20,38 +20,61 @@
#
# get current working dir (this should be the install directory)
python_version_check() {
python_major_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[0])")
python_minor_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[1])")
python_patch_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[2])")
python_version="$python_major_version.$python_minor_version.$python_patch_version"
}
python_check_failed() {
printf %s\\n "*****Error occurred during installation******"
printf %s\\n "OTB python bindings normally require python 3.5 but current \
detected python version is $python_version"
printf %s\\n "If you have python 3.5 installed in your system you should \
set OTB_PYTHON_EXE and re-run this installation script."
printf %s\\n "eg: OTB_PYTHON_EXE=/path/to/python3 ./OTB-X.Y-Linux64.run"
printf %s\\n "Python bindings might not work."
}
CWD=$(pwd)
CUSTOM_PYTHON=true
# Setup python environment
if [ ! -f "$OTB_PYTHON_EXE" ] ; then
CUSTOM_PYTHON=false
OTB_PYTHON_EXE=$(which python3)
if [ ! -f "$OTB_PYTHON_EXE" ] ; then
OTB_PYTHON_EXE=$(which python)
# On old system we still have python => python2.x and python3 => python3.x
if [ ! -f "$OTB_PYTHON_EXE" ] ; then
printf %s\\n "*****Error occurred during installation******"
printf %s\\n "Python executable not found"
exit 1
fi
fi
fi
if [ ! -f "$OTB_PYTHON_EXE" ] ; then
printf %s\\n "*****Error occurred during installation******"
printf %s\\n "Python executable not found"
exit 1
fi
python_major_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[0])")
python_minor_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[1])")
python_patch_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[2])")
python_version="$python_major_version.$python_minor_version.$python_patch_version"
#From here we should have a python executable
python_check_failed() {
printf %s\\n "*****Error occurred during installation******"
printf %s\\n "OTB python bindings requires python2.6 or python2.7 but current detected python version is $python_version"
printf %s\\n "If you have python2.6 or Python2.7 installed in your system "
printf %s\\n "You should set OTB_PYTHON_EXE and re-run this installation script."
printf %s\\n "eg: OTB_PYTHON_EXE=/path/to/python2.7 ./OTB-X.Y-Linux64.run"
exit 1
}
if [ "$python_major_version" -gt 2 ]; then
python_check_failed
fi
python_version_check
if [ "$python_minor_version" -lt 5 ]; then
python_check_failed
if [ ! $CUSTOM_PYTHON ]
then
if [ ! "$python_major_version" -eq 3 ] && [ ! "$python_minor_version" -eq 5 ]
then
python_check_failed
fi
else # case wher user provides an OTB_PYTHON_EXE
if [ ! "$python_major_version" -eq 3 ] || [ ! "$python_minor_version" -eq 5 ]
then
printf %s\\n "*****Warning******"
printf %s\\n "OTB python bindings normally require python3.5."
printf %s\\n "The version of OTB_PYTHON_EXE ($OTB_PYTHON_EXE) is \
$python_version."
printf %s\\n "This case is undefined unless you are sure the packages were \
build with this version of python."
fi
fi
python_INSTSONAME=$($OTB_PYTHON_EXE -c "import sys; from distutils import sysconfig; print (sysconfig.get_config_var('INSTSONAME'));")
......@@ -76,13 +99,14 @@ if [ "$found_python_lib" -eq "1" ]; then
numpy_import_result="$($OTB_PYTHON_EXE -c 'import numpy' 2>&1)" || numpy_ret=$?
if [ ! -z "$numpy_import_result" ]; then
printf %s\\n "*****Error occurred during installation******"
printf %s\\n "Python interpreter detected is : $OTB_PYTHON_EXE ( version: $python_version )"
printf %s\\n "Python interpreter detected is : $OTB_PYTHON_EXE \
( version: $python_version )"
printf %s\\n "numpy not installed with '$OTB_PYTHON_EXE'"
printf %s\\n "Check failed with result:"
printf %s\\n "$numpy_import_result"
exit 1
else
printf %s\\n "OTB python bindings will be configured for $OTB_PYTHON_EXE ( version: $python_version )"
printf %s\\n "OTB python bindings will be configured for $OTB_PYTHON_EXE \
( version: $python_version )"
printf %s\\n "Found python library: $python_lib_file_path"
fi
#ln -sf "$python_lib_file_path" "$CWD/lib/$python_INSTALLED_SONAME"
......@@ -94,5 +118,4 @@ else
printf %s\\n "If you don't have python-dev package installed, install it and make a symlink"
printf %s\\n "If you don't have python headers and so installed on a custom location, then make a symlink"
printf %s\\n "eg: ln -s /usr/lib/x86_64-linux-gnu/$python_INSTSONAME $CWD/lib/$python_INSTSONAME"
exit 1
fi
......@@ -37,7 +37,6 @@ rd /S /Q lib\otb
del /S /Q lib\otb*
del /S /Q lib\python\*otbApplication.* || exit 1
del /S /Q lib\python3\*otbApplication.* || exit 1
del /S /Q lib\java\org.otb.application.jar || exit 1
del /S /Q bin\otb* || exit 1
del /S /Q bin\monteverdi.exe || exit 1
......
......@@ -21,7 +21,7 @@
set -e
rm -fr OUT_DIR/include/OTB-*
rm -f OUT_DIR/lib/{libotb*,libOTB*}
rm -fr OUT_DIR/lib/{otb,python/*otbApplication*,python3/*otbApplication*,java/org.otb.application.jar}
rm -fr OUT_DIR/lib/{otb,python/*otbApplication*,java/org.otb.application.jar}
rm -fr OUT_DIR/lib/cmake/OTB-*
rm -fr OUT_DIR/share/otb/
rm -fv OUT_DIR/bin/{otb*,monteverdi,mapla}
......
......@@ -19,10 +19,6 @@
#
macro(check_cmake_variables)
set(required_vars)
if(OTB_WRAP_PYTHON)
list(APPEND required_vars PYTHON_EXECUTABLE)
endif()
if(LINUX)
list(APPEND required_vars FILE_COMMAND)
list(APPEND required_vars READLINK)
......
......@@ -25,20 +25,15 @@ function(install_python_bindings)
PATTERN "__pycache__" EXCLUDE
)
endif()
if(HAVE_PYTHON3)
install(DIRECTORY ${SUPERBUILD_INSTALL_DIR}/lib/otb/python3
DESTINATION ${PKG_STAGE_DIR}/lib
PATTERN "*.pyc" EXCLUDE
PATTERN "__pycache__" EXCLUDE
)
endif()
# Handle GDAL python bindings
file(GLOB gdal_python_scripts "${SUPERBUILD_INSTALL_DIR}/bin/gdal*.py")
foreach(_script ${gdal_python_scripts})
install(PROGRAMS ${_script}
DESTINATION ${PKG_STAGE_DIR}/bin)
endforeach()
file(GLOB gdal_python_wrappings "${SUPERBUILD_INSTALL_DIR}/lib/python[2|3]*")
# file(GLOB gdal_python_wrappings "${SUPERBUILD_INSTALL_DIR}/lib/python[2|3]*")
# Do we need to get rid of gdal python 2 bindings too?
file(GLOB gdal_python_wrappings "${SUPERBUILD_INSTALL_DIR}/lib/python*")
foreach(_wrap ${gdal_python_wrappings})
if (IS_DIRECTORY "${_wrap}")
install(DIRECTORY ${_wrap}
......
......@@ -106,8 +106,14 @@ if(UNIX)
${GDAL_SB_CONFIG}
${GDAL_SB_EXTRA_OPTIONS}
)
#set(GDAL_BUILD_COMMAND ${CMAKE_MAKE_PROGRAM})
#set(GDAL_INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install)
# For now gdal is built if Superbuild has find python... And only on UNIX
# That might be a problem
# User will not be able to override this...
if ( OTB_WRAP_PYTHON AND PYTHON_EXECUTABLE)
list(APPEND GDAL_CONFIGURE_COMMAND "--with-python=${PYTHON_EXECUTABLE}")
endif()
else(MSVC)
configure_file(
......
......@@ -79,7 +79,7 @@ if(OTB_USE_MUPARSERX)
ADD_SUPERBUILD_CMAKE_VAR(OTB MUPARSERX_LIBRARY)
endif()
if(OTB_WRAP_PYTHON OR OTB_WRAP_JAVA OR OTB_WRAP_PYTHON3)
if(OTB_WRAP_PYTHON OR OTB_WRAP_JAVA)
ADD_SUPERBUILD_CMAKE_VAR(OTB SWIG_EXECUTABLE)
ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB SWIG)
endif()
......@@ -90,12 +90,6 @@ if(OTB_WRAP_PYTHON)
ADD_SUPERBUILD_CMAKE_VAR(OTB PYTHON_EXECUTABLE)
endif()
if(OTB_WRAP_PYTHON3)
ADD_SUPERBUILD_CMAKE_VAR(OTB PYTHON3_INCLUDE_DIR)
ADD_SUPERBUILD_CMAKE_VAR(OTB PYTHON3_LIBRARY)
ADD_SUPERBUILD_CMAKE_VAR(OTB PYTHON3_EXECUTABLE)
endif()
if(OTB_USE_QT)
ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB QT5)
ADD_SUPERBUILD_CMAKE_VAR(OTB QT_QMAKE_EXECUTABLE)
......@@ -150,7 +144,7 @@ ADD_SUPERBUILD_CMAKE_VAR(OTB Boost_LIBRARY_DIR)
set(OTB_MODULES_CONFIG)
if(WITH_REMOTE_MODULES)
foreach(remote_module SertitObject Mosaic otbGRM OTBFFSforGMM DiapOTBModule)
foreach(remote_module SertitObject Mosaic otbGRM DiapOTBModule)
list(APPEND OTB_MODULES_CONFIG -DModule_${remote_module}:BOOL=ON)
endforeach()
......@@ -213,10 +207,10 @@ ExternalProject_Add(OTB
-DOTB_USE_OPENMP:BOOL=${OTB_USE_OPENMP}
-DOTB_USE_GSL:BOOL=${OTB_USE_GSL}
-DOTB_WRAP_PYTHON:BOOL=${OTB_WRAP_PYTHON}
-DOTB_WRAP_PYTHON3:BOOL=${OTB_WRAP_PYTHON3}
-DOTB_WRAP_JAVA:BOOL=${OTB_WRAP_JAVA}
-DOTB_USE_MPI:BOOL=${OTB_USE_MPI}
-DOTB_USE_SPTW:BOOL=${OTB_USE_SPTW}
-DPYTHON_EXECUTABLE:PATH=${PYTHON_EXECUTABLE}
${OTB_ADDITIONAL_CACHE}
CMAKE_ARGS ${OTB_SB_CONFIG}
CMAKE_COMMAND ${SB_CMAKE_COMMAND}
......
......@@ -22,9 +22,7 @@ INCLUDE_ONCE_MACRO(SWIG)
SETUP_SUPERBUILD(SWIG)
set(PythonInterp_FIND_VERSION 2.7)
find_package(PythonInterp)
if(PYTHONINTERP_FOUND)
if( PYTHON_EXECUTABLE )
set(SWIG_SB_PYTHON_CONFIG "--with-python=${PYTHON_EXECUTABLE}")
else()
set(SWIG_SB_PYTHON_CONFIG)
......
......@@ -350,7 +350,6 @@ find_path(OTB_DATA_ROOT README-OTB-Data
# SWIG Wrapping
option(OTB_WRAP_PYTHON "Enable python wrappers for OTB applications (requires SWIG)" ON)
option(OTB_WRAP_PYTHON3 "Enable python 3 wrappers for OTB applications (requires SWIG)" OFF)
option(OTB_WRAP_JAVA "Enable java wrappers for OTB applications (requires SWIG)" OFF)
configure_file(${CMAKE_SOURCE_DIR}/CMake/CTestCustom.cmake.in
......@@ -376,6 +375,22 @@ foreach(lib ${_SYSTEM_CHECKUP_CONTENT})
message(STATUS "|----------------------------------------------------------")
endforeach()
# Python
# This should set the following variables (and more):
# -PYTHON_EXECUTABLE
# -PYTHON_INCLUDE_DIR
# -PYTHON_LIBRARY
set ( Python_ADDITIONAL_VERSIONS "3;2" )
set ( PythonInterp_FIND_REQUIRED ${OTB_WRAP_PYTHON} )
set ( PythonLibs_FIND_REQUIRED ${OTB_WRAP_PYTHON} )
find_package( PythonInterp )
if ( OTB_WRAP_PYTHON AND ( ${PYTHON_VERSION_MAJOR} EQUAL 2 ) )
message (WARNING "Python3 not found. There is no longer support of \
wrapping in python2 in OTB, but it can still be used.")
endif()
set (Python_ADDITIONAL_VERSIONS "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
find_package ( PythonLibs )
include(External_otb)
if(FROM_SYSTEM_LIST)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment