Request for changes-126: Support python 2.7 and 3 wrappings
[Request for Changes - 126] Support python 2.7 and 3 wrappings
- Author: Guillaume Pasero
- Additional Contributors (if different than authors)
- Submitted on 23.11.2017
- Proposed target release : 6.4
- Adopted : +2 from Victor, Guillaume
- Merged : 84c47885c7da897b2dd1a490b03bbf9cc215eef6
Support of Python wrappings with version 2.7 and 3 at the same time.
The purpose of the RFC is to start a transition to Python 3 wrappings. Since 2.7 is still in use, this RFC adds a support for both wrappings in parallel.
Classes and files
The modifications are focused on CMake files.
M CMakeLists.txt M CMake/UseSWIGLocal.cmake M Modules/Wrappers/SWIG/otb-module-init.cmake
A new option
OTB_WRAP_PYTHON3 has been added. It enables Python wrappings for versions 3.X only. Note that the existing wrapping
OTB_WRAP_PYTHON is unchanged, and compatible with both 2.7 and 3. When both python wrappings are ON, there are 2 calls to
find_package(PythonLibs/PythonInterp). The trick to avoid a collision between variables is to add new variables with names carrying "PYTHON3". Before and after the
find_package() for Python3, there is a variable swap between the "standard" variables and the "python3" variables.
M Modules/Wrappers/SWIG/src/CMakeLists.txt A Modules/Wrappers/SWIG/src/java/CMakeLists.txt A Modules/Wrappers/SWIG/src/python/CMakeLists.txt A Modules/Wrappers/SWIG/src/python3/CMakeLists.txt
In order to build properly the wrapping without conflict between include directories, we have to split the different wrapper in sub-folders (and call the corresponding
include_directories(Python_DIR) from there). The new 'python3' wrappers are built with the same module name 'otbApplication.py'. They are installed in
D Modules/Wrappers/SWIG/src/itkPyCommand.cxx D Modules/Wrappers/SWIG/src/itkPyCommand.h A Modules/Wrappers/SWIG/src/python/itkPyCommand.cxx A Modules/Wrappers/SWIG/src/python/itkPyCommand.h
itkPyCommand is specific for python and python3 wrappings, it has been moved to the 'python' subfolder.
M Packaging/CMakeLists.txt M Packaging/install_python_bindings.cmake M SuperBuild/CMake/External_otb.cmake M SuperBuild/CMakeLists.txt
SuperBuild and Packaging have been modified to support this new wrapper.
This new feature will be used to provide standalone binaries with two python wrappings : for version 2.7 and 3.5. At the moment, it is not possible to provide a Python 3 wrapping that will be guaranteed to work on all 3.x versions.