Python Development Environment#
Although every developer's environment is different and is subject to a personal preference, we will provide some recommendations for a Python toolchain setup suitable for the development of NDK applications.
The toolchain that can be used to develop Python-based NDK apps consists of the following components:
- Python programming language - Python interpreter, toolchain, and standard library. Python2 is not supported.
- Python NDK bindings - generated data access classes for gRPC based NDK service.
Here is an example project structure that you can use for the NDK agent development:
. # Root of a project ├── app # Contains agent core logic ├── yang # A directory with agent YANG modules ├── agent.yml # Agent yml config file ├── main.py # Package main that calls agent logic ├── requirements.txt # Python packages required by the app logic
NDK language bindings#
With the provided Python bindings, the NDK can be installed with
# it is a good practice to use virtual env sudo python3 -m venv /opt/myApp/venv # activate the newly created venv source /opt/myApp/venv/bin/activate # update pip/setuptools in the venv pip3 install -U pip setuptools # install the NDK using a specific version (example given for v21.6.2) pip3 install https://github.com/nokia/srlinux-ndk-py/archive/v21.6.2.zip
Once installed, NDK services are imported in a Python project like that:
from ndk import appid_service_pb2 # (1)
- Example given for
appid_service_pb2service but every service is imported the same way.