Project Tooling¶
This document describes the build, test, and packaging tooling used by the pico-sqlalchemy project. It covers what the tooling is, how the project is configured, and how to run common developer workflows.
Overview¶
- pyproject.toml: Central configuration for build system, package metadata, dependencies, and optional extras. Uses setuptools and setuptools_scm to build and version the package.
- tox.ini: Test automation across multiple Python versions (py310–py314). Provides environments to run the test suite and a dedicated coverage run configured to execute pytest with coverage reporting.
pyproject.toml¶
What it is: - Defines the build system (setuptools) and versioning (setuptools_scm). - Declares the package name (pico-sqlalchemy), metadata, required dependencies, and optional extras. - Drives how the project is built (sdist and wheel) and how it is installed by pip.
Key points: - Versioning is automatic via setuptools_scm, typically derived from Git tags. - Optional extras include an “async” extra to install asynchronous-related dependencies used by the project’s async features and tests.
How to use it: - Install the package from source:
- Editable install for local development: - Install with optional async extras: Or when installing from PyPI:Versioning and releases: - Versions are managed by setuptools_scm from your Git tags. - To prepare a release, tag the commit you want to release:
Building after tagging will produce artifacts with the tagged version.Building distributions: - Ensure you have the build tool installed:
- Build sdist and wheel: - Artifacts will be written to the dist/ directory.Uploading to PyPI (optional): - Check artifacts:
- Upload:tox.ini¶
What it is: - A tox configuration to run tests across multiple Python interpreters (py310, py311, py312, py313, py314). - Ensures the test environments install required dependencies, including the “async” extras. - Provides a coverage environment to execute pytest with coverage reporting.
Prerequisites: - Install tox:
Using pipx is recommended for isolation: - Ensure the targeted Python versions are installed and discoverable (e.g., via pyenv or system packages).Common tasks:
- Run the test suite across all configured Python versions:
- Run tests for a single interpreter:
- Pass arguments through to pytest:
-
Run coverage:
The coverage environment will run pytest with coverage enabled and report results to the console. A coverage data file (e.g., .coverage) may be generated for further reporting. -
Speed up by running environments in parallel:
Notes: - Tox environments install the project along with the async extras so async-related tests and functionality are available. - If tox fails due to missing interpreters, install them (e.g., via pyenv) and ensure they’re on PATH.
Typical Development Workflow¶
-
Create and activate a virtual environment:
-
Install the project (editable) and optional extras if needed:
-
Run tests quickly via pytest (single environment):
-
Validate across all supported Python versions using tox:
-
Generate a coverage report:
-
Build release artifacts:
-
Tag and publish (when ready):
Troubleshooting¶
- Missing Python interpreters in tox:
- Install the required versions (py310–py314) using pyenv or your OS package manager.
-
Recreate tox environments:
-
Version appears as a dirty or local version:
- Ensure you have a clean working tree and a proper Git tag for the release commit.
- setuptools_scm uses Git metadata; verify the repository is not shallow and tags are available locally.