This guide walks through setting up a local development environment for a WLAN Pi Python package. The example uses wlanpi-fpms, but the steps apply to any WLAN Pi Python repo.
Some packages have hardware requirements. For wlanpi-fpms, the SPI interface must be enabled on the target device for the display to work.
Enable SPI via raspi-config:
sudo raspi-configOr by editing /boot/firmware/config.txt directly and adding:
dtparam=spi=on
These steps only need to be done once per environment.
- Clone the repo:
git clone git@github.com:WLAN-Pi/wlanpi-fpms.git && cd wlanpi-fpms- Create a virtualenv:
python3 -m venv venv- Activate it:
source venv/bin/activate- Update pip and install build tools:
pip install -U pip setuptools wheel pip-tools- Install the package with test dependencies:
pip install -e .[testing]The testing extras bring in tools like tox, pytest, ruff, and mypy.
WLAN Pi packages are structured as Python modules and should be run with -m:
- Stop the running service if the package is already installed on the device:
sudo systemctl stop wlanpi-fpms
sudo systemctl status wlanpi-fpms- Run using the virtualenv's interpreter (some packages require root):
sudo venv/bin/python3 -m fpmsFor keyboard-interactive mode (enables display screenshots with g):
sudo venv/bin/python3 -m fpms -eFurther reading on executing Python modules: https://docs.python.org/3/library/runpy.html
toxOr directly with pytest:
pytestNew environment:
git clone git@github.com:WLAN-Pi/wlanpi-fpms.git && cd wlanpi-fpms
python3 -m venv venv
source venv/bin/activate
pip install -U pip setuptools wheel pip-tools
pip install -e .[testing]
sudo systemctl stop wlanpi-fpms
sudo venv/bin/python3 -m fpmsReturning to an existing environment:
cd wlanpi-fpms
source venv/bin/activate
sudo systemctl stop wlanpi-fpms
sudo venv/bin/python3 -m fpms