Python and OTB binary package on MacOS
OTB binaries are distributed for MacOS with a Python wrapper generated for Python 3.7. There are several problems :
- The self-extraction script (mostly generated from this script) will try to find python libraries in
$DYLD_LIBRARY_PATH. The first path are standard location for Python if it is installed from package managers (brew, port). The latter (dyld path) is supposed to give the user the opportunity to specify a custom location for the Python library path. This could be useful when using a virtual env (e.g. with conda environments) where the libraries are not in a standard place. A similar solution is used for the Linux packages where
LD_LIBRARY_PATHcan be set to locate python libraries. However with recent versions of MacOS (> ElCapitan), System Integrity Protection has been introduced. A consequence is that the DYLD_LIBRARY_PATH variable cannot be passed to a shell script (the self extracting archive is one). System Integrity Protection can be turned off, but it is activated by default.
This means that there is currently no way to use a python library that is not in the standard location in OTB binary packages on MacOS.
- The binary package is compiled with Python 3.7 and should be used with the same version (it is possible to recompile the bindings with another version thought). However the self extraction script complains about invalid version when the archive extracted with Python 3.7 :
OTB python bindings normally require python3.5. The version of OTB_PYTHON_EXE (/Users/user/opt/anaconda3/envs/py37/bin/python3) is 3.7.7. This case is undefined unless you are sure the packages were build with this version of python.
This check uses a hardcoded version of Python (3.5). This has no consequence, but this is confusing. It shouldn't be hard to fix.
- Recompiling the Python bindings in a python 3.7 conda environment seems to work, but produces a segfault when importing the otbApplication module in Python. See this comment
I reproduced the error on MacOS with the same conda environment. It works on Ubuntu 16.04.
This last problem requires more investigation.
Hopefully one day there will be a conda package for otb on MacOS.