This project uses Poetry for dependency management while maintaining compatibility with Azure Functions deployment via requirements.txt.
The devcontainer automatically installs Poetry and all dependencies when built. The setup includes:
- Poetry and the
poetry-plugin-exportplugin (for generatingrequirements.txt) - Virtual environments are disabled (
virtualenvs.create false) since we're inside a container - All dependencies (including dev dependencies) are installed via
poetry install - Pre-commit hooks are installed automatically via
postCreateCommand
No additional setup is needed when using the devcontainer.
poetry add <package-name>Example:
poetry add requestspoetry add --group dev <package-name>Example:
poetry add --group dev blackpoetry add --group test <package-name>Example:
poetry add --group test pytest-mockAfter adding dependencies, both pyproject.toml and poetry.lock will be updated automatically.
Dependencies use caret (^) version constraints:
^1.24allows versions>=1.24.0and<2.0.0- This allows minor and patch updates while preventing breaking major version changes
Azure Functions requires a requirements.txt file for deployment.
A pre-commit hook automatically exports requirements.txt whenever pyproject.toml or poetry.lock changes. This ensures the requirements file is always in sync when you commit dependency changes.
The hook runs:
poetry export -f requirements.txt --output requirements.txt --without-hashesThe GitHub Actions workflow includes a check that validates requirements.txt is up-to-date with pyproject.toml. If the check fails, it means the requirements.txt file needs to be regenerated.
To fix a failing check:
- Recommended: Simply commit your changes to
poetry.lockorpyproject.toml. The pre-commit hook will automatically updaterequirements.txtfor you. - Alternative: Manually run the export command (see below).
If needed, you can manually export:
poetry export -f requirements.txt --output requirements.txt --without-hashesNote: Only production dependencies are exported. Dev and test dependencies (pytest, ipykernel, etc.) are not included in the deployment.
| File | Purpose |
|---|---|
pyproject.toml |
Poetry configuration and dependency definitions |
poetry.lock |
Locked versions for reproducible builds |
requirements.txt |
Generated file for Azure Functions deployment |
.pre-commit-config.yaml |
Pre-commit hook configuration |
# Install all dependencies
poetry install
# Run tests
poetry run pytest
# Update all dependencies to latest allowed versions
poetry update
# Show outdated packages
poetry show --outdated
# Run pre-commit hooks manually
pre-commit run --all-files