common-python-tasks 0.3.1__tar.gz → 0.4.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.3.1 → common_python_tasks-0.4.0}/PKG-INFO +92 -101
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/README.md +88 -100
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/pyproject.toml +4 -1
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/generic/.dockerignore +0 -2
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/generic/.pytest_cache/v/cache/lastfailed +2 -1
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/generic/.pytest_cache/v/cache/nodeids +155 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/generic/Dockerfile.j2 +7 -3
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/docker.py +98 -39
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/docker_compose.py +8 -5
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/env.py +53 -12
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/git.py +24 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/github.py +19 -40
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/project.py +29 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/tasks.py +172 -62
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/utils.py +166 -13
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/LICENSE +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/__init__.py +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/__main__.py +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/dockerfile_extensions/.gitkeep +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/fastapi/alembic.ini.j2 +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/fastapi/compose-base.yml.j2 +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/fastapi/compose-db-debug.yml.j2 +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/fastapi/compose-db.yml.j2 +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/fastapi/compose-debug.yml.j2 +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/generic/.coveragerc +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/generic/.flake8 +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/generic/.isort.cfg +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/generic/.pytest_cache/.gitignore +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/generic/.pytest_cache/CACHEDIR.TAG +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/generic/.pytest_cache/README.md +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/generic/Dockerfile.deps.j2 +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/generic/cliff.toml +0 -0
- {common_python_tasks-0.3.1 → common_python_tasks-0.4.0}/src/common_python_tasks/data/generic/pytest.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: common-python-tasks
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Opinionated Poe the Poet tasks for Python package development.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -17,14 +17,17 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
17
17
|
Classifier: Topic :: Software Development :: Build Tools
|
|
18
18
|
Requires-Dist: autoflake (>=2.3.1,<3.0.0)
|
|
19
19
|
Requires-Dist: black (>=26.3.1,<27.0.0)
|
|
20
|
+
Requires-Dist: docker (>=7.1.0,<8.0.0)
|
|
20
21
|
Requires-Dist: dunamai (>=1.25.0,<2.0.0)
|
|
21
22
|
Requires-Dist: flake8 (>=7.3.0,<8.0.0)
|
|
22
23
|
Requires-Dist: git-cliff (>=2.12.0,<3.0.0)
|
|
23
24
|
Requires-Dist: isort (>=8.0.1,<9.0.0)
|
|
24
25
|
Requires-Dist: jinja2 (>=3.1.6,<4.0.0)
|
|
26
|
+
Requires-Dist: packaging (>=26.2,<27.0)
|
|
25
27
|
Requires-Dist: poethepoet-tasks (>=0.3.0,<0.4.0)
|
|
26
28
|
Requires-Dist: pytest (>=9.0.3,<10.0.0)
|
|
27
29
|
Requires-Dist: pytest-cov (>=7.0.0,<8.0.0)
|
|
30
|
+
Requires-Dist: requests (>=2.34.2,<3.0.0)
|
|
28
31
|
Requires-Dist: tomlkit (>=0.13.3,<0.14.0)
|
|
29
32
|
Project-URL: Homepage, http://github.com/ci-sourcerer/common-python-tasks
|
|
30
33
|
Project-URL: Issues, http://github.com/ci-sourcerer/common-python-tasks/issues
|
|
@@ -35,7 +38,7 @@ Description-Content-Type: text/markdown
|
|
|
35
38
|
|
|
36
39
|
This package is a collection of (very) opinionated [Poe the Poet](https://poethepoet.natn.io/guides/packaged_tasks.html) Python tasks for common Python development workflows.
|
|
37
40
|
|
|
38
|
-
Instead of writing your own tasks for formatting, linting, testing, packaging, and more, you can use these
|
|
41
|
+
Instead of writing your own tasks for formatting, linting, testing, packaging, and more, you can use these prebuilt tasks that work immediately with reasonable defaults and support configuration overrides when needed. In the past, I found myself copying and pasting the same task definitions across projects, and this package is my attempt to DRY up that workflow and provide a single source of truth for common Python development tasks. I hope you can use them too.
|
|
39
42
|
|
|
40
43
|
## Quick start
|
|
41
44
|
|
|
@@ -50,7 +53,7 @@ curl -sSL https://api.github.com/repos/ci-sourcerer/common-python-tasks/contents
|
|
|
50
53
|
To install a specific release, set the environment variable `COMMON_PYTHON_TASKS_VERSION`.
|
|
51
54
|
|
|
52
55
|
```shell
|
|
53
|
-
COMMON_PYTHON_TASKS_VERSION=0.
|
|
56
|
+
COMMON_PYTHON_TASKS_VERSION=0.4.0 \
|
|
54
57
|
sh -c "$(curl -sSL https://api.github.com/repos/ci-sourcerer/common-python-tasks/contents/scripts/add-common-python-tasks.sh | jq -r '.content' | base64 -d)"
|
|
55
58
|
```
|
|
56
59
|
|
|
@@ -70,10 +73,8 @@ There's no real reason to run the automated script; I just like automating every
|
|
|
70
73
|
|
|
71
74
|
```toml
|
|
72
75
|
[project]
|
|
73
|
-
name = "my-awesome-project"
|
|
74
|
-
version = "0.3.1"
|
|
75
76
|
dependencies = [
|
|
76
|
-
"common-python-tasks==0.
|
|
77
|
+
"common-python-tasks==0.4.0" # Always pin to a specific version
|
|
77
78
|
]
|
|
78
79
|
|
|
79
80
|
[tool.poe]
|
|
@@ -106,6 +107,7 @@ Internal tasks are used by other tasks and are not meant to be run directly.
|
|
|
106
107
|
| `format` | Format Python code with autoflake, black, and isort. | common, format |
|
|
107
108
|
| `lint` | Lint Python code with autoflake, black, isort, and flake8. | common, lint |
|
|
108
109
|
| `build-image` | Build the container image for this project using the Dockerfile template. | build, containers |
|
|
110
|
+
| `build-deps-image` | Build only the container dependency collector image for this project. | build, containers |
|
|
109
111
|
| `run-container` | Run the Docker image as a container for this project. By default (when `tag` is `None`) this will run the most-recently-built tag for the project's image. | containers |
|
|
110
112
|
| `push-image` | Push the Docker image for this project to the container registry. | containers, packaging, release |
|
|
111
113
|
| `publish-package` | Publish the package to the PyPI server. | common, packaging |
|
|
@@ -133,7 +135,7 @@ Some tasks of certain tags provide Docker Compose-based development stacks for r
|
|
|
133
135
|
|
|
134
136
|
Specifies the type of application stack. Currently supported:
|
|
135
137
|
|
|
136
|
-
- `fastapi
|
|
138
|
+
- `fastapi`: FastAPI application with optional database support and Alembic migrations
|
|
137
139
|
|
|
138
140
|
Set via environment variable:
|
|
139
141
|
|
|
@@ -146,7 +148,7 @@ COMPOSE_TYPE = "fastapi"
|
|
|
146
148
|
|
|
147
149
|
Colon-separated list of additional services to include. Available addons:
|
|
148
150
|
|
|
149
|
-
- `db
|
|
151
|
+
- `db`: PostgreSQL database with Alembic migration support and Adminer web UI
|
|
150
152
|
|
|
151
153
|
Example:
|
|
152
154
|
|
|
@@ -161,13 +163,13 @@ For multiple addons (future): `COMPOSE_ADDONS = "db:redis:cache"`
|
|
|
161
163
|
|
|
162
164
|
The compose setup follows this precedence.
|
|
163
165
|
|
|
164
|
-
1. **Environment override
|
|
165
|
-
2. **
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
3. **Additional overlays
|
|
166
|
+
1. **Environment override**: `COMPOSE_FILE` environment variable with colon separated paths
|
|
167
|
+
2. **Automatically loaded files**: Based on `COMPOSE_TYPE` and `COMPOSE_ADDONS`
|
|
168
|
+
- `compose-base.yml`: Core application service
|
|
169
|
+
- `compose-{addon}.yml`: One file for each addon; for example, `compose-db.yml`
|
|
170
|
+
- `compose-debug.yml`: Used when the `--debug` flag is present
|
|
171
|
+
- `compose-{addon}-debug.yml`: Debug overlays for addons
|
|
172
|
+
3. **Additional overlays**: `COMPOSE_OVERLAY_FILES` with colon separated paths
|
|
171
173
|
|
|
172
174
|
You can provide local compose files or let the tasks use bundled templates.
|
|
173
175
|
|
|
@@ -177,16 +179,16 @@ The `fastapi` stack includes a service for your FastAPI application. It uses the
|
|
|
177
179
|
|
|
178
180
|
#### Environment variables
|
|
179
181
|
|
|
180
|
-
- `API_PORT
|
|
181
|
-
- `SECRET_KEY
|
|
182
|
-
- `ENVIRONMENT
|
|
183
|
-
- `DEBUG_PORT
|
|
184
|
-
- `DB_PORT
|
|
185
|
-
- `DB_USER
|
|
186
|
-
- `DB_BASE
|
|
187
|
-
- `DB_PASS
|
|
188
|
-
- `POSTGRES_VERSION
|
|
189
|
-
- `ADMINER_PORT
|
|
182
|
+
- `API_PORT`: Port for the API server (default: `8080`)
|
|
183
|
+
- `SECRET_KEY`: Application secret key; generated automatically and stored in `.env` if not set
|
|
184
|
+
- `ENVIRONMENT`: Environment name such as `development` or `production` (default: `production`)
|
|
185
|
+
- `DEBUG_PORT`: Port for the Python debugger when using `--debug` (default: `5678`)
|
|
186
|
+
- `DB_PORT`: PostgreSQL port (default: `5432`)
|
|
187
|
+
- `DB_USER`: Database user (default: package name)
|
|
188
|
+
- `DB_BASE`: Database name (default: package name)
|
|
189
|
+
- `DB_PASS`: Database password; generated automatically and stored in `.env` if not set
|
|
190
|
+
- `POSTGRES_VERSION`: PostgreSQL Docker image version (default: `17`)
|
|
191
|
+
- `ADMINER_PORT`: Adminer web UI port (default: `8081`)
|
|
190
192
|
|
|
191
193
|
## How it works
|
|
192
194
|
|
|
@@ -202,10 +204,10 @@ Your project must meet the following requirements.
|
|
|
202
204
|
|
|
203
205
|
Tasks that need configuration files (`pytest`, `coverage`, `flake8`, `isort`) follow this order of precedence.
|
|
204
206
|
|
|
205
|
-
1. **`pyproject.toml` sections
|
|
206
|
-
2. **Environment variables
|
|
207
|
-
3. **Local config files
|
|
208
|
-
4. **Bundled defaults
|
|
207
|
+
1. **`pyproject.toml` sections**: `[tool.pytest]`, `[tool.coverage]`, `[tool.isort]` take priority
|
|
208
|
+
2. **Environment variables**: Override config paths; see [Environment Variables](#environment-variables)
|
|
209
|
+
3. **Local config files**: `pytest.ini`, `.coveragerc`, `.flake8`, `.isort.cfg` in the project root
|
|
210
|
+
4. **Bundled defaults**: Sensible defaults included with this package, found in the [`src/common_python_tasks/data`](src/common_python_tasks/data) directory
|
|
209
211
|
|
|
210
212
|
You can start with zero configuration and customize as needed.
|
|
211
213
|
|
|
@@ -215,68 +217,68 @@ You can start with zero configuration and customize as needed.
|
|
|
215
217
|
|
|
216
218
|
The following environment variables configure the paths to configuration files.
|
|
217
219
|
|
|
218
|
-
- `PYTEST_CONFIG
|
|
219
|
-
- `COVERAGE_RCFILE
|
|
220
|
-
- `FLAKE8_CONFIG
|
|
221
|
-
- `ISORT_CONFIG
|
|
220
|
+
- `PYTEST_CONFIG`: Specifies the path to the pytest configuration file
|
|
221
|
+
- `COVERAGE_RCFILE`: Specifies the path to the coverage configuration file
|
|
222
|
+
- `FLAKE8_CONFIG`: Specifies the path to the flake8 configuration file
|
|
223
|
+
- `ISORT_CONFIG`: Specifies the path to the isort configuration file
|
|
222
224
|
|
|
223
225
|
#### Package/Container settings
|
|
224
226
|
|
|
225
227
|
The following environment variables configure package and container behavior.
|
|
226
228
|
|
|
227
|
-
- `PACKAGE_NAME
|
|
228
|
-
- `POETRY_VERSION
|
|
229
|
-
- `
|
|
230
|
-
- `CONTAINER_REGISTRY_URL
|
|
231
|
-
- `CONTAINER_BUILD_ARGS
|
|
232
|
-
- `CONTAINER_EXTENSION_FILES
|
|
233
|
-
- `CONTAINER_EXTENSIONS
|
|
234
|
-
- `CONTAINER_ENV
|
|
235
|
-
- `.containerenv
|
|
236
|
-
- `CONTAINER_PRUNE_KEEP
|
|
237
|
-
- `
|
|
238
|
-
- `CONTAINER_DEPS_CONTENT
|
|
239
|
-
- `CONTAINER_DEPS_FILE
|
|
240
|
-
- `CONTAINER_DEPS_MAPPINGS
|
|
241
|
-
- `CONTAINER_DEPS_MOVE_SCRIPT
|
|
242
|
-
- `CONTAINER_DEPS_MOVE_SCRIPT_PATH
|
|
243
|
-
- `GITHUB_RELEASE_ASSETS
|
|
244
|
-
- `SKIP_GITHUB_RELEASE
|
|
245
|
-
- `GITHUB_TOKEN` or `GH_TOKEN
|
|
246
|
-
- `GITHUB_REPOSITORY
|
|
247
|
-
- `GITHUB_API_URL` and `GITHUB_SERVER_URL
|
|
248
|
-
- `GITHUB_RELEASE_TAG
|
|
249
|
-
- `GITHUB_RELEASE_NAME
|
|
250
|
-
- `GITHUB_RELEASE_BODY
|
|
251
|
-
- `RELEASE_UPDATE_CHANGELOG
|
|
252
|
-
- `RELEASE_PRE_SCRIPT
|
|
253
|
-
- `RELEASE_POST_SCRIPT
|
|
254
|
-
- Hook commands
|
|
229
|
+
- `PACKAGE_NAME`: Overrides the package name; the default comes from `pyproject.toml`
|
|
230
|
+
- `POETRY_VERSION`: Overrides the Poetry version for container builds
|
|
231
|
+
- `CONTAINER_REGISTRY_USERNAME`: Specifies the container registry username for image tagging; the default is the current local user
|
|
232
|
+
- `CONTAINER_REGISTRY_URL`: Specifies the registry URL (default: `docker.io/{username}`)
|
|
233
|
+
- `CONTAINER_BUILD_ARGS`: Provides additional Docker build arguments in `KEY=VALUE:OTHER=VALUE` format
|
|
234
|
+
- `CONTAINER_EXTENSION_FILES`: Specifies colon delimited local extension Dockerfile paths to include in the rendered build
|
|
235
|
+
- `CONTAINER_EXTENSIONS`: Specifies colon delimited extension bundle names or parameterized bundle values to include in the rendered build
|
|
236
|
+
- `CONTAINER_ENV`: Provides colon delimited `KEY=VALUE` declarations to inject into the builder stage of the rendered Dockerfile
|
|
237
|
+
- `.containerenv`: Can also supply the same declarations from a file in the project root. It is loaded first, then `container_envfile`, then `CONTAINER_ENV`, and finally `container_env`.
|
|
238
|
+
- `CONTAINER_PRUNE_KEEP`: Controls image pruning after builds (`-1` keeps all, `0` keeps the latest only, `N` keeps the latest plus `N` previous)
|
|
239
|
+
- `CUSTOM_ENTRYPOINT`: Specifies a custom entrypoint script name for containers
|
|
240
|
+
- `CONTAINER_DEPS_CONTENT`: Supplies inline Dockerfile instructions for a dependency image that installs artifacts into `/tmp/deps`
|
|
241
|
+
- `CONTAINER_DEPS_FILE`: Points to one or more explicit Dockerfiles to build the dependency image. It may be a colon delimited list of file paths and is used only when `CONTAINER_DEPS_CONTENT` is unset
|
|
242
|
+
- `CONTAINER_DEPS_MAPPINGS`: Maps copied dependency names from `/tmp/deps` into destination paths as space separated `name:/target/path` entries. This is used only when `CONTAINER_DEPS_MOVE_SCRIPT` or `CONTAINER_DEPS_MOVE_SCRIPT_PATH` is not set
|
|
243
|
+
- `CONTAINER_DEPS_MOVE_SCRIPT`: Supplies a raw executable script to run after `/tmp/deps` is copied into the image. The script is written to `/tmp/container-deps-move-script` and executed with its own shebang
|
|
244
|
+
- `CONTAINER_DEPS_MOVE_SCRIPT_PATH`: Supplies a host path to a script file to run after `/tmp/deps` is copied into the image. This path takes precedence over `CONTAINER_DEPS_MOVE_SCRIPT` when both are set
|
|
245
|
+
- `GITHUB_RELEASE_ASSETS`: Colon separated list of file paths or glob patterns to attach to the GitHub Release (default: `dist/*`)
|
|
246
|
+
- `SKIP_GITHUB_RELEASE`: Truthy value to skip GitHub Release publication
|
|
247
|
+
- `GITHUB_TOKEN` or `GH_TOKEN`: GitHub authentication token used to publish releases and upload assets
|
|
248
|
+
- `GITHUB_REPOSITORY`: Optional override for the repository slug used when publishing a GitHub Release
|
|
249
|
+
- `GITHUB_API_URL` and `GITHUB_SERVER_URL`: Configure the GitHub API host for GitHub Enterprise environments
|
|
250
|
+
- `GITHUB_RELEASE_TAG`: Optional tag name to publish for the GitHub Release
|
|
251
|
+
- `GITHUB_RELEASE_NAME`: Optional release title to use for the GitHub Release
|
|
252
|
+
- `GITHUB_RELEASE_BODY`: Optional release body text to use for the GitHub Release
|
|
253
|
+
- `RELEASE_UPDATE_CHANGELOG`: Truthy value to update `CHANGELOG.md` by prepending the `git-cliff --unreleased --tag "$RELEASE_TAG"` output before the release tag is created. This is enabled by default; set it to a falsy value if you want to disable changelog commits during release
|
|
254
|
+
- `RELEASE_PRE_SCRIPT`: Optional shell command to run before the release steps
|
|
255
|
+
- `RELEASE_POST_SCRIPT`: Optional shell command to run after the release completes
|
|
256
|
+
- Hook commands: Receive the following env vars; `RELEASE_SCRIPT_PHASE`, `RELEASE_TAG`, `RELEASE_VERSION`, `RELEASE_STAGE`, `RELEASE_COMPONENT`, and `RELEASE_DRY_RUN`
|
|
255
257
|
|
|
256
258
|
#### Docker Compose settings
|
|
257
259
|
|
|
258
260
|
The following environment variables configure Docker Compose stacks (when using the `web` tag).
|
|
259
261
|
|
|
260
|
-
- `COMPOSE_TYPE
|
|
261
|
-
- `COMPOSE_ADDONS
|
|
262
|
-
- `COMPOSE_FILE
|
|
263
|
-
- `COMPOSE_OVERLAY_FILES
|
|
264
|
-
- `API_PORT
|
|
265
|
-
- `SECRET_KEY
|
|
266
|
-
- `ENVIRONMENT
|
|
267
|
-
- `DEBUG_PORT
|
|
268
|
-
- `DB_PORT
|
|
269
|
-
- `DB_USER
|
|
270
|
-
- `DB_BASE
|
|
271
|
-
- `DB_PASS
|
|
272
|
-
- `POSTGRES_VERSION
|
|
273
|
-
- `ADMINER_PORT
|
|
262
|
+
- `COMPOSE_TYPE`: Specifies the type of application stack; for example, `fastapi`
|
|
263
|
+
- `COMPOSE_ADDONS`: Colon separated list of services to include; for example, `db` for database support
|
|
264
|
+
- `COMPOSE_FILE`: Overrides all compose files with colon separated paths
|
|
265
|
+
- `COMPOSE_OVERLAY_FILES`: Additional compose files to merge; uses colon separated paths
|
|
266
|
+
- `API_PORT`: Port for the API server (default: `8080`)
|
|
267
|
+
- `SECRET_KEY`: Application secret key; generated automatically if not set
|
|
268
|
+
- `ENVIRONMENT`: Environment name (default: `production`)
|
|
269
|
+
- `DEBUG_PORT`: Port for the Python debugger in debug mode (default: `5678`)
|
|
270
|
+
- `DB_PORT`: PostgreSQL port (default: `5432`)
|
|
271
|
+
- `DB_USER`: Database user (default: package name)
|
|
272
|
+
- `DB_BASE`: Database name (default: package name)
|
|
273
|
+
- `DB_PASS`: Database password; generated automatically if not set
|
|
274
|
+
- `POSTGRES_VERSION`: PostgreSQL version (default: `17`)
|
|
275
|
+
- `ADMINER_PORT`: Adminer web UI port (default: `8081`)
|
|
274
276
|
|
|
275
277
|
#### Debugging
|
|
276
278
|
|
|
277
279
|
The following environment variable enables debugging output.
|
|
278
280
|
|
|
279
|
-
- `COMMON_PYTHON_TASKS_LOG_LEVEL
|
|
281
|
+
- `COMMON_PYTHON_TASKS_LOG_LEVEL`: Set this to `DEBUG` to see detailed configuration resolution
|
|
280
282
|
|
|
281
283
|
### Usage examples
|
|
282
284
|
|
|
@@ -287,8 +289,8 @@ By default, `tasks()` exposes the common task set. You can still include or excl
|
|
|
287
289
|
```toml
|
|
288
290
|
[project]
|
|
289
291
|
name = "simple-cli-tool"
|
|
290
|
-
version = "0.
|
|
291
|
-
dependencies = ["common-python-tasks==0.
|
|
292
|
+
version = "0.4.0"
|
|
293
|
+
dependencies = ["common-python-tasks==0.4.0"]
|
|
292
294
|
|
|
293
295
|
[tool.poe]
|
|
294
296
|
include_script = "common_python_tasks:tasks()"
|
|
@@ -300,15 +302,13 @@ Available tasks: common defaults such as `format`, `lint`, `test`, and `build`.
|
|
|
300
302
|
|
|
301
303
|
```toml
|
|
302
304
|
[project]
|
|
303
|
-
|
|
304
|
-
version = "0.3.1"
|
|
305
|
-
dependencies = ["common-python-tasks==0.3.1"]
|
|
305
|
+
dependencies = ["common-python-tasks==0.4.0"]
|
|
306
306
|
|
|
307
307
|
[tool.poe]
|
|
308
308
|
include_script = "common_python_tasks:tasks(include_tags=['common', 'containers'])"
|
|
309
309
|
|
|
310
310
|
[tool.poe.env]
|
|
311
|
-
|
|
311
|
+
CONTAINER_REGISTRY_USERNAME = "myusername"
|
|
312
312
|
PACKAGE_NAME = "containerized-app"
|
|
313
313
|
```
|
|
314
314
|
|
|
@@ -318,9 +318,7 @@ Available tasks: All tasks including `build-image` and `push-image`.
|
|
|
318
318
|
|
|
319
319
|
```toml
|
|
320
320
|
[project]
|
|
321
|
-
|
|
322
|
-
dependencies = ["common-python-tasks==0.3.1"]
|
|
323
|
-
dynamic = ["version"]
|
|
321
|
+
dependencies = ["common-python-tasks==0.4.0"]
|
|
324
322
|
|
|
325
323
|
[tool.poe]
|
|
326
324
|
include_script = "common_python_tasks:tasks()"
|
|
@@ -348,13 +346,6 @@ include_script = "common_python_tasks:tasks(exclude_tags=['internal'])"
|
|
|
348
346
|
includes = "common_python_tasks:tasks"
|
|
349
347
|
```
|
|
350
348
|
|
|
351
|
-
### Version bump fails with "no changes since last tag"
|
|
352
|
-
|
|
353
|
-
This is expected behavior. The `bump-version` task requires commits between the last tag and HEAD. You can resolve this in one of the following ways.
|
|
354
|
-
|
|
355
|
-
- Make changes and commit them first
|
|
356
|
-
- Delete the old tag (for example, `git tag -d v0.0.1`). This is not recommended. Versions should be immutable, and if you need to fix something, you should create a new patch version instead. Rarely do you want to pass off new code as an old version
|
|
357
|
-
|
|
358
349
|
### Config files not being used
|
|
359
350
|
|
|
360
351
|
Check the configuration precedence (see [How it works](#how-it-works)). Use debug logging to see which config is selected.
|
|
@@ -385,7 +376,7 @@ If `stack-up` builds successfully but services can't connect:
|
|
|
385
376
|
- Check that required environment variables are set (`COMPOSE_TYPE` at minimum)
|
|
386
377
|
- Verify ports aren't already in use (defaults: 8080 for API, 5432 for database, 8081 for Adminer)
|
|
387
378
|
- Check Docker daemon is running: `docker info`
|
|
388
|
-
- View service logs: `docker
|
|
379
|
+
- View service logs: `docker compose logs` in your project directory
|
|
389
380
|
|
|
390
381
|
### Database migrations fail
|
|
391
382
|
|
|
@@ -406,21 +397,21 @@ If `SECRET_KEY` or `DB_PASS` aren't auto-generated:
|
|
|
406
397
|
|
|
407
398
|
## Design choices
|
|
408
399
|
|
|
409
|
-
### Dockerfile (see [src/common_python_tasks/data/Dockerfile](src/common_python_tasks/data/Dockerfile))
|
|
400
|
+
### Dockerfile (see [`src/common_python_tasks/data/generic/Dockerfile.j2`](src/common_python_tasks/data/generic/Dockerfile.j2))
|
|
410
401
|
|
|
411
402
|
The standard Python Dockerfile incorporates several intentional design choices.
|
|
412
403
|
|
|
413
404
|
- Multi-stage build: The build stage installs Poetry and builds a wheel while the runtime stage installs only the wheel to keep the final image slim and reproducible
|
|
414
|
-
- Pip and Poetry cache mounts
|
|
415
|
-
- Explicit inputs through build args
|
|
416
|
-
- Optional debug stage
|
|
417
|
-
- Stable package path
|
|
418
|
-
- Safe entrypoint selection
|
|
419
|
-
- Minimal final image
|
|
405
|
+
- Pip and Poetry cache mounts: Speed up iterative builds without bloating the final image
|
|
406
|
+
- Explicit inputs through build args: `PYTHON_VERSION`, `POETRY_VERSION`, `PACKAGE_NAME`, `AUTHORS`, `GIT_COMMIT`, and `CUSTOM_ENTRYPOINT` make image metadata and behavior predictable and auditable
|
|
407
|
+
- Optional debug stage: Exports and installs the `debug` dependency group only when present, without failing otherwise, and is not part of the default final image
|
|
408
|
+
- Stable package path: Creates symlinks to the installed package so entrypoints and consumers have a consistent `/pkg` and `/_$PACKAGE_NAME` path regardless of wheel layout. This ensures that the package can be imported and executed from a known location and supports the less common case of reading files directly from the package path
|
|
409
|
+
- Safe entrypoint selection: The default entrypoint resolves the console script matching the package name, while `CUSTOM_ENTRYPOINT` allows an override at build time and keeps runtime behavior predictable
|
|
410
|
+
- Minimal final image: Uses the slim Python base by default, cleans wheel artifacts and caches, and sets `runtime` as the explicit final target so the debug stage remains optional
|
|
420
411
|
|
|
421
412
|
## Notes
|
|
422
413
|
|
|
423
|
-
- This project dogfoods itself
|
|
414
|
+
- This project dogfoods itself; it uses `common-python-tasks` for its own development. **That said, you must set the environment variable `PYTHONPATH=src` when running tasks locally to ensure you are using the local version of the package instead of the installed version**
|
|
424
415
|
- `RELEASE_UPDATE_CHANGELOG` is enabled by default for releases and prepends a tagged section into `CHANGELOG.md` before the release tag is created. Set it to a falsy value if you prefer to manage changelog commits yourself.
|
|
425
416
|
- `RELEASE_PRE_SCRIPT` and `RELEASE_POST_SCRIPT` hooks may not be necessary for most users, as this package promotes the use of `poetry-dynamic-versioning` and `git-cliff` to automate versioning and changelog generation based on git history. One advanced use case for the `RELEASE_PRE_SCRIPT` hook is to edit another file before release, such as a README that references the current stable version number. This allows you to keep the README up to date with the latest version without hardcoding it.
|
|
426
417
|
- Contributions welcome! Open an issue/discussion to discuss changes before submitting a PR. I do not claim to have all the answers, and you can help determine the future of low-code solutions for Python. I am very interested in your feedback as I don't want to work in a vacuum
|