Installation

Choose your operating system:

Installation on Windows

You need a Python installation with the modules numpy and matplotlib. There are minimalistic installers and pre-packaged distributions. We recommend WinPython or Anaconda 64bit versions.

Binary installers

To avoid the building the C++ core, we provide binary packages built against WinPython, but working as well with Anaconda. Make sure you have an appropriate Python version (3.5.x or 3.6.x, 64bit) installed. There are two ways, exe installers and wheels. The latter can be easily installed by a package manager like the WinPython Control Panel (located in the WinPython main directory).

https://img.shields.io/badge/pyGIMLi_win64-Python_3.5_Wheel-green.svg https://img.shields.io/badge/pyGIMLi_win64-Python_3.6_Wheel-green.svg

In the package manager just select the whl file and press Install to install or upgrade. If there is no package manager you can install the wheel by calling pip on the command line (e.g. on the Windows command prompt, in the WinPython control shell or under MSYS2/cygwin):

pip install pygimli-1.0rc4-cp36-cp36m-win_amd64.whl # or if pip is not in the path use
python -m pip install pygimli-1.0rc4-cp36-cp36m-win_amd64.whl # ensure python is found

See also Issue #76 for screenshots. Uninstall can be made also with the Control Panel or by pip uninstall.

Alternatively you can use the MSI installer where you can choose your Python installation

https://img.shields.io/badge/pyGIMLi_win64-MSI_for_Python_3.5-green.svg https://img.shields.io/badge/pyGIMLi_win64-MSI_for_Python_3.6-green.svg

As a result you should be able to import pygimli in any script from any location. Since the C++ core changes only rarely, you can also check out the code via git, copy the pyd/dll files from the core directory of the binary distribution (lib/site-packages/pygimli) to the core directory of the git clone, and set PYTHONPATH to the latter.

Building pyGIMLI from source

First, you 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:msys64 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:/msys64/home/YOUR_USERNAME

Edit .bashrc so that the WinPython installation path is added to your default PATH.

export PATH=$PATH:/c/PATH_TO_YOUR_WINPYTHON/WinPython-64bit-3.5.1.2/python-3.5.1/

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 -Sy

to update your local package databases. See https://sourceforge.net/p/msys2/wiki/MSYS2%20installation/ 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-doxygen
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 MSYS makefile generator:

cmake ../trunk -G 'MSYS Makefiles' -DBLAS_LIBRARIES=/mingw64/lib/libopenblas.a

If cmake complains about missing python stuff, make sure the Python interpreter is in your execution path. If openblas is not installed you should of course omit the last directive, then built-int lapack/blas are used or they are build from source.

To build the library, just run

make

You might add the option -jN to use a number of N CPUs in parallel. To build pygimli, run

make pygimli

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

If you want to use the C++ commandline applications, call

make apps

Compiled binaries will be written to build/bin.

You can test the pygimli build with:

python -c 'import pygimli as pg; print(pg.__version__)'

Using cmake with CodeBlocks

Codeblocks is a nice C++ IDE available on http://www.codeblocks.org/downloads/

Tested versions 13.12/16.01, each without integrated mingw but a real MinGW/MSYS.

To generate the codeblocks project files run

cmake -G "CodeBlocks - MinGW Makefiles"

and open the libgimli.cbp with codeblocks. Set up your compiler and run Build All.

Installation on Linux

Pre-build binary install with conda

https://anaconda.org/gimli/pygimli/badges/installer/conda.svg https://anaconda.org/gimli/pygimli/badges/downloads.svg

On Linux platforms, the most comfortable way to install pygimli is via the conda package manager contained in the Anaconda distribution. Anaconda is scientific Python distribution with more than 100 Python packages included (~400 Mb). You can also use the lightweight alternative Miniconda (~35 Mb) and only install the packages you like to use.

Install Miniconda (only once):

wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
chmod +x miniconda.sh
./miniconda.sh -b -p $HOME/miniconda
export PATH=$HOME/miniconda/bin:$PATH # Note: Add this to your .bashrc for permanent use

Add the gimli and conda-forge channel (only once):

conda config --add channels gimli --add channels conda-forge

Install pygimli (and its dependencies) and test if everything works correctly via:

conda install -f pygimli
python -c "import pygimli; pygimli.test()"

Update your pygimli installation if want to have the newest functionality:

conda update -f pygimli

The only drawback using conda is that you are bound to the rhythm we update the binary packages. Conda also can be seen as a sandbox Linux inside your system and it might be difficult to combine system python packages and conda GIMLi. If you like to keep your GIMLi version more recent (including all possible drawbacks of versions that are actively developed) you should compile GIMli using your systems toolchain.

Compile your own with the 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 Stretch

In order to build pygimli (and gimli) for Python 2.7 and Python 3.5, install the required packages:

sudo apt-get install wget subversion git cmake mercurial \
    libboost-all-dev libblas-dev liblapack-dev \
    python python-setuptools \
    python-numpy python-matplotlib \
    libedit-dev clang llvm-dev python3-dev \
    python3  python3-numpy python3-matplotlib \
    python3-setuptools

Create a directory for your installation, e.g., $HOME/src

mkdir -p ~/src
cd src
mkdir -p gimli
cd 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

and configure the build for Python 2.7 with:

cmake ../gimli

If you want to compile for Python 3.5, alternatively use:

cmake ../gimli -DPYVERSION=3.5

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/python/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):

export PYTHONPATH=$PYTHONPATH:$HOME/src/gimli/gimli/python
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/src/gimli/build/lib
export PATH=$PATH:$HOME/src/gimli/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 stretch (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_DebianStretch. 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 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

If the build misses libedit:

/usr/bin/ld: cannot find -ledit

Install libedit, e.g. ‘apt-get install libedit’ on Debian/Ubuntu.

castXML

castXML (https://github.com/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.3

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

Useful make commands

More verbose build output to view the complete command line:

make VERBOSE=1

Installation on MAC OS

In most cases, the following will suffice to compile pyGIMLi in the current directory.

curl -Ls install.pygimli.org | bash

Note

Detailed installation instructions 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-1.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.

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
News (Aug 2017):
pyGIMLi Paper out now! Download PDF here.


© 2017 - GIMLi Development Team
Created using Bootstrap and Sphinx. Last updated on Nov 21, 2017.