This project provides a minimal example for setting up Python packages in 2023 with modern tooling. Its main purpose is reading information from cofiguration files in a structured, easily extendable and elegant fashion.
As the repository name suggests, this project uses pdm as package manager. pdm
handles not only the installation of dependencies, but also the creation of virtual environments, execution of custom scripts similar to npm
, and further serves as a build backend.
Thus, it works as a modern alternative to poetry and replaces the traditional package building process based on setuptools.
Further, pdm
stores all package metadata in pyproject.toml
according to PEP 621. There is no need for setup.py
, setup.cfg
or requirements.txt
files!
- black for formatting.
- ruff for linting as an extremely fast and more complete substitute of flake8. ruff can also replace isort for sorting imports.
- pytest for testing. Shared pytest fixtures are collected in
tests/conftest.py
. - mypy for static type checking.
This project uses toml
as configuration format in combination with the tomllib library which was added to the standard library in Python 3.11.
Further, it makes heavy use of Python dataclasses for convenient and structured storage and access of configuration data.
- pre-commit for running all kinds of checks before committing and pushing to the remote repository.
- pdm scripts for easy and consistent task execution similar to a
Makefile
. - GitHub Actions as continuous integration service.
The easiest way to use the pdm_config
package is to clone the repository from GitHub and run
pip install .
If you want to contribute to development or extend the project according to your own needs, run the command
pip install -e .
to install the package in editable mode with all development dependencies.
The entry point for this project is the __main__.py
file in the pdm_config
package directory.
It simply prints out the configuration data and can be executed via
# from `pdm_config` directory
python __main__.py
# from `pdm_config` directory
python -m pdm_config
# from any point of the project
pdm main # or `pdm run main`