Building from source#
Choose your operating system for more information, in particular on alternative ways of installation or compilation from source:Building on Windows#
You need a Python installation with the modules numpy and matplotlib. There are minimalistic installers and pre-packaged distributions. We recommend Anaconda 64bit but WinPython will to the job too.
You also need a Linux-like command shell along with a gcc compiler. Although there might be different solutions (Cygwin, Git Bash, MinGW/MSYS), we only support the MSYS2 (Minimal System 2) hosted at http://www.msys2.org. As computers and modern Windows (>=7) are 64bit we only test this. Avoid installing into strange Windows folders, e.g., c:ProgramDatamys64 is fine.
After installing MSYS, start the console once so it builds your personal home directory where you find a .bashrc file, e.g. in
c:\ProgramData\mys64\home\YOUR_USERNAME
Edit .bashrc so that the Anaconda or WinPython installation path is added to your default PATH.
e.g.:
export ANACONDA=/c/ProgramData/Anaconda3
export PATH=$PATH:$ANACONDA
This is necessary since gimli needs to know valid python installation and version. Ideally the following one-liner will suffice to compile pyGIMLi in the current directory.
Note: The script will automatically take care of requirements and updates of MSYS2. And also needs to modify/patch some of the llvm system files.
curl -Ls install.pygimli.org | bash
This script accepts a few more options. For help see
curl -Ls install.pygimli.org | bash -s help
If everything runs fine, including some tests, the script will tell you some additional PATH and PYTHONPATH settings for your .bashrc to use pygimli inside the console or any IDE like Spyder (coming along with WinPython).
If something goes wrong, please take a look on the error message.
You can alse try the following instructions for manual installation.
Manual installation#
Make sure to have an updated msys2 environment. Run at least:
pacman -Su
pacman -Sy
to update your local package databases. See https://www.msys2.org/ for further instructions.
To get a complete working toolchain you need some packages installed.
pacman -S make tar git subversion mercurial unzip wget patch
pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-fortran
pacman -S mingw-w64-x86_64-openblas mingw-w64-x86_64-suitesparse
pacman -S mingw-w64-x86_64-doxygen mingw-w64-x86_64-cppunit
pacman -S mingw-w64-x86_64-llvm mingw-w64-x86_64-clang
The rest of the installation is like the linux way with some small differences.
Prepare the directory structure as described above:
The build is performed via cmake. While calling cmake MSYS users should tell using the Unix makefile generator to find the correct gcc versions:
cmake ../gimli -G 'Unix Makefiles'
If cmake complains about missing python stuff, make sure the Python interpreter is in your execution path.
Problems with cmake configuration
If cmake can’t install pygccxml or pyplusplus then you can provide those packages using pip from the anaconda distribution. First make sure the needed scripts are in your path.
export PATH=$PATH:$ANACONDA/Scripts
Then you can install those both packages in your user space
pip install pygccxml --user
pip install pyplusplus --user
If cmake complains about misssig numpy, python can’t probably import numpy, which you can test:
python -c 'import numpy'
Probably anaconda additional needs another path setting, don’t ask me why
export PATH=$PATH:$ANACONDA/Library/bin
Now python should be able to find numpy and cmake will work as supposed and you can continue the build process.
To build the library, just run
make -j2
You might add the option -jN to use a number of N CPUs in parallel. To build pygimli, run
make pygimli J=2
You might add J=N to use a number of N CPUs in parallel. Building pygimli takes some time and you can grab a coffee (or two). If it finishes without errors you just need to set the environment: (note that pygimli is still built in-place, in pygimli/core)
export PYTHONPATH=$PYTHONPATH:$HOME/src/gimli/gimli/python
export PATH=$PATH:$HOME/src/gimli/build/lib
export PATH=$PATH:$HOME/src/gimli/build/bin
Compiled binaries will be written to build/bin.
You can test the pygimli build with:
python -c 'import pygimli as pg; print(pg.version())'
Building on Linux#
Curl installer#
If you are not using Anaconda, you can build pyGIMLi from source in the current directory via:
curl -Ls install.pygimli.org | bash
This script accepts a few more options. For help see:
curl -Ls install.pygimli.org | bash -s help
If something goes wrong please take a look at the error message. In most cases there are missing or outdated packages. Please have a look at the prerequisites tab.
If the installation fails you can try the following instructions for manual installation.
Detailed Installation on Debian#
Tested on Debian 12 (Bookworm).
In order to build pygimli (and gimli) Python 3, install the required packages:
sudo apt-get install wget subversion git cmake mercurial g++ \
libboost-all-dev libblas-dev liblapack-dev libopenblas-dev \
libsuitesparse-dev libedit-dev python3-dev \
python3-numpy python3-matplotlib \
python3-setuptools
Create a directory for your installation, e.g., $HOME/src/gimli
mkdir -p ~/src/gimli
cd ~/src/gimli
Checkout the current sources for libgimli:
git clone https://github.com/gimli-org/gimli.git
We use cmake for compilation. We recommend using a build directory parallel to the gimli (trunk) path:
mkdir -p build
The main directory structure should looks like this:
gimli/gimli
gimli/build
Change to the build path
cd build
If you want to compile for Python 3.8, alternatively use:
cmake ../gimli -DPYVERSION=3.8
If the output complains about missing dependencies, install these and repeat the the last step. To build the library just run make.
make
To speed up the build process using more CPUs, use the -j flag, e.g.:
make -j 8
The libraries will be installed in build/lib and some test applications are installed in build/bin. If you want to build the Python bindings, call:
make pygimli
You might add J=8 (make pygimli J=8) for using 8 jobs in parallel to speed up the build (adapt this to the number of real cores of the computer). The library _pygimli_.so library will be copied into the source path ../gimli/pygimli in the subdirectory core.
To use the gimli installation you need to set some environment variables (this example assumes that the src directory resides in your home directory):
GIMLI_INSTALLATION=$HOME/src/gimli
export PYTHONPATH=$PYTHONPATH:$GIMLI_INSTALLATION/gimli
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GIMLI_INSTALLATION/build/lib
export PATH=$PATH:$GIMLI_INSTALLATION/build/bin
If you want to use the C++ command line applications, call
make apps
Compiled binaries will be written to build/bin.
You can do a quick test of the pygimli build and installation with:
python -c 'import pygimli as pg; print(pg.__version__)'
You can test your gimli build with:
make check
Note that the test will be very silent if you don’t have cppunit installed.
If you install pytest with
sudo apt-get install python-pytest python3-pytest
then you can run the internal test suite with
python -c "import pygimli; pygimli.test()"
Using Docker to build in Debian Bookworm (for advanced users only!)#
If you want to use a Docker container to build (and possibly use) pyGIMLi, you can use the Dockerfile found in the scripts/ subdirectory named Dockerfile_DebianBookworm. Please refer to the file for further instructions.
Example Installation on Ubuntu#
sudo apt-get install libc-dev subversion git cmake mercurial
sudo apt-get install libboost-all-dev libblas-dev liblapack-dev libedit-dev
sudo apt-get install libsuitesparse-dev
sudo apt-get install python3-dev python3-matplotlib python3-numpy
mkdir -p ~/src/gimli
cd ~/src/gimli
git clone https://github.com/gimli-org/gimli.git
mkdir -p build
cd build
cmake ../gimli
make -j 4 gimli
make pygimli J=4
Troubleshooting#
If you experience runtime problems on starting pygimli like:
ImportError: /usr/lib/libboost_python.so: undefined symbol: PyClass_Type
It may happen that CMake estimates the wrong libboost_python version by choosing py2 version instead of py3. You can force cmake to select the correct version with:
cmake ../gimli -DBoost_PYTHON_LIBRARY=/usr/lib64/libboost_python3.so
castXML#
castXML (CastXML/CastXML) is needed to generate the code for the python bindings. Some systems provide castxml binary so the build system should detect it if installed. As fallback solution the build system tries to install castxml binaries or try to compile there own if the binaries don’t work. You can enforce the local binary installation with:
cmake ../../src/castXML/ -DCASTXML_LOCAL=1
make
or the local binary compilation with:
cmake ../../src/castXML/ -DCASTXML_LOCALSRC=1
make
If castXML build complains about missing clang or llvm command, please go into $(GIMLISRC)/../thirdParty/build-XXX-XXX/castXML and try configure and build cmake manually
CC=clang-3.6 CXX=clang++-3.6 cmake ../../src/castXML/
make
If you build castXML manually you can provide this binary to cmake via
cmake ../gimli -DCASTER_EXECUTABLE=$(PATH_TO_CASTXML)
Useful cmake settings#
You can rebuild and update all local generated third party software by setting the CLEAN environment variable:
CLEAN=1 cmake ../gimli
Use alternative c++ compiler.
CC=clang CXX=clang++ cmake ../gimli
Define alternative python version. On default the version of your active python version will be chosen. You will need numpy and boost-python builds with your desired python version.
cmake ../gimli -DPYVERSION=3.6
Build the library with debug and profiling flags
cmake ../gimli -DCMAKE_BUILD_TYPE=Debug
Build the library with gcc build.in sanity check
cmake ../gimli -DCMAKE_BUILD_TYPE=Debug -DASAN=1
Building on MAC OS#
These installation instructions were proposed by Claudio Jordi (ETH Zurich) in a GitHub issue. Since we do not have access to Macs, this has not been tested thorougly. Please comment in the issue and let us know if it works. know it works in the corresponding GitHub issue. For installation instructions for MacOS, please refer to:
In most cases, the following will suffice to compile pyGIMLi in the current directory.
#========================================
# First install:
# - Xcode (AppStore)
# - XQuartz (https://www.xquartz.org)
# - homebrew (https://brew.sh)
#========================================
# Install python3
brew install python3
brew install boost --with-python3
brew install boost-python --with-python3
# install some prerequisites that are not yet installed (might be more than what is here…)
brew install mercurial
brew install wget
# install matplotlib, … using pip3 (for python3)
pip3 install scipy
pip3 install numpy
pip3 install matplotlib
# follow installation instructions from pygimli.org
mkdir -p ~/src
cd src
mkdir -p gimli
cd gimli
git clone https://github.com/gimli-org/gimli.git
mkdir -p build
cd build
# The version (here 3.6.4_2) needs to be set to the installed python3 version
cmake ../gimli -DPYTHON_EXECUTABLE=/usr/local/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -DPYTHON_LIBRARY=/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6.dylib -DPY_NUMPY=/usr/local/lib/python3.6/site-packages/numpy
# This was needed for the compilation of some c++ stuff
export CPLUS_INCLUDE_PATH=/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/Headers
make -j 8
make pygimli
curl -Ls install.pygimli.org | bash
Note
Conda packages for Mac OS will follow soon.
Prerequisites#
To build pyGIMLi from source, the following tools are required:
subversion, git, mercurial, wget, tar
cmake >= 2.8.10
gcc >= 4.4
>=Python-3.5 | >=Python-2.7
numpy-dev
>=matplotlib-3.0
>=clang++-3.6.0 (3.7.0, 3.8.0)
libclang-3.7-dev
>=llvm-3.6.0 (3.7.0, 3.8.0)
libz-dev
python-setuptools
tested on:
gentoo x86_64: gcc-4.4.5, gcc-4.5.3, gcc-4.5.4, gcc-4.9.2 gcc-5.3.0
Debian 3.2.46-1 x86_64: gcc-4.7.2
Ubuntu 16.04 LTS with gcc-5.4.0
Arch Linux gcc-5.2.0
CentOS
MinGW32: gcc-4.6.2/4, gcc-4.7.2, gcc-5.2.0
MinGW64: gcc-4.5.4, gcc-5.2.0, gcc-6.3.0, gcc-7.1.0
Optional Prerequisites#
These tools can be installed system-wide with your native package manager (i.e. apt-get). If not found, the provided build scripts will automatically download and compile the necessary components.
libboost >=1.46 (python) (1.46, 1.48, 1.49, 1.51, 1.52, 1.53, 1.57)
blas and lapack for suitesparse (system or auto via cmake)
SuiteSparse (http://faculty.cse.tamu.edu/davis/suitesparse.html)
cppunit
procps
triangle (http://www.cs.cmu.edu/~quake/triangle.html)
Prerequisites automatically installed by the installer#
These tools are required to create the Python bindings and are likely to be outdated in your distribution and should therefore not be installed system-wide. The build scripts will install them automatically.
castxml
pygccxml
pyplusplus