Skip to content

Commit

Permalink
Fix installation instructions (#520)
Browse files Browse the repository at this point in the history
* add root level tox.ini containing dev env settings only
adapt instructions README.md
fix excludes of _external_src in pytest configuration

* add tox installation

* add explanation of -dev.txt
add external dependencies

* remove Python 3.11
  • Loading branch information
halungge authored Aug 13, 2024
1 parent 0be1aba commit 0aab0a3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 19 deletions.
43 changes: 25 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,13 @@ ICON4Py hosts Python implementations of various components from the ICON climate
The repository is organized into directories, each containing independent Python namespace packages for different ICON components or utility packages. These packages can be installed independently. Since these packages are not available from a package repository (yet), you need to specify the location of dependencies within this repository. This can be done by installing the required dependencies first. Refer to the [Installation instructions](#installation-instructions) below.

## Installation instructions
### Dependencies
A minimal installation of ICON4Py needs
- Python 3.10
- boost >= 1.85.0

We recommend to use [tox](https://tox.wiki/en/latest/) for the automatic installation of all packages in development mode in a single step:
The `tox.ini` files are located in the `model` and `tools` directories so `tox` needs to be run from there.

```bash
# Clone the repository
git clone [email protected]:C2SM/icon4py.git
cd icon4py

# Use tox to create and set up a development environment (usually at `.venv`) in verbose mode
python -m tox -vv -c model/tox.ini -e dev --devenv .venv

# Activate the virtual environment and check that everything works
source .venv/bin/activate
pytest -v
```

If you want to proceed manually, you should install all packages at once by using the provided `requirements.txt` or `requirements-dev.txt` files in the root of the repository. For example:

You can install all packages at once by using the provided `requirements.txt` or `requirements-dev.txt` files in the root of the repository. For example:
The `-dev.txt` file installs ICON4Py packages and GT4Py in editable mode, such that source changes are immediatly picked up and used in the virtual environment.
```bash
# Clone the repository
git clone [email protected]:C2SM/icon4py.git
Expand All @@ -50,6 +38,25 @@ pytest -v

The `--src _external_src` option tells `pip` to use a specific folder as the base path for checked out sources, which is very convenient for development tasks involving changes in external dependencies like `gt4py`. For convenience, `./_external_src` has been already added to the repository `.gitignore`.

You can also use [tox](https://tox.wiki/en/latest/) for the automatic installation of all packages in development mode in a single step:


```bash
# Clone the repository
git clone [email protected]:C2SM/icon4py.git
cd icon4py

# Use tox to create and set up a development environment (usually at `.venv`) in verbose mode
pip install tox
python -m tox -vv -e dev --devenv .venv

# Activate the virtual environment and check that everything works
source .venv/bin/activate
pytest -v
```



### Installation of specific subpackages

In case you only want to install a specific subpackage, use the actual subpackage `requirements.txt` or `requirements-dev.txt` files.
Expand Down
1 change: 1 addition & 0 deletions model/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ commands_post =

[pytest]
addopts = -p icon4py.model.common.test_utils.pytest_config
norecursedirs=*_external_src
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
norecursedirs = _external_src
norecursedirs = *_external_src
markers =
slow_tests: mark test as slow.
datatest: test depending on serialized data generated by a full model run
Expand Down
14 changes: 14 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Tox configuration file
# Reference documentation: https://tox.readthedocs.org/

[tox]
envlist =
dev
skipsdist = true

[testenv]
deps =
-r {toxinidir}/requirements-dev.txt
setenv =
PIP_SRC = _external_src
skip_install = true

0 comments on commit 0aab0a3

Please sign in to comment.