See the official Python packaging projects guide to get started.
New projects must use pyproject.toml for project metadata. Do not use setup.py for new packages.
If you cannot run your Python project directly as a module python -m app, it is not packaged correctly.
If you rely on data outside of your package, you must handle considerations for when that data is not present when your package is run. Do not rely on hard coding paths, make them configurable.
Do not roll your own options parser. Use argparse from the stdlib.
In general the rules of thumb are:
- Class names should use
UpperCamelCase - Constant names should be
CAPITALIZED_WITH_UNDERSCORES - Other names should use
lowercase_separated_by_underscores - Private variables/methods should start with an underscore:
_myvar - Some special class methods are surrounded by two underscores:
__init__
In some cases, we break the rules.
When using abbreviations with CamelCase, capitalize all the letters of the abbreviation. For example, Dot11FT is desired rather than Dot11Ft.
Python 3.13 is the standard for new development. This aligns with the system Python in Debian Trixie, which is the active development target for WLAN Pi.
Bookworm (Python 3.11) may still receive bug fixes on existing packages. Bullseye (Python 3.9) is end-of-life for WLAN Pi.
Existing repos may still carry older targets such as py39 or py311 in their tox.ini and pyproject.toml. These should be updated to include py313 when the repo is next actively worked on.
The Python testing framework of choice should be pytest.
To familiarize yourself with tox, read the tox documentation here.
Install tox:
python3 -m pip install toxYou can now invoke tox in the directory where tox.ini resides.
These are some things you should do before submitting a PR:
To initiate testing:
toxSee wlanpi-profiler/tox.ini for an example tox.ini.
Lint your code:
tox -e lintFormat your code:
tox -e format