Skip to content

Latest commit

 

History

History
115 lines (77 loc) · 2.13 KB

File metadata and controls

115 lines (77 loc) · 2.13 KB

Development Setup

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.

System requirements

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-config

Or by editing /boot/firmware/config.txt directly and adding:

dtparam=spi=on

Initial setup

These steps only need to be done once per environment.

  1. Clone the repo:
git clone git@github.com:WLAN-Pi/wlanpi-fpms.git && cd wlanpi-fpms
  1. Create a virtualenv:
python3 -m venv venv
  1. Activate it:
source venv/bin/activate
  1. Update pip and install build tools:
pip install -U pip setuptools wheel pip-tools
  1. Install the package with test dependencies:
pip install -e .[testing]

The testing extras bring in tools like tox, pytest, ruff, and mypy.

Running the module

WLAN Pi packages are structured as Python modules and should be run with -m:

  1. Stop the running service if the package is already installed on the device:
sudo systemctl stop wlanpi-fpms
sudo systemctl status wlanpi-fpms
  1. Run using the virtualenv's interpreter (some packages require root):
sudo venv/bin/python3 -m fpms

For keyboard-interactive mode (enables display screenshots with g):

sudo venv/bin/python3 -m fpms -e

Further reading on executing Python modules: https://docs.python.org/3/library/runpy.html

Running tests

tox

Or directly with pytest:

pytest

Cheatsheet

New 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 fpms

Returning to an existing environment:

cd wlanpi-fpms
source venv/bin/activate
sudo systemctl stop wlanpi-fpms
sudo venv/bin/python3 -m fpms