common-python-tasks 0.6.0__tar.gz → 0.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- common_python_tasks-0.7.0/PKG-INFO +406 -0
- common_python_tasks-0.7.0/README.md +374 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/pyproject.toml +9 -4
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/scripts/release_script.py +51 -12
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/data/fastapi/alembic.ini.j2 +7 -8
- common_python_tasks-0.7.0/src/common_python_tasks/data/generic/ruff.toml +6 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/git.py +1 -1
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/github.py +1 -1
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/project.py +16 -14
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/tasks.py +90 -209
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/utils.py +31 -20
- common_python_tasks-0.6.0/PKG-INFO +0 -439
- common_python_tasks-0.6.0/README.md +0 -404
- common_python_tasks-0.6.0/src/common_python_tasks/data/generic/.flake8 +0 -9
- common_python_tasks-0.6.0/src/common_python_tasks/data/generic/.isort.cfg +0 -4
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/.gitignore +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/.poetry/plugins/poetry_dynamic_versioning-1.10.0.dist-info/licenses/LICENSE +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/.poetry/plugins/poetry_plugin_export-1.10.0.dist-info/licenses/LICENSE +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/LICENSE +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/scripts/add_common_python_tasks.py +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/__init__.py +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/__main__.py +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/data/dockerfile_extensions/.gitkeep +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/data/fastapi/compose-base.yml.j2 +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/data/fastapi/compose-db-debug.yml.j2 +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/data/fastapi/compose-db.yml.j2 +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/data/fastapi/compose-debug.yml.j2 +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/data/generic/.coveragerc +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/data/generic/.dockerignore +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/data/generic/Dockerfile.deps.j2 +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/data/generic/Dockerfile.j2 +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/data/generic/cliff.toml +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/data/generic/pytest.ini +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/docker.py +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/docker_compose.py +0 -0
- {common_python_tasks-0.6.0 → common_python_tasks-0.7.0}/src/common_python_tasks/env.py +0 -0
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: common-python-tasks
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: Opinionated Poe the Poet tasks for Python package development.
|
|
5
|
+
Project-URL: Homepage, http://github.com/ci-sourcerer/common-python-tasks
|
|
6
|
+
Project-URL: Source, http://github.com/ci-sourcerer/common-python-tasks.git
|
|
7
|
+
Project-URL: Issues, http://github.com/ci-sourcerer/common-python-tasks/issues
|
|
8
|
+
Author-email: Joseph Asbury <ci_sourcerer@yahoo.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
19
|
+
Requires-Python: <4.0,>=3.11
|
|
20
|
+
Requires-Dist: docker<8.0.0,>=7.1.0
|
|
21
|
+
Requires-Dist: dunamai<2.0.0,>=1.25.0
|
|
22
|
+
Requires-Dist: git-cliff<3.0.0,>=2.12.0
|
|
23
|
+
Requires-Dist: jinja2<4.0.0,>=3.1.6
|
|
24
|
+
Requires-Dist: packaging<27.0,>=26.2
|
|
25
|
+
Requires-Dist: poethepoet-tasks<0.4.0,>=0.3.0
|
|
26
|
+
Requires-Dist: pytest-cov<8.0.0,>=7.0.0
|
|
27
|
+
Requires-Dist: pytest<10.0.0,>=9.0.3
|
|
28
|
+
Requires-Dist: requests<3.0.0,>=2.34.2
|
|
29
|
+
Requires-Dist: ruff<0.17.0,>=0.16.1
|
|
30
|
+
Requires-Dist: tomlkit<0.14.0,>=0.13.3
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# Common Python Tasks
|
|
34
|
+
|
|
35
|
+
`common-python-tasks` provides reusable, opinionated [Poe the Poet](https://poethepoet.natn.io/guides/packaged_tasks.html) tasks for common Python development workflows.
|
|
36
|
+
|
|
37
|
+
It supplies sensible defaults for formatting, linting, testing, packaging, releases, and container workflows while allowing projects to override configuration when needed.
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
40
|
+
|
|
41
|
+
### Manual setup
|
|
42
|
+
|
|
43
|
+
Add `common-python-tasks` as a development dependency from your project root.
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
uv add --dev common-python-tasks==0.7.0
|
|
47
|
+
# or, for Poetry projects
|
|
48
|
+
poetry add --group dev common-python-tasks==0.7.0
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Configure Poe the Poet to expose the default `common` task set.
|
|
52
|
+
|
|
53
|
+
```toml
|
|
54
|
+
[tool.poe]
|
|
55
|
+
include_script = "common_python_tasks:tasks()"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Run the common development tasks.
|
|
59
|
+
|
|
60
|
+
```shell
|
|
61
|
+
poe format
|
|
62
|
+
poe lint
|
|
63
|
+
poe test
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Automated setup
|
|
67
|
+
|
|
68
|
+
The helper script performs the same development-dependency installation and Poe configuration. Download the script for the exact release you want, review it, then run it from your project root.
|
|
69
|
+
|
|
70
|
+
```shell
|
|
71
|
+
curl --fail --silent --show-error --location \
|
|
72
|
+
--output /tmp/add_common_python_tasks.py \
|
|
73
|
+
https://raw.githubusercontent.com/ci-sourcerer/common-python-tasks/v0.7.0/scripts/add_common_python_tasks.py
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Review the downloaded script before executing it.
|
|
77
|
+
|
|
78
|
+
```shell
|
|
79
|
+
less /tmp/add_common_python_tasks.py
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Run the reviewed script with the same pinned package version.
|
|
83
|
+
|
|
84
|
+
```shell
|
|
85
|
+
COMMON_PYTHON_TASKS_VERSION=0.7.0 python3 /tmp/add_common_python_tasks.py
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
To install another release, replace both occurrences of `0.7.0` with that release's version.
|
|
89
|
+
|
|
90
|
+
## Available tasks
|
|
91
|
+
|
|
92
|
+
The generated tables below list public tasks only. Tags identify which tasks are selected by `include_tags` and `exclude_tags`.
|
|
93
|
+
|
|
94
|
+
<!-- tasks-table -->
|
|
95
|
+
|
|
96
|
+
### Daily development
|
|
97
|
+
|
|
98
|
+
| Task | Description | Tags |
|
|
99
|
+
| --- | --- | --- |
|
|
100
|
+
| `test` | Run the test suite with coverage (if pytest-cov is installed). | common, test |
|
|
101
|
+
| `clean` | Clean up temporary files and directories. | clean, common |
|
|
102
|
+
| `format` | Fix import issues and format Python code with Ruff. | common, format |
|
|
103
|
+
| `lint` | Check Python lint and formatting with Ruff. | common, lint |
|
|
104
|
+
|
|
105
|
+
### Packaging and releases
|
|
106
|
+
|
|
107
|
+
| Task | Description | Tags |
|
|
108
|
+
| --- | --- | --- |
|
|
109
|
+
| `publish-package` | Publish the package to the PyPI server. | common, packaging |
|
|
110
|
+
| `publish-github-release` | Publish or update a GitHub Release for the current repository. | common, packaging, release |
|
|
111
|
+
| `update-dependencies` | Update project dependencies with Poetry or uv. | common, packaging |
|
|
112
|
+
| `build-package` | Build the package (wheel and sdist). | build, common, packaging |
|
|
113
|
+
| `bump-version` | Bump the project version. | common, packaging |
|
|
114
|
+
| `changelog` | Print the changelog for the current version based on git history and git-cliff. | common, packaging, release |
|
|
115
|
+
| `release` | Run a full release flow for package and containers. | common, containers, packaging, release |
|
|
116
|
+
|
|
117
|
+
### Container images
|
|
118
|
+
|
|
119
|
+
| Task | Description | Tags |
|
|
120
|
+
| --- | --- | --- |
|
|
121
|
+
| `build-image` | Build the container image for this project using the Dockerfile template. | build, containers |
|
|
122
|
+
| `build-deps-image` | Build only the container dependency collector image for this project. | build, containers |
|
|
123
|
+
| `run-container` | Run the Docker image as a container for this project. By default, this will run the most-recently-built tag for the project's image. | containers |
|
|
124
|
+
| `push-image` | Push the Docker image for this project to the container registry. | containers, packaging, release |
|
|
125
|
+
| `build` | Build the project and its containers. | common, containers, packaging |
|
|
126
|
+
| `container-shell` | Run the debug image with an interactive shell. | containers, debug |
|
|
127
|
+
|
|
128
|
+
### Development stacks
|
|
129
|
+
|
|
130
|
+
| Task | Description | Tags |
|
|
131
|
+
| --- | --- | --- |
|
|
132
|
+
| `stack-up` | Bring up the development stack for the application. | containers, fastapi, web |
|
|
133
|
+
| `stack-down` | Bring down the development stack for the application. | containers, fastapi, web |
|
|
134
|
+
| `reset-db` | Reset the database by deleting the database volume. | containers, database, fastapi, web |
|
|
135
|
+
| `run-db-migrations` | Run database migrations. | containers, database, fastapi, web |
|
|
136
|
+
| `db-shell` | Open a psql shell to the database container. | containers, database, fastapi, web |
|
|
137
|
+
|
|
138
|
+
<!-- end-tasks-table -->
|
|
139
|
+
|
|
140
|
+
## Configuration and requirements
|
|
141
|
+
|
|
142
|
+
### Requirements
|
|
143
|
+
|
|
144
|
+
Every project needs a `pyproject.toml` file at its root and Poe the Poet available in its development environment.
|
|
145
|
+
|
|
146
|
+
Tasks that install, build, publish, or update dependencies also require either Poetry or uv. Package and release tasks need a resolvable project version from `project.version`, Poetry's version resolution, or Git tags. Dynamic-versioning plugins are supported but are not a baseline requirement.
|
|
147
|
+
|
|
148
|
+
### Task selection
|
|
149
|
+
|
|
150
|
+
Calling `tasks()` without arguments exposes the default `common` task set.
|
|
151
|
+
|
|
152
|
+
```toml
|
|
153
|
+
[tool.poe]
|
|
154
|
+
include_script = "common_python_tasks:tasks()"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Select optional task groups with tags when your project needs them.
|
|
158
|
+
|
|
159
|
+
```toml
|
|
160
|
+
[tool.poe]
|
|
161
|
+
include_script = "common_python_tasks:tasks(include_tags=['common', 'containers'])"
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The `containers` tag also includes container-based development-stack tasks. Use the tags in the task tables to tailor a smaller task set.
|
|
165
|
+
|
|
166
|
+
### Package manager backend selection
|
|
167
|
+
|
|
168
|
+
Packaging-related tasks, including `build-package`, `publish-package`, release version resolution, and container build metadata, support Poetry and uv.
|
|
169
|
+
|
|
170
|
+
Backend selection uses this precedence.
|
|
171
|
+
|
|
172
|
+
1. `COMMON_PYTHON_TASKS_PACKAGE_MANAGER`
|
|
173
|
+
2. `COMMON_PYTHON_TASKS_BUILD_TOOL`
|
|
174
|
+
3. `PACKAGE_MANAGER`
|
|
175
|
+
4. Auto-discovery (`auto`) based on installed tools and project metadata
|
|
176
|
+
|
|
177
|
+
Supported values are `poetry`, `uv`, and `auto`.
|
|
178
|
+
|
|
179
|
+
### Configuration precedence
|
|
180
|
+
|
|
181
|
+
For pytest and coverage, configuration resolves in the following order.
|
|
182
|
+
|
|
183
|
+
1. Matching `pyproject.toml` sections such as `[tool.pytest.ini_options]` and `[tool.coverage]`
|
|
184
|
+
2. Environment variables that specify a configuration path
|
|
185
|
+
3. Local configuration files in the project root
|
|
186
|
+
4. Bundled defaults from [`src/common_python_tasks/data`](src/common_python_tasks/data)
|
|
187
|
+
|
|
188
|
+
Ruff uses `RUFF_CONFIG` when set. Otherwise it discovers `.ruff.toml`, `ruff.toml`, or a `[tool.ruff]` section in `pyproject.toml`. When no project configuration is available, the tasks use the bundled Ruff defaults. Ruff configuration follows Ruff's native file precedence, so `.ruff.toml` takes precedence over `ruff.toml`, which takes precedence over `pyproject.toml` in the same directory.
|
|
189
|
+
|
|
190
|
+
The `format` task first applies safe fixes for unused imports and import sorting, then runs the Ruff formatter. The `lint` task checks both Ruff lint rules and formatting without changing files.
|
|
191
|
+
|
|
192
|
+
### Configuration examples
|
|
193
|
+
|
|
194
|
+
After installing the package, a minimal project configuration looks like this.
|
|
195
|
+
|
|
196
|
+
```toml
|
|
197
|
+
[project]
|
|
198
|
+
name = "simple-cli-tool"
|
|
199
|
+
version = "0.7.0"
|
|
200
|
+
|
|
201
|
+
[tool.poe]
|
|
202
|
+
include_script = "common_python_tasks:tasks()"
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
A container-based project can select the container task group and set its image details.
|
|
206
|
+
|
|
207
|
+
```toml
|
|
208
|
+
[tool.poe]
|
|
209
|
+
include_script = "common_python_tasks:tasks(include_tags=['common', 'containers'])"
|
|
210
|
+
|
|
211
|
+
[tool.poe.env]
|
|
212
|
+
CONTAINER_REGISTRY_USERNAME = "myusername"
|
|
213
|
+
PACKAGE_NAME = "containerized-app"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
The `test` task automatically uses pytest configuration in `pyproject.toml`.
|
|
217
|
+
|
|
218
|
+
```toml
|
|
219
|
+
[tool.pytest.ini_options]
|
|
220
|
+
testpaths = ["tests", "integration"]
|
|
221
|
+
addopts = "-ra"
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Environment variables
|
|
225
|
+
|
|
226
|
+
#### Task configuration files
|
|
227
|
+
|
|
228
|
+
- `PYTEST_CONFIG`: Path to the pytest configuration file
|
|
229
|
+
- `COVERAGE_RCFILE`: Path to the coverage configuration file
|
|
230
|
+
- `RUFF_CONFIG`: Path to a Ruff TOML configuration file
|
|
231
|
+
|
|
232
|
+
#### Project and package settings
|
|
233
|
+
|
|
234
|
+
- `PACKAGE_NAME`: Overrides the package name inferred from `pyproject.toml`
|
|
235
|
+
- `COMMON_PYTHON_TASKS_PACKAGE_MANAGER`: Selects the package-manager backend as `poetry`, `uv`, or `auto`
|
|
236
|
+
- `COMMON_PYTHON_TASKS_BUILD_TOOL`: Alias for `COMMON_PYTHON_TASKS_PACKAGE_MANAGER`
|
|
237
|
+
- `PACKAGE_MANAGER`: Alias for `COMMON_PYTHON_TASKS_PACKAGE_MANAGER`
|
|
238
|
+
|
|
239
|
+
#### Container image settings
|
|
240
|
+
|
|
241
|
+
- `CONTAINER_REGISTRY_USERNAME`: Container-registry username for image tagging; the default is the current local user
|
|
242
|
+
- `CONTAINER_REGISTRY_URL`: Registry URL with a default of `docker.io/{username}`
|
|
243
|
+
- `CONTAINER_BUILD_ARGS`: Additional Docker build arguments in `KEY=VALUE:OTHER=VALUE` format. Escape literal colons as `\:` or quote the complete value.
|
|
244
|
+
- `CONTAINER_EXTENSION_FILES`: Colon-delimited local extension Dockerfile paths. Escape literal colons as `\:` or quote the complete path.
|
|
245
|
+
- `CONTAINER_EXTENSIONS`: Colon-delimited extension-bundle names or parameterized values. Escape literal colons as `\:` or quote the complete value.
|
|
246
|
+
- `CONTAINER_ENV`: Colon-delimited `KEY=VALUE` declarations injected into the rendered Dockerfile's builder stage. Escape literal colons as `\:` or quote the complete value.
|
|
247
|
+
- `.containerenv`: A project-root file that can supply the same declarations. It is loaded before the `container_envfile` task argument, `CONTAINER_ENV`, and the `container_env` task argument.
|
|
248
|
+
- `CONTAINER_PRUNE_KEEP`: Image-pruning policy after builds. `-1` keeps all images, `0` keeps only the latest, and `N` keeps the latest plus `N` prior images.
|
|
249
|
+
- `CUSTOM_ENTRYPOINT`: Custom container entrypoint script. The value must match a key in `[project].scripts`.
|
|
250
|
+
- `CONTAINER_DEPS_CONTENT`: Inline Dockerfile instructions for a dependency image that installs artifacts into `/tmp/deps`
|
|
251
|
+
- `CONTAINER_DEPS_FILE`: One or more dependency-image Dockerfiles. It accepts colon-delimited paths with literal colons escaped as `\:` and is used only when `CONTAINER_DEPS_CONTENT` is unset.
|
|
252
|
+
- `CONTAINER_DEPS_MAPPINGS`: Space-delimited `name:/target/path` entries for copying items from `/tmp/deps`. It is used only when no dependency move script is set.
|
|
253
|
+
- `CONTAINER_DEPS_MOVE_SCRIPT`: Raw executable script to run after `/tmp/deps` is copied into the image
|
|
254
|
+
- `CONTAINER_DEPS_MOVE_SCRIPT_PATH`: Host path to a dependency move script. This takes precedence over `CONTAINER_DEPS_MOVE_SCRIPT`.
|
|
255
|
+
|
|
256
|
+
#### Release settings
|
|
257
|
+
|
|
258
|
+
- `GITHUB_RELEASE_ASSETS`: Colon-delimited file paths or glob patterns to attach to a GitHub Release. The default is `dist/*`; escape literal colons as `\:` or quote the complete path.
|
|
259
|
+
- `SKIP_GITHUB_RELEASE`: Truthy value that skips GitHub Release publication
|
|
260
|
+
- `GITHUB_TOKEN` or `GH_TOKEN`: GitHub authentication token for releases and assets
|
|
261
|
+
- `GITHUB_REPOSITORY`: Optional repository-slug override for GitHub Release publication
|
|
262
|
+
- `GITHUB_API_URL` and `GITHUB_SERVER_URL`: GitHub Enterprise API-host settings
|
|
263
|
+
- `GITHUB_RELEASE_TAG`: Optional release tag name
|
|
264
|
+
- `GITHUB_RELEASE_NAME`: Optional release title
|
|
265
|
+
- `GITHUB_RELEASE_BODY`: Optional release body
|
|
266
|
+
- `RELEASE_UPDATE_CHANGELOG`: Truthy value that prepends `git-cliff --unreleased --tag "$RELEASE_TAG"` output to `CHANGELOG.md` before the release tag is created. It is enabled by default.
|
|
267
|
+
- `RELEASE_PRE_SCRIPT`: Optional shell command to run before release steps
|
|
268
|
+
- `RELEASE_POST_SCRIPT`: Optional shell command to run after release completion
|
|
269
|
+
- Release hooks receive `RELEASE_SCRIPT_PHASE`, `RELEASE_TAG`, `RELEASE_VERSION`, `RELEASE_STAGE`, `RELEASE_COMPONENT`, and `RELEASE_DRY_RUN`.
|
|
270
|
+
|
|
271
|
+
#### Docker Compose settings
|
|
272
|
+
|
|
273
|
+
- `COMPOSE_TYPE`: Application-stack type, such as `fastapi`
|
|
274
|
+
- `COMPOSE_ADDONS`: Colon-delimited services to include, such as `db`
|
|
275
|
+
- `COMPOSE_FILE`: Override for all compose files with colon-delimited paths
|
|
276
|
+
- `COMPOSE_OVERLAY_FILES`: Additional compose files to merge with colon-delimited paths
|
|
277
|
+
- `API_PORT`: API server port with a default of `8080`
|
|
278
|
+
- `SECRET_KEY`: Application secret key generated automatically when unset
|
|
279
|
+
- `ENVIRONMENT`: Environment name with a default of `production`
|
|
280
|
+
- `DEBUG_PORT`: Python debugger port in debug mode with a default of `5678`
|
|
281
|
+
- `DB_PORT`: PostgreSQL port with a default of `5432`
|
|
282
|
+
- `DB_USER`: Database user with a default of the package name
|
|
283
|
+
- `DB_BASE`: Database name with a default of the package name
|
|
284
|
+
- `DB_PASS`: Database password generated automatically when unset
|
|
285
|
+
- `POSTGRES_VERSION`: PostgreSQL version with a default of `17`
|
|
286
|
+
- `ADMINER_PORT`: Adminer web UI port with a default of `8081`
|
|
287
|
+
|
|
288
|
+
#### Debugging
|
|
289
|
+
|
|
290
|
+
- `COMMON_PYTHON_TASKS_LOG_LEVEL`: Set to `DEBUG` to show detailed configuration resolution
|
|
291
|
+
|
|
292
|
+
## Containers and development stacks
|
|
293
|
+
|
|
294
|
+
Docker Compose development-stack tasks are available when the `containers` tag is selected. The current stack supports FastAPI applications and an optional PostgreSQL database.
|
|
295
|
+
|
|
296
|
+
### Stack configuration
|
|
297
|
+
|
|
298
|
+
Set `COMPOSE_TYPE` to select the application stack. `fastapi` is currently supported and includes optional database support and Alembic migrations.
|
|
299
|
+
|
|
300
|
+
```toml
|
|
301
|
+
[tool.poe.env]
|
|
302
|
+
COMPOSE_TYPE = "fastapi"
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Set `COMPOSE_ADDONS` to select extra services. Addon names are colon-delimited, and `db` is the currently available addon.
|
|
306
|
+
|
|
307
|
+
```toml
|
|
308
|
+
[tool.poe.env]
|
|
309
|
+
COMPOSE_ADDONS = "db"
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Compose-file customization
|
|
313
|
+
|
|
314
|
+
The compose setup resolves files in this precedence order.
|
|
315
|
+
|
|
316
|
+
1. **Environment override** uses `COMPOSE_FILE` with colon-delimited paths.
|
|
317
|
+
2. **Automatically loaded files** are based on `COMPOSE_TYPE` and `COMPOSE_ADDONS`.
|
|
318
|
+
- `compose-base.yml` provides the core application service.
|
|
319
|
+
- `compose-{addon}.yml` adds one file per addon, such as `compose-db.yml`.
|
|
320
|
+
- `compose-debug.yml` is used when the `--debug` flag is present.
|
|
321
|
+
- `compose-{addon}-debug.yml` provides debug overlays for addons.
|
|
322
|
+
3. **Additional overlays** use `COMPOSE_OVERLAY_FILES` with colon-delimited paths.
|
|
323
|
+
|
|
324
|
+
You can provide local compose files or allow the tasks to use bundled templates.
|
|
325
|
+
|
|
326
|
+
### FastAPI stack
|
|
327
|
+
|
|
328
|
+
The FastAPI stack uses the standard Dockerfile supplied by this package. Configure its ports, credentials, and database settings through the [Docker Compose settings](#docker-compose-settings) reference.
|
|
329
|
+
|
|
330
|
+
## Troubleshooting
|
|
331
|
+
|
|
332
|
+
### Tasks not showing up with `poe --help`
|
|
333
|
+
|
|
334
|
+
Check the `[tool.poe]` configuration in `pyproject.toml` and use `include_script`.
|
|
335
|
+
|
|
336
|
+
```toml
|
|
337
|
+
# Correct
|
|
338
|
+
[tool.poe]
|
|
339
|
+
include_script = "common_python_tasks:tasks(exclude_tags=['internal'])"
|
|
340
|
+
|
|
341
|
+
# Incorrect
|
|
342
|
+
[tool.poe]
|
|
343
|
+
includes = "common_python_tasks:tasks"
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Config files not being used
|
|
347
|
+
|
|
348
|
+
Review the [configuration precedence](#configuration-precedence) and enable debug logging to see the selected configuration.
|
|
349
|
+
|
|
350
|
+
```shell
|
|
351
|
+
COMMON_PYTHON_TASKS_LOG_LEVEL=DEBUG poe test
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### GitHub Release assets not uploading
|
|
355
|
+
|
|
356
|
+
Confirm that `dist/` contains the built wheels and source distributions. You can override the default asset selection with `GITHUB_RELEASE_ASSETS`.
|
|
357
|
+
|
|
358
|
+
```shell
|
|
359
|
+
GITHUB_RELEASE_ASSETS="dist/*.whl:dist/*.tar.gz" poe publish-github-release
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### Container build fails with "unable to find package"
|
|
363
|
+
|
|
364
|
+
Check that `pyproject.toml` has a correct package name and the package-discovery settings required by its build backend. For Poetry projects, this commonly includes `[tool.poetry] packages = [{ include = "your_package", from = "src" }]`.
|
|
365
|
+
|
|
366
|
+
### Stack fails to start or services cannot connect
|
|
367
|
+
|
|
368
|
+
Check the following conditions.
|
|
369
|
+
|
|
370
|
+
- `COMPOSE_TYPE` is set and the required addon is selected.
|
|
371
|
+
- Default ports are available, including `8080` for the API, `5432` for PostgreSQL, and `8081` for Adminer.
|
|
372
|
+
- The Docker daemon is running, as verified with `docker info`.
|
|
373
|
+
- Service logs are available through `docker compose logs` in the project directory.
|
|
374
|
+
|
|
375
|
+
### Database migrations fail
|
|
376
|
+
|
|
377
|
+
Verify that the `db` addon is selected, Alembic is configured at the expected location, and its credentials match the generated `.env` values. Use `poe db-shell` to inspect the database manually.
|
|
378
|
+
|
|
379
|
+
### Secrets are not generated
|
|
380
|
+
|
|
381
|
+
Ensure the project-root `.env` file is writable and inspect its permissions with `ls -la .env`. You can also generate a value manually with `python -c "import secrets; print(secrets.token_hex(32))"`.
|
|
382
|
+
|
|
383
|
+
## Design choices
|
|
384
|
+
|
|
385
|
+
### Dockerfile design
|
|
386
|
+
|
|
387
|
+
See the [standard Dockerfile template](src/common_python_tasks/data/generic/Dockerfile.j2) for the implementation.
|
|
388
|
+
|
|
389
|
+
- Multi-stage build: The build stage installs the selected package-manager backend and builds a wheel. The runtime stage installs only the wheel to keep the final image slim and reproducible.
|
|
390
|
+
- Cache mounts: Pip and package-manager cache mounts speed up iterative builds without bloating the final image.
|
|
391
|
+
- Explicit build arguments: `PYTHON_VERSION`, `PACKAGE_MANAGER`, `PACKAGE_MANAGER_VERSION`, `PACKAGE_NAME`, `AUTHORS`, `GIT_COMMIT`, and `CUSTOM_ENTRYPOINT` make image metadata and behavior predictable and auditable.
|
|
392
|
+
- Optional debug stage: The image exports and installs the `debug` dependency group only when present and does not include it in the default final image.
|
|
393
|
+
- Stable package path: Symlinks give entrypoints and consumers consistent `/pkg` and `/_$PACKAGE_NAME` paths regardless of wheel layout.
|
|
394
|
+
- Safe entrypoint selection: The default entrypoint resolves the console script matching the package name and falls back to `python`. `CUSTOM_ENTRYPOINT` is validated against `[project].scripts`.
|
|
395
|
+
- Minimal final image: The standard slim Python base, cache cleanup, and explicit `runtime` final target keep the default image small.
|
|
396
|
+
|
|
397
|
+
## Project notes
|
|
398
|
+
|
|
399
|
+
- This project dogfoods itself. Set `PYTHONPATH=src` when running its tasks locally so Poe uses the local package rather than the installed version.
|
|
400
|
+
- `RELEASE_UPDATE_CHANGELOG` is enabled by default and prepends the generated changelog section before the release tag is created. Set it to a falsy value to manage changelog commits yourself.
|
|
401
|
+
- `RELEASE_PRE_SCRIPT` and `RELEASE_POST_SCRIPT` are advanced hooks for release-specific work, such as updating a version reference in another file.
|
|
402
|
+
- The project is in alpha status, so breaking changes may occur between minor versions before 1.0.0.
|
|
403
|
+
|
|
404
|
+
## Contributing
|
|
405
|
+
|
|
406
|
+
Contributions and feedback are welcome. Please open an issue or discussion to talk through a change before submitting a pull request.
|