Installation#

We define here two types of installation:

We recommend users and contributors to first set up a virtual environment where to install GPM-API.

Virtual environment creation#

While not mandatory, utilizing a virtual environment when installing GPM-API is recommended.

Using a virtual environment for installing packages provides isolation of dependencies, easier package management, easier maintenance, improved security, and improved development workflow.

Here below we provide two options to set up a virtual environment, using venv or conda (recommended).

With conda:

  • Install miniconda or anaconda if you don’t have it already installed.

  • Create the gpm-api-py311 (or any other custom name) conda environment:

conda create --name gpm-api-py311 python=3.11 --no-default-packages
  • Activate the gpm-api-py311 conda environment:

conda activate gpm-api-py311

With venv:

  • Windows: Create a virtual environment with venv:

python -m venv gpm-api-pyXXX
cd gpm-api-pyXXX/Scripts
activate
  • Mac/Linux: Create a virtual environment with venv:

virtualenv -p python3 gpm-api-pyXXX
source gpm-api-pyXXX/bin/activate

Installation for standard users#

The latest GPM-API stable version is available on the Python Packaging Index (PyPI) and on the conda-forge channel.

Therefore you can either install the package with pip or conda. Installation with conda is recommended, as GPM-API depends on cartopy and GEOS libraries, which can be difficult to install with pip.

Please install the package in the virtual environment you created before !

With conda:

conda install -c conda-forge gpm-api

To unlock the full functionalities offered by GPM-API, we recommend to already install the following packages:

conda install -c conda-forge ximage polars pyarrow pyresample shapely jupyter spyder pyvista trame trame-vuetify trame-vtk

Note

In alternative to conda, if you are looking for a lightweight package manager you could use micromamba.

With pip:

On Linux, prior to the installation of GPM-API, you can install GEOS using your package manager (e.g. apt install libgeos-dev). Then, install GPM-API with:

pip install gpm-api

Installation for contributors#

The latest GPM-API version is available on the GitHub repository gpm_api. You can install the package in editable mode, so that you can modify the code and see the changes immediately. Here below we provide the steps to install the package in editable mode.

Clone the repository from GitHub#

According to the contributors guidelines, you should first create a fork into your personal GitHub account.

Then create a local copy of the repository you forked with:

git clone https://github.com/<your-account>/gpm_api.git
cd gpm_api

Create the development environment#

We recommend to create a dedicated conda environment for development purposes. You can create a conda environment (i.e. with python 3.11) with:

conda create --name gpm-api-dev-py311 python=3.11 --no-default-packages
conda activate gpm-api-dev-py311

Install the package dependencies#

conda install --only-deps gpm-api

Install the package in editable mode#

Install the GPM-API package in editable mode by executing the following command in the GPM-API repository’s root:

pip install -e ".[dev]"

Install code quality checks#

Install the pre-commit hook by executing the following command in the GPM-API repository’s root:

pre-commit install

Pre-commit hooks are automated scripts that run during each commit to detect basic code quality issues. If a hook identifies an issue (signified by the pre-commit script exiting with a non-zero status), it halts the commit process and displays the error messages.

Note

The versions of the software used in the pre-commit hooks is specified in the .pre-commit-config.yaml file. This file serves as a configuration guide, ensuring that the hooks are executed with the correct versions of each tool, thereby maintaining consistency and reliability in the code quality checks.

Further details about pre-commit hooks can be found in the Contributors Guidelines, specifically in the provided in the Code quality control section.

Download the test data#

Some of GPM-API’s tests require additional data to be executed. If you want to be able to run the full GPM-API test suite on your local machine, you also need to download such additional test data. First, ensure you have your GitHub account ssh keys set up correctly. Then, from the within the gpm_api directory, run:

git submodule update --init --recursive

Run GPM-API on Jupyter Notebooks#

If you want to run GPM-API on a Jupyter Notebook, you have to take care to set up the IPython kernel environment where GPM-API is installed.

For example, if your conda/virtual environment is named gpm-api-dev, run:

python -m ipykernel install --user --name=gpm-api-dev

When you will use the Jupyter Notebook, by clicking on Kernel and then Change Kernel, you will be able to select the gpm-api-dev kernel.