Skip to content

Get started

In general there are 4 ways to use ili2py:

  • CLI pure python
  • CLI binary (linux, window, macos)
  • Docker container
  • as a library

Install

ili2py is published on PyPI as interlis2py (the name ili2py is not available on PyPI). Import package and command line tool are ili2py. Requires Python >= 3.12.

pip install interlis2py
# or with uv in your project
uv add interlis2py
# or as standalone command line tool
uv tool install interlis2py
# show help about ili2py in general
ili2py --help
import ili2py

The binaries for Linux, macOS and Windows are attached to the releases on GitHub, see CLI (Binary version).

Quickstart

The following sections will guide you to quickstart the project.

Tip

If you are on windows, you need to change the direction of the slashes in the commands you execute!

All following commands are executed from the project root.

Python

Assuming you have uv installed on your system.

uv sync --no-dev
# show help about ili2py in general
uv run python -m ili2py.cli
# show version of ili2py
uv run python -m ili2py.cli -V
# show help about diagram tool
uv run python -m ili2py.cli diagram --help
# create plantuml diagram with one model selected
uv run python -m ili2py.cli diagram -i tests/data/models/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f plantuml -o .generated -m OeREBKRMtrsfr_V2_0
# create plantuml diagram with all models which are related
uv run python -m ili2py.cli diagram -i tests/data/models/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f plantuml -o .generated
# create plantuml diagram with 2 models selected
uv run python -m ili2py.cli diagram -i tests/data/models/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f plantuml -o .generated -m OeREBKRMtrsfr_V2_0,OeREBKRM_V2_0
# create mermaid diagram with one model selected
uv run python -m ili2py.cli diagram -i tests/data/models/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f mermaid -o .generated -m OeREBKRMtrsfr_V2_0
# create mermaid diagram with all models which are related
uv run python -m ili2py.cli diagram -i tests/data/models/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f mermaid -o .generated
# create mermaid diagram with 2 models selected
uv run python -m ili2py.cli diagram -i tests/data/models/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f mermaid -o .generated -m OeREBKRMtrsfr_V2_0,OeREBKRM_V2_0
# show debug output while generating diagram
uv run python -m ili2py.cli -v diagram -i tests/data/models/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f plantuml -o .generated
# capture log into a log file
uv run python -m ili2py.cli -v diagram -i tests/data/models/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f plantuml -o .generated > ili2py.log

# show help about python class generation tool
uv run python -m ili2py.cli python-classes --help
# generates complete set of python classes for a model
uv run python -m ili2py.cli python-classes -i tests/data/models/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -o .generated -l interface
# if you have a python project which you want to include the interface directly you should name it regardingly (dotted python path).
# Of course you need to copy the output to the correct path then, or create it alread in the right place.
uv run python -m ili2py.cli python-classes -i tests/data/models/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -o .generated -l ili2py.interfaces.interlis.OeREBKRMtrsfr_V2_0
# show debug output while generating python classes
uv run python -m ili2py.cli -v python-classes -i tests/data/models/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -o .generated -l interface
# capture log into a log file
uv run python -m ili2py.cli -v python-classes -i tests/data/models/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -o .generated -l interface > ili2py.log

Docker

docker build -t ili2py:local-dev .

# show help about ili2py in general
docker run --rm -ti ili2py:local-dev
# show version of ili2py
docker run --rm -ti ili2py:local-dev -V
# show help about diagram tool
docker run --rm -ti ili2py:local-dev diagram --help
# create plantuml diagram with one model selected
docker run --rm -ti -v ./tests/data/models:/io/data -v ./.generated:/io/generated ili2py:local-dev diagram -i /io/data/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f plantuml -o /io/generated -m OeREBKRMtrsfr_V2_0
# create plantuml diagram with all models which are related
docker run --rm -ti -v ./tests/data/models:/io/data -v ./.generated:/io/generated ili2py:local-dev diagram -i /io/data/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f plantuml -o /io/generated
# create plantuml diagram with 2 models selected
docker run --rm -ti -v ./tests/data/models:/io/data -v ./.generated:/io/generated ili2py:local-dev diagram -i /io/data/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f plantuml -o /io/generated -m OeREBKRMtrsfr_V2_0,OeREBKRM_V2_0
# create mermaid diagram with one model selected
docker run --rm -ti -v ./tests/data/models:/io/data -v ./.generated:/io/generated ili2py:local-dev diagram -i /io/data/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f mermaid -o /io/generated -m OeREBKRMtrsfr_V2_0
# create mermaid diagram with all models which are related
docker run --rm -ti -v ./tests/data/models:/io/data -v ./.generated:/io/generated ili2py:local-dev diagram -i /io/data/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f mermaid -o /io/generated
# create mermaid diagram with 2 models selected
docker run --rm -ti -v ./tests/data/models:/io/data -v ./.generated:/io/generated ili2py:local-dev diagram -i /io/data/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -f mermaid -o /io/generated -m OeREBKRMtrsfr_V2_0,OeREBKRM_V2_0

# show help about python class generation tool
docker run --rm -ti ili2py:local-dev python-classes --help
# generates complete set of python classes for a model
docker run --rm -ti -v ./tests/data/models:/io/data -v ./.generated:/io/generated ili2py:local-dev python-classes -i /io/data/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -o /io/generated -l interface
# if you have a python project which you want to include the interface directly you should name it regardingly (dotted python path).
# Of course you need to copy the output to the correct path then, or create it alread in the right place.
docker run --rm -ti -v ./tests/data/models:/io/data -v ./.generated:/io/generated ili2py:local-dev python-classes -i /io/data/OeREBKRMtrsfr_V2_0/OeREBKRMtrsfr_V2_0.imd -o /io/generated -l ili2py.interfaces.interlis.OeREBKRMtrsfr_V2_0