Skip to content

Add function for interactive OTB installation

Vincent Delbar requested to merge otb-installation into develop

Fix #113 (closed) and minor fixes in helpers.py that I just discovered, mostly with help messages in case OTB is not installed.

This adds functions in helpers.py a new pyotb.install module that should allow user to automatically install OTB when the first import failed.
If shell is interactive, user may confirm OTB installation and provide optional path and version.
By default, the latest tag is found using gitlab API (ignoring alpha or release candidates).
For windows we just need to unzip a file. Else we execute the ".run" file. The we add the OTB_ROOT env variable to user's profile using registry.

For linux and macOS, the '. otbenv.profile' command is added to $HOME/.profile.
In case of python version mismatch with the pre-built bindings, and when possible (linux and darwin, if ctest and python3-dev is installed), the ctest command to recompile python bindings is also called.
About python bindings, there is still one annoying thing: OpenGL libs (aka libgl1-mesa-dev) is required to recompile (but is missing from CLI env like the docker one).
I don't think this is normal, something is wrong with this ctest trick. Should we open an issue ?

Finally, if we cannot recompile, we may try the symlink trick (this is working for ubuntu 22 and google colab).
Sometimes we could have the problem of missing file command, but in most cases this is working good ! See tested platforms above.

Features :

  • Installation in interactive mode
    • Linux
    • macOS
    • Windows
  • Auto env profile edit
    • Linux
    • macOS
    • Windows (using registry hive)
  • Auto upgrade / overwrite old versions ?

This last one should be easy to add. But if we do this it may be better to define a fixed "pyotb_dir" where we always install / upgrade

Tested on :

  • Ubuntu 22.04 with ctest and python3-dev installed
  • Ubuntu 20.04 is working out of the box
  • Windows 11 and 10 with conda env py37
  • Google Colab (now ships with ubuntu 22)
  • Python official docker images, out of the box
  • Planetary Computer jupyter env
  • macOS may work
Edited by Vincent Delbar

Merge request reports

Loading