Infuse-IoT Python Tools

Install & Setup

Instructions to install and setup the Infuse-IoT Python tools.

The Infuse-IoT Python Tools can be installed on:

Prerequisites

Install Python

Ensure a suitable version of Python is installed on your system. The Python Tools are tested with Python versions 3.10 through to 3.14. Checking if Python is installed (and which version) can be done by running the following in your terminal.

python --version
If ZephyrRTOS or Infuse-IoT is setup and working on your machine, Python is already installed and setup, skip to Installation.
sudo apt install python3-dev

Do you need a Virtual Environment

Python now requires virtual environments to avoid package conflicts.

The next steps depends on whether you:

  • Already have your own virtual environment (or one using a different environment manager) for Infuse-IoT Python Tools, or intend to use the same virtual environment created as part of an existing ZephyrRTOS or Infuse-IoT SDK installation.
  • Don't have one (or know if you have one), but plan to install the Infuse-IoT embedded SDK, or
  • Plan to use Infuse-IoT Python tools standalone (without the Infuse-IoT embedded SDK installed).

Skip to Installation.

Ensure your intended venv created is active before continuing.

Setup a Virtual Environment (.venv)

Zephyr's Getting Started Guide outlines the process to setup a virtual environment in zephyrproject (in your user profile/home directory). Follow the instructions to setup a Virtual Environment.

The Virtual Environment can be installed to a different location if desired, but the corresponding commands will need to be changed to accomodate the new path. Similarly, other Python Environment managers (e.g. Anaconda) can be used, if you're comfortable doing so.
Once created, a virtual environment cannot be moved, so ensure the location is convenient. However, a venv can be recreated by following the specific steps in the Infuse-IoT Getting Started Guide

Don't forget to activate your environment

Remember to activate your virtual environment every time your start a new terminal before working with Infuse-IoT Python Tools, or it won't function. With the default installation path, this can be done by running:

source ~/zephyrproject/.venv/bin/activate
If you do not usually use Python or only use this Python Virtual Environments, this line can be added to your .zshrc/.bashrc to automatically launch the virtual environment when opening a shell to avoid needing to type it each time. Otherwise using an alias can make it easier to switch between different venv's.

Installation

The Python tools can be installed from PyPI.

Select the option depending on whether you are using a virtual environment (pip) or not (pipx)

Utilise the following command to install Infuse-IoT Python Tools.

pip install infuse-iot
Ensure your venv is activated before installing.

Once installed, some additional setup required.

Additional Setup

Keyring

Infuse-IoT Python Tools utilises Keyring to securely store secrets such as API keys and caching Network Credentials and installs it as part of Infuse-IoT's installation. Keyring is cross platform by utilising different backends on different OS's.

Check that Keyring is correctly setup by running:

keyring --list-backends

This will output the supported backends on your machine such as:

> keyring --list-backends
keyring.backends.chainer.ChainerBackend (priority: -1)
keyring.backends.fail.Keyring (priority: 0)
keyring.backends.SecretService.Keyring (priority: 5)

Search for a backend with a priority above 0.

Ubuntu and other distros won't always have a default credential provider. The preferred predential storage provider is provided by gnome-keyring and appears as:

keyring.backends.SecretService.Keyring.

It can be installed with:

sudo apt install gnome-keyring

Setup Infuse-IoT Credentials

The Python tools interract with the Infuse-IoT cloud API to setup boards and run cloud RPCs. To perform these tasks, the Python tools require a Cloud API key to authorise the commands.

At this point in time the Infuse-IoT Cloud API only accepts legacy Organisation Admin API Keys (opposed to other Temporary and IAM Managed API Keys that are also available in the Infuse-IoT Portal). The Legacy Organisation Admin API key can be retrieved by Organisation Admins from the Infuse-IoT Portal Under the Admin Centre > Developer at the very bottom under the "Infuse Iot Admin Api Key" section. Click the "Fetch Key" button and copy the API Key.

Ensure you have access to your Organisation's Admin Key. Otherwise contact your Organisation's Administrator.

Run the command below (replacing [API_KEY] with your API key, while ommitting the Bearer prefix) to save your API key on the machine.

infuse credentials --api-key [API_KEY]
Some systems running WSL may have issues with keyring raising:
secretstorage.exceptions.PromptDismissedException: Prompt dismissed
This is likely because WSL launches the distro headless. Running the following command once should fix it (that or add to .bashrc if it reappears after rebooting WSL)
dbus-update-activation-environment --systemd DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY

When launching infuse it will attempt to unlock the keyring to access its credentials, and you will receive a password prompt.

For WSL users, this prompt will only ask for a password. This password will correspond to the user account created inside WSL (not the account used to sign into Windows).

Register Autocomplete (Optional)

Enable Tab auto completion for the Python Tools.

Add the following to your .bashrc

eval "$(register-python-argcomplete infuse)"
If you auto-load your Virtual Environment in your .bashrc, ensure to add this line afterwards.

Cache Network Credentials (Optional)

During development, Infuse-IoT SDK powered devices utilise a default, publicly available network key for encryption. A custom, non-public network key may be used during development and should be used for releases. For the Python tools to communicate with these devices, the encryption key must be registered with the Python Tools. These custom keys are generated by the embedded SDK as a .yamlfile and can be shared and imported into the Python tools with:

infuse credentials --network network_key_file.yaml

Load Project Specific Definitions & Scripts (Optional)

If you're using a custom project that includes custom definitions (for RPCs, TDFs, KV, etc), you can import those into the Python tools.

Import custom tools:

python credentials --custom-tools /path/to/tools_folder
If your embedded SDK project contains custom tools, they will typically be found under the project's scripts/tools folder

Import custom definitions:

python credentials --custom-definitions /path/to/definitions_folder
If your embedded SDK project contains custom tools, they will typically be found under the project's generated folder