Installation

Choose one of the following methods below to install the package:

  • If you are using Mojito in another project, we suggest to add Mojito as a dependency using the project’s dedicated environement manager; see uv (recommended) or pip below.

  • You can also install from source (discouraged).

  • If you wish to contribute to Mojito, we suggest to setup the Mojito developement environement.

With pip

Equivalently, you can use pip to create a dedicated environement and install Mojito.

To create a new virtual environment with pip, run the following commands. If you already have created your project virtual environement, skip this step and simply activate it.

# If you need to create a new venv
python3 -m venv my-mojito-env
# Activate venv
source my-mojito-env/bin/activate

Then, run the following command to install Mojito in the activated environement,

pip install mojito

Tip

A good habit is to freeze a list of dependencies for your project using pip freeze > requirements.txt, and to commit it. This will allow you to recreate the exact same environement at a later time using pip install -r requirements.txt.

Warning

You can also install Mojito in your global system Python environement; simply run the above command outside of a venv. Note, however, that this is strongly discouraged as it breaks compartimentalization and often results in dependency hell.

From source code and wheel

If you don’t have access to the package registry, you can manually download the source code or wheel from the project registry. Select the desired version, scroll down to the “Assets” section, and download the mojito-<VERSION>.tar.gz or mojito-<VERSION>-py3-none-any.whl file.

You can then install it using one of the following commands:

# From source code
pip install mojito-<VERSION>.tar.gz
# From wheel
pip install mojito-<VERSION>-py3-none-any.whl

Setup the developement environement

If you wish to contribute to Mojito as a developer, you need to setup the developement environement using uv.

Using the dedicated developement environement ensures that all developers use the same environement and therefore prevents incompatibilities issues. This method also installs the developer toolchain automatically.

First, clone the project:

git clone https://gitlab.esa.int/lisa-sgs/commons/mojito.git
cd mojito

You can now run any command inside the Mojito developement environement using

# Run any command inside the dev venv
uv run my-command

# For example, run pylint, mypy black and unit tests
uv run pylint src/mojito
uv run mypy src/mojito
uv run black .
uv run pytest

We recommend setting up pre-commit hooks,

# Setup pre-commit hooks
uv run pre-commit install

# Run pre-commit hooks on all files
uv run pre-commit run --all-files

You can also manually activate the uv-managed environement:

# Update and activate uv dev venv
uv sync
source .venv/bin/activate

# Now, run any command inside the dev env, e.g.
pre-commit run --all-files

VS Code users

If you are using VS Code, we recommanded to update the dev venv with uv sync, then setting it up as the Python interpreter in VS Code:

  1. In VS Code, open the command palette (Cmd + Shift + P)

  2. Choose “Python: Select Interpreter”

  3. Pick the uv-managed environement located in “./.venv/bin/python”

Any terminal opened in VS Code will now automatically use this environement.