Environment#

Fab requires a suitable Python environment in which to run. This page outlines some routes to achieving such an environment.

This page contains general instructions, there are additional instructions for Met Office users elsewhere.

Requirements#

The minimum dependencies for Fab to build a project are:

  • Python >= 3.7

  • fParser >= 0.16.0

  • Fortran compiler

  • Linker

If you intend to compile C you will need a C compiler and linker but also:

  • libclang

  • python-clang

If you want pretty charts to be plotted from the build metrics you will need:

  • matplotlib

Obtaining Fab#

Although you can install the tool from a copy of the source it is usually preferable to use one of the managed packages.

Packages are made available through PyPI and Conda forge and are installed in the usual way for these services. Some examples follow.

Somebody Elses Problem#

Some of the prerequisites may require system administrator intervention. If they are feeling benevolent your administrator may even be prevailed upon to install the whole lot.

Using a Python Virtual Environment#

A virtual environment is created in the normal way and pip used to install Fab:

$ python -m venv $ENV_PATH
$ . $ENV_PATH/bin/activate
$ pip install sci-fab

Where $ENV_PATH is the location for the new environment.

If you want to compile C you will need to add the prerequisites for that:

$ pip install python-clang

Note that this requires a suitible libclang to be installed on your system which may require system administrator internvention.

Finally, to get plots from the metrics you will need:

$ pip install matplotlib

Using Anaconda#

Anaconda can be used in a similar way to the built in Python virtual environemnt but can also handle your C needs:

$ conda create -n FabEnv sci-fab

Or you can add Fab to an existing environment:

$ conda install -n ExistingEnv sci-fab

If you want to compile C then you will need to add the prerequisites for that:

$ conda install -n FabEnv python-clang

And again, if you want to plot the build metrics:

$ conda install -n FabEnv matplotlib

Using Containers#

The dockerfile in envs/docker can be used to create a suitible container for running Fab:

$ docker build -t fab $FAB_WC/envs/docker
$ docker run --env PYTHONPATH=/fab -v $FAB_WC/source:/fab -v /home/$USER:/home/$USER -it fab bash

This was tested on Windows, running Ubuntu in WSL but is not regularly tested so can not be guaranteed.