common-python-tasks 0.13.0__tar.gz → 0.14.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.13.0 → common_python_tasks-0.14.0}/PKG-INFO +2 -3
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/README.md +1 -2
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/configuration.md +24 -14
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/getting-started.md +1 -1
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/index.md +0 -1
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/container-images.md +39 -33
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/index.md +0 -1
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/packaging-and-releases.md +3 -1
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/pyproject.toml +1 -3
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/scripts/docs_tasks_reference.py +3 -4
- common_python_tasks-0.14.0/src/common_python_tasks/_task_registry.py +163 -0
- common_python_tasks-0.14.0/src/common_python_tasks/container_tasks.py +609 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/Dockerfile.j2 +28 -27
- common_python_tasks-0.14.0/src/common_python_tasks/dependency_tasks.py +180 -0
- common_python_tasks-0.14.0/src/common_python_tasks/development_tasks.py +211 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/git.py +47 -30
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/github.py +4 -2
- common_python_tasks-0.14.0/src/common_python_tasks/packaging_tasks.py +160 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/project.py +15 -39
- common_python_tasks-0.14.0/src/common_python_tasks/release_tasks.py +435 -0
- common_python_tasks-0.14.0/src/common_python_tasks/tasks.py +93 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/utils.py +38 -16
- common_python_tasks-0.13.0/docs/tasks/development-stacks.md +0 -25
- common_python_tasks-0.13.0/docs/tasks/reference/db-shell.md +0 -13
- common_python_tasks-0.13.0/docs/tasks/reference/reset-db.md +0 -13
- common_python_tasks-0.13.0/docs/tasks/reference/run-db-migrations.md +0 -13
- common_python_tasks-0.13.0/docs/tasks/reference/stack-down.md +0 -13
- common_python_tasks-0.13.0/docs/tasks/reference/stack-up.md +0 -24
- common_python_tasks-0.13.0/src/common_python_tasks/data/fastapi/alembic.ini.j2 +0 -51
- common_python_tasks-0.13.0/src/common_python_tasks/data/fastapi/compose-base.yml.j2 +0 -40
- common_python_tasks-0.13.0/src/common_python_tasks/data/fastapi/compose-db-debug.yml.j2 +0 -45
- common_python_tasks-0.13.0/src/common_python_tasks/data/fastapi/compose-db.yml.j2 +0 -80
- common_python_tasks-0.13.0/src/common_python_tasks/data/fastapi/compose-debug.yml.j2 +0 -30
- common_python_tasks-0.13.0/src/common_python_tasks/docker_compose.py +0 -643
- common_python_tasks-0.13.0/src/common_python_tasks/tasks.py +0 -1982
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/.gitignore +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/.poetry/plugins/poetry_dynamic_versioning-1.10.0.dist-info/licenses/LICENSE +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/.poetry/plugins/poetry_plugin_export-1.10.0.dist-info/licenses/LICENSE +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/LICENSE +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/documentation-workflows.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/daily-development.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/documentation.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/build-deps-image.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/build-image.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/build-package.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/build.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/bump-version.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/changelog.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/clean.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/container-shell.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/docs-build.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/docs-serve.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/format.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/lint.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/publish-github-release.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/publish-package.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/push-image.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/release.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/run-container.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/test.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/reference/update-dependencies.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/scripts/__init__.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/scripts/add_common_python_tasks.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/scripts/release_script.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/scripts/update_docs_tasks_reference.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/scripts/utils.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/__init__.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/__main__.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/data/dockerfile_extensions/docker-in-docker/Dockerfile +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/data/dockerfile_extensions/docker-in-docker/install.sh +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/data/dockerfile_extensions/docker-in-docker/supervisor.sh +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/.coveragerc +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/.dockerignore +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/Dockerfile.deps.j2 +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/cliff.toml +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/pytest.ini +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/ruff.toml +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/docker.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/src/common_python_tasks/env.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/zensical.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: common-python-tasks
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.0
|
|
4
4
|
Summary: Opinionated Poe the Poet tasks for Python package development.
|
|
5
5
|
Project-URL: Homepage, http://github.com/ci-sourcerer/common-python-tasks
|
|
6
6
|
Project-URL: Source, http://github.com/ci-sourcerer/common-python-tasks.git
|
|
@@ -42,7 +42,7 @@ Read the [complete documentation](https://common-python-tasks.ci-sourcerer.com/)
|
|
|
42
42
|
Add the package as a development dependency.
|
|
43
43
|
|
|
44
44
|
```shell
|
|
45
|
-
uv add --dev common-python-tasks==0.
|
|
45
|
+
uv add --dev common-python-tasks==0.14.0
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
Expose the default task set in `pyproject.toml`.
|
|
@@ -74,7 +74,6 @@ include_script = "common_python_tasks:tasks(include_tags=['common', 'docs', 'con
|
|
|
74
74
|
| `common` | Formatting, linting, testing, packaging, and releases |
|
|
75
75
|
| `docs` | Build and serve Zensical documentation |
|
|
76
76
|
| `containers` | Build, run, inspect, and publish container images |
|
|
77
|
-
| `fastapi` | Run the FastAPI and PostgreSQL development stack |
|
|
78
77
|
|
|
79
78
|
Documentation projects can build locally or start a development server.
|
|
80
79
|
|
|
@@ -9,7 +9,7 @@ Read the [complete documentation](https://common-python-tasks.ci-sourcerer.com/)
|
|
|
9
9
|
Add the package as a development dependency.
|
|
10
10
|
|
|
11
11
|
```shell
|
|
12
|
-
uv add --dev common-python-tasks==0.
|
|
12
|
+
uv add --dev common-python-tasks==0.14.0
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Expose the default task set in `pyproject.toml`.
|
|
@@ -41,7 +41,6 @@ include_script = "common_python_tasks:tasks(include_tags=['common', 'docs', 'con
|
|
|
41
41
|
| `common` | Formatting, linting, testing, packaging, and releases |
|
|
42
42
|
| `docs` | Build and serve Zensical documentation |
|
|
43
43
|
| `containers` | Build, run, inspect, and publish container images |
|
|
44
|
-
| `fastapi` | Run the FastAPI and PostgreSQL development stack |
|
|
45
44
|
|
|
46
45
|
Documentation projects can build locally or start a development server.
|
|
47
46
|
|
|
@@ -26,7 +26,30 @@ Ruff uses `RUFF_CONFIG` when set. Otherwise, it discovers `.ruff.toml`, `ruff.to
|
|
|
26
26
|
| `RELEASE_PRE_SCRIPT` | Run a command before the release steps |
|
|
27
27
|
| `RELEASE_POST_SCRIPT` | Run a command after the release steps |
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
Publishing targets are selected from the first populated source in this order.
|
|
30
|
+
|
|
31
|
+
1. Explicit task arguments, `--repository` or `--repository-url`.
|
|
32
|
+
2. `COMMON_PYTHON_TASKS_PUBLISH_REPOSITORY` or `COMMON_PYTHON_TASKS_PUBLISH_URL`.
|
|
33
|
+
3. uv's `UV_PUBLISH_INDEX` or `UV_PUBLISH_URL`.
|
|
34
|
+
4. A configured publishable `[[tool.uv.index]]`, using the default entry or the sole publishable entry.
|
|
35
|
+
5. uv's default publishing destination.
|
|
36
|
+
|
|
37
|
+
Blank environment values are ignored. Specifying both an index and a URL within the winning source fails before builds or release changes begin. Lower-priority settings are ignored. For example, `poe publish-package --repository internal` overrides `UV_PUBLISH_URL`, and `poe release --repository-url https://packages.example.com/legacy/` overrides `UV_PUBLISH_INDEX`.
|
|
38
|
+
|
|
39
|
+
The publishing subprocess receives the selected target as a command argument and omits `UV_PUBLISH_INDEX` and `UV_PUBLISH_URL` to prevent uv argument conflicts. The parent environment, credentials, check URLs, and other uv settings remain available. `UV_DEFAULT_INDEX` controls dependency resolution and does not select a publishing destination.
|
|
40
|
+
|
|
41
|
+
Other uv environment settings are inherited by `publish-package` and the package publishing step of `release`; no CPT aliases are required.
|
|
42
|
+
|
|
43
|
+
| Setting | Purpose |
|
|
44
|
+
| - | - |
|
|
45
|
+
| `UV_PUBLISH_TOKEN` | Authenticate publishing with a token |
|
|
46
|
+
| `UV_PUBLISH_USERNAME`, `UV_PUBLISH_PASSWORD` | Authenticate publishing with a username and password |
|
|
47
|
+
| `UV_INDEX_{name}_USERNAME`, `UV_INDEX_{name}_PASSWORD` | Supply credentials for a named index |
|
|
48
|
+
| `UV_PUBLISH_CHECK_URL` | Check an index for existing distributions and skip duplicate uploads |
|
|
49
|
+
| `UV_PUBLISH_NO_ATTESTATIONS` | Disable uploading attestations |
|
|
50
|
+
| `UV_KEYRING_PROVIDER` | Select uv's keyring authentication provider |
|
|
51
|
+
|
|
52
|
+
See uv's [environment variable reference](https://docs.astral.sh/uv/reference/environment/) for supported values and its [publishing guide](https://docs.astral.sh/uv/guides/package/#publishing-your-package) for publishing configuration. Availability depends on the installed uv version.
|
|
30
53
|
|
|
31
54
|
## Container settings
|
|
32
55
|
|
|
@@ -70,19 +93,6 @@ Container variables are read by the host-side tasks unless their description exp
|
|
|
70
93
|
| `CONTAINER_DEPS_MOVE_SCRIPT` | Inline script that distributes copied dependency artifacts and takes precedence over mappings |
|
|
71
94
|
| `CONTAINER_DEPS_MOVE_SCRIPT_PATH` | Host path to a dependency move script; takes precedence over the inline script and mappings |
|
|
72
95
|
|
|
73
|
-
## Development-stack settings
|
|
74
|
-
|
|
75
|
-
Set `COMPOSE_TYPE=fastapi` to use the bundled FastAPI stack. Add PostgreSQL with `COMPOSE_ADDONS=db`.
|
|
76
|
-
|
|
77
|
-
```toml
|
|
78
|
-
[tool.poe.env]
|
|
79
|
-
COMPOSE_TYPE = "fastapi"
|
|
80
|
-
COMPOSE_ADDONS = "db"
|
|
81
|
-
API_PORT = "8080"
|
|
82
|
-
DB_PORT = "5432"
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
`COMPOSE_FILE` replaces automatic compose-file selection. `COMPOSE_OVERLAY_FILES` appends project-specific overlays to the automatically selected files.
|
|
86
96
|
|
|
87
97
|
## Diagnostics
|
|
88
98
|
|
|
@@ -36,7 +36,7 @@ Use `exclude_tags` when a project wants nearly every group.
|
|
|
36
36
|
|
|
37
37
|
```toml
|
|
38
38
|
[tool.poe]
|
|
39
|
-
include_script = "common_python_tasks:tasks(exclude_tags=['
|
|
39
|
+
include_script = "common_python_tasks:tasks(exclude_tags=['containers'])"
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
Calling `tasks()` with no arguments selects only `common`. Passing an explicit empty `include_tags` sequence selects every task unless an exclusion removes it.
|
|
@@ -18,7 +18,6 @@ Tasks are organized by tags, so each project can select only the workflows it ne
|
|
|
18
18
|
| `common` | Formatting, linting, testing, packaging, and releases |
|
|
19
19
|
| `docs` | Build and locally serve Zensical documentation |
|
|
20
20
|
| `containers` | Build, run, inspect, and publish container images |
|
|
21
|
-
| `fastapi` | Run a local FastAPI and PostgreSQL development stack |
|
|
22
21
|
|
|
23
22
|
The default task collection exposes the `common` group. Optional groups are enabled through the package's `include_script` expression.
|
|
24
23
|
|
|
@@ -11,17 +11,24 @@ include_script = "common_python_tasks:tasks(include_tags=['common', 'containers'
|
|
|
11
11
|
|
|
12
12
|
`build-image` renders a temporary Dockerfile and uses the project root as its build context. If the project does not provide `.dockerignore`, the task temporarily supplies a conservative default that includes `pyproject.toml`, `uv.lock`, `README.md`, `LICENSE`, and the `src/` tree.
|
|
13
13
|
|
|
14
|
+
Managed builds require a current `uv.lock` in the build context. If the lockfile is missing or stale, run `uv lock` and include the updated file in the build context.
|
|
15
|
+
|
|
14
16
|
The generated Dockerfile contains the following stages.
|
|
15
17
|
|
|
16
18
|
| Stage | Purpose |
|
|
17
19
|
| - | - |
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `
|
|
20
|
+
| `uv-tool` | Supplies the uv binary to build steps through temporary mounts. |
|
|
21
|
+
| `builder` | Uses the host Python version to build the project wheel. |
|
|
22
|
+
| `runtime` | Uses the configured Python image variant and installs the locked runtime dependencies and project wheel into `/opt/venv`. It also installs optional APT packages and dependency-image artifacts, creates the non-root `py` user, configures the `/pkg` link and entrypoint, and applies container extensions. |
|
|
23
|
+
| `debug` | Extends `runtime` with the project source and the locked `debug` dependency group. This stage exists only when `[dependency-groups].debug` is non-empty. |
|
|
21
24
|
| `final` | Extends `runtime` so tools that build the rendered Dockerfile without selecting a target still produce the normal runtime image. |
|
|
22
25
|
|
|
23
26
|
The `build-image` task explicitly builds `runtime`, or `debug` when `--debug` is used. A debug build fails early when the project has no non-empty `debug` dependency group.
|
|
24
27
|
|
|
28
|
+
The managed Python installation excludes default dependency groups. Both targets use `/opt/venv/bin` on `PATH`. The template removes the base image's pip before applying extensions and uses uv through build-time mounts.
|
|
29
|
+
|
|
30
|
+
Maintainers can verify lockfile installation on slim and Alpine with `CPT_DOCKER_INTEGRATION=1 poe test tests/test_managed_dockerfile.py`. The tests require a running Docker daemon and network access to download base images and dependencies.
|
|
31
|
+
|
|
25
32
|
The task supplies build arguments derived from the current environment and project metadata, including `PYTHON_VERSION`, `UV_VERSION`, `PACKAGE_VERSION`, `PACKAGE_NAME`, `AUTHORS`, `GIT_COMMIT`, `PYTHON_VARIANT`, and `WORKDIR_PATH`. It also creates short and fully qualified image tags for the package version and Git commit. A dirty working tree adds `-dirty` to the commit tag.
|
|
26
33
|
|
|
27
34
|
### Generic template reference
|
|
@@ -43,11 +50,13 @@ ARG PYTHON_VERSION=3
|
|
|
43
50
|
# Variant for the runtime image, e.g. slim, alpine, etc.
|
|
44
51
|
# See https://hub.docker.com/_/python for available variants. Leave empty for no variant.
|
|
45
52
|
ARG PYTHON_VARIANT=slim
|
|
53
|
+
ARG UV_VERSION=latest
|
|
54
|
+
|
|
55
|
+
FROM ghcr.io/astral-sh/uv:${UV_VERSION:-latest} AS uv-tool
|
|
46
56
|
|
|
47
57
|
FROM python:${PYTHON_VERSION} AS builder
|
|
48
58
|
|
|
49
59
|
ARG PACKAGE_VERSION
|
|
50
|
-
ARG UV_VERSION
|
|
51
60
|
|
|
52
61
|
{% if CONTAINER_ENV_VARS %}
|
|
53
62
|
# Make configured variables available to package build commands.
|
|
@@ -61,32 +70,18 @@ ENV {{ env_var }}
|
|
|
61
70
|
# false dirty-version detection from a partial working tree.
|
|
62
71
|
ENV UV_DYNAMIC_VERSIONING_BYPASS=${PACKAGE_VERSION}
|
|
63
72
|
|
|
64
|
-
# Install uv for package build and dependency export steps
|
|
65
|
-
RUN --mount=type=cache,target=/root/.cache/pip,id=pip-cache{{ CACHE_ID_SUFFIX }} \
|
|
66
|
-
sh -c 'if [ -n "${UV_VERSION:-}" ]; then \
|
|
67
|
-
pip install --root-user-action=ignore "uv==$UV_VERSION"; \
|
|
68
|
-
else \
|
|
69
|
-
pip install --root-user-action=ignore uv; \
|
|
70
|
-
fi'
|
|
71
|
-
|
|
72
73
|
# Build package
|
|
73
74
|
WORKDIR /tmp/build
|
|
74
75
|
COPY . /tmp/build/
|
|
75
76
|
|
|
76
|
-
{% if HAS_DEBUG_DEPS %}
|
|
77
|
-
# Export debug requirements when the project defines a debug dependency group
|
|
78
|
-
RUN --mount=type=cache,target=/root/.cache/uv,id=uv-cache{{ CACHE_ID_SUFFIX }}{% for mount in UV_INDEX_SECRET_MOUNTS %} \
|
|
79
|
-
--mount={{ mount }}{% endfor %} \
|
|
80
|
-
uv export --frozen --only-group debug --no-hashes --format requirements-txt --output-file requirements-debug.txt
|
|
81
|
-
{% endif %}
|
|
82
|
-
|
|
83
77
|
# Build the wheel, caching the uv cache directory to speed up subsequent builds.
|
|
84
78
|
# If running this in a CI system, you must be using a persistent builder to take
|
|
85
79
|
# advantage of the cache mount, and you should configure your CI to persist the
|
|
86
80
|
# cache directory between builds
|
|
87
|
-
RUN --mount=
|
|
81
|
+
RUN --mount=from=uv-tool,source=/uv,target=/usr/local/bin/uv \
|
|
82
|
+
--mount=type=cache,target=/root/.cache/uv,id=uv-cache{{ CACHE_ID_SUFFIX }}{% for mount in UV_INDEX_SECRET_MOUNTS %} \
|
|
88
83
|
--mount={{ mount }}{% endfor %} \
|
|
89
|
-
uv build --wheel
|
|
84
|
+
uv build --wheel --out-dir /tmp/wheels
|
|
90
85
|
|
|
91
86
|
FROM python:${PYTHON_VERSION}${PYTHON_VARIANT:+-${PYTHON_VARIANT}} AS runtime
|
|
92
87
|
ARG PYTHON_VERSION
|
|
@@ -147,11 +142,21 @@ RUN set -eux; \
|
|
|
147
142
|
|
|
148
143
|
WORKDIR ${WORKDIR_PATH}
|
|
149
144
|
|
|
150
|
-
#
|
|
151
|
-
|
|
145
|
+
# Sync locked dependencies for the runtime platform, then install the built wheel.
|
|
146
|
+
ARG PACKAGE_VERSION
|
|
147
|
+
RUN --mount=from=uv-tool,source=/uv,target=/usr/local/bin/uv \
|
|
148
|
+
--mount=from=builder,source=/tmp/build,target=/tmp/build,rw \
|
|
149
|
+
--mount=from=builder,source=/tmp/wheels,target=/tmp/wheels \
|
|
150
|
+
--mount=type=cache,target=/root/.cache/uv,id=uv-cache{{ CACHE_ID_SUFFIX }}{% for mount in UV_INDEX_SECRET_MOUNTS %} \
|
|
151
|
+
--mount={{ mount }}{% endfor %} \
|
|
152
|
+
UV_DYNAMIC_VERSIONING_BYPASS="${PACKAGE_VERSION}" UV_PROJECT_ENVIRONMENT=/opt/venv \
|
|
153
|
+
uv sync --project /tmp/build --python /usr/local/bin/python --no-python-downloads \
|
|
154
|
+
--locked --no-default-groups --no-install-project --no-editable --link-mode copy \
|
|
155
|
+
&& uv pip install --python /opt/venv/bin/python --no-deps --link-mode copy /tmp/wheels/*.whl \
|
|
156
|
+
&& /usr/local/bin/python -m pip uninstall --yes --root-user-action=ignore pip
|
|
157
|
+
|
|
158
|
+
ENV PATH="/opt/venv/bin:${PATH}"
|
|
152
159
|
|
|
153
|
-
# Install package
|
|
154
|
-
RUN --mount=type=cache,target=/root/.cache/pip,id=pip-cache{{ CACHE_ID_SUFFIX }} pip install --root-user-action=ignore /tmp/*.whl
|
|
155
160
|
# Create symlinks for the package
|
|
156
161
|
ARG PACKAGE_NAME
|
|
157
162
|
ENV PACKAGE_NAME=${PACKAGE_NAME}
|
|
@@ -170,9 +175,7 @@ LABEL git.commit=${GIT_COMMIT}
|
|
|
170
175
|
# This entrypoint is deliberately not configurable via environment variables in order to
|
|
171
176
|
# ensure that the container always uses the entrypoint selected at build time. If the
|
|
172
177
|
# current package does not provide a console script, the entrypoint will default to `python`
|
|
173
|
-
RUN
|
|
174
|
-
|
|
175
|
-
exec {{ ENTRYPOINT_COMMAND|default('python') }} \"\$@\"" >/pkg/entrypoint.sh \
|
|
178
|
+
RUN printf '%s\n' '#!/bin/sh' '' "exec {{ ENTRYPOINT_COMMAND|default('python') }} \"\$@\"" >/pkg/entrypoint.sh \
|
|
176
179
|
&& chmod +x /pkg/entrypoint.sh
|
|
177
180
|
|
|
178
181
|
ARG RUNTIME_USER=py
|
|
@@ -183,16 +186,19 @@ USER ${RUNTIME_USER}
|
|
|
183
186
|
{% endif %}
|
|
184
187
|
|
|
185
188
|
{% if HAS_DEBUG_DEPS %}
|
|
186
|
-
#
|
|
187
|
-
# be built by default (the final stage below is the runtime image), and it will safely do
|
|
188
|
-
# nothing if there are no debug requirements
|
|
189
|
+
# The debug target adds its locked dependency group to the runtime environment.
|
|
189
190
|
FROM runtime AS debug
|
|
190
191
|
|
|
191
192
|
USER root
|
|
192
193
|
|
|
193
194
|
COPY --from=builder /tmp/build /tmp/build
|
|
194
195
|
|
|
195
|
-
RUN --mount=
|
|
196
|
+
RUN --mount=from=uv-tool,source=/uv,target=/usr/local/bin/uv \
|
|
197
|
+
--mount=type=cache,target=/root/.cache/uv,id=uv-cache{{ CACHE_ID_SUFFIX }}{% for mount in UV_INDEX_SECRET_MOUNTS %} \
|
|
198
|
+
--mount={{ mount }}{% endfor %} \
|
|
199
|
+
UV_DYNAMIC_VERSIONING_BYPASS="${PACKAGE_VERSION}" UV_PROJECT_ENVIRONMENT=/opt/venv \
|
|
200
|
+
uv sync --project /tmp/build --python /usr/local/bin/python --no-python-downloads \
|
|
201
|
+
--locked --no-default-groups --group debug --no-install-project --no-editable --inexact --link-mode copy
|
|
196
202
|
|
|
197
203
|
USER ${RUNTIME_USER}
|
|
198
204
|
{% endif %}
|
|
@@ -414,7 +420,7 @@ See [Container settings](../configuration.md#container-settings) for the complet
|
|
|
414
420
|
| [`build-deps-image`](reference/build-deps-image.md) | Build only the container dependency collector image for this project. |
|
|
415
421
|
| [`run-container`](reference/run-container.md) | Run the Docker image as a container for this project. |
|
|
416
422
|
| [`push-image`](reference/push-image.md) | Push the Docker image for this project to the container registry. |
|
|
417
|
-
| [`build`](reference/build.md) | Build the project and its containers. |
|
|
418
423
|
| [`container-shell`](reference/container-shell.md) | Run the debug image with an interactive shell. |
|
|
424
|
+
| [`build`](reference/build.md) | Build the project and its containers. |
|
|
419
425
|
|
|
420
426
|
<!-- end-generated-task-reference -->
|
|
@@ -10,7 +10,6 @@ The task reference is divided by workflow. Each category page includes a table l
|
|
|
10
10
|
| [Documentation](documentation.md) | Build and locally serve a Zensical site |
|
|
11
11
|
| [Packaging and releases](packaging-and-releases.md) | Build, version, publish, and release packages |
|
|
12
12
|
| [Container images](container-images.md) | Build, run, inspect, and publish images |
|
|
13
|
-
| [Development stacks](development-stacks.md) | Operate the FastAPI and PostgreSQL Compose stack |
|
|
14
13
|
|
|
15
14
|
Individual task reference pages are also available in the sidebar under the "reference" section.
|
|
16
15
|
|
{common_python_tasks-0.13.0 → common_python_tasks-0.14.0}/docs/tasks/packaging-and-releases.md
RENAMED
|
@@ -10,12 +10,14 @@ Publish targets and release hooks are described in [Configuration](../configurat
|
|
|
10
10
|
|
|
11
11
|
| Task | Description |
|
|
12
12
|
| - | - |
|
|
13
|
+
| [`update-dependencies`](reference/update-dependencies.md) | Update project dependencies with uv. |
|
|
13
14
|
| [`publish-package`](reference/publish-package.md) | Publish the package to the PyPI server. |
|
|
14
15
|
| [`publish-github-release`](reference/publish-github-release.md) | Publish or update a GitHub Release for the current repository. |
|
|
15
|
-
| [`update-dependencies`](reference/update-dependencies.md) | Update project dependencies with uv. |
|
|
16
16
|
| [`build-package`](reference/build-package.md) | Build the package (wheel and sdist). |
|
|
17
17
|
| [`bump-version`](reference/bump-version.md) | Bump the project version. |
|
|
18
18
|
| [`changelog`](reference/changelog.md) | Print the changelog for the current version based on git history and git-cliff. |
|
|
19
19
|
| [`release`](reference/release.md) | Run a full release flow for package and containers. |
|
|
20
20
|
|
|
21
21
|
<!-- end-generated-task-reference -->
|
|
22
|
+
|
|
23
|
+
Automatic releases default to a patch bump when no version bump is inferred, including when there are no new commits. Empty generated release notes use “No conventional commit messages found.” No synthetic commits are created for version inference.
|
|
@@ -38,13 +38,11 @@ Source = "http://github.com/ci-sourcerer/common-python-tasks.git"
|
|
|
38
38
|
Issues = "http://github.com/ci-sourcerer/common-python-tasks/issues"
|
|
39
39
|
|
|
40
40
|
[tool.poe]
|
|
41
|
-
include_script = "common_python_tasks:tasks(exclude_tags=['containers'
|
|
41
|
+
include_script = "common_python_tasks:tasks(exclude_tags=['containers'])"
|
|
42
42
|
|
|
43
43
|
[tool.poe.tasks]
|
|
44
44
|
update-docs-references = { cmd = "python -m scripts.update_docs_tasks_reference" }
|
|
45
45
|
check-docs-references = { cmd = "python -m scripts.update_docs_tasks_reference --check" }
|
|
46
|
-
update-docs-tasks-reference = { cmd = "python -m scripts.update_docs_tasks_reference" }
|
|
47
|
-
check-docs-tasks-reference = { cmd = "python -m scripts.update_docs_tasks_reference --check" }
|
|
48
46
|
|
|
49
47
|
[tool.poe.env]
|
|
50
48
|
PYTHONPATH = "src"
|
|
@@ -17,7 +17,6 @@ TASK_CATEGORY_FILES = {
|
|
|
17
17
|
"documentation": Path("docs/tasks/documentation.md"),
|
|
18
18
|
"packaging-and-releases": Path("docs/tasks/packaging-and-releases.md"),
|
|
19
19
|
"container-images": Path("docs/tasks/container-images.md"),
|
|
20
|
-
"development-stacks": Path("docs/tasks/development-stacks.md"),
|
|
21
20
|
}
|
|
22
21
|
DOCKERFILE_REFERENCE_FILE = Path("docs/tasks/container-images.md")
|
|
23
22
|
DOCKERFILE_TEMPLATE_FILES = (
|
|
@@ -36,8 +35,6 @@ def _get_task_category(task_name: str) -> str:
|
|
|
36
35
|
tags = get_task_tags(task_name) or []
|
|
37
36
|
if "docs" in tags:
|
|
38
37
|
return "documentation"
|
|
39
|
-
if "web" in tags or "database" in tags:
|
|
40
|
-
return "development-stacks"
|
|
41
38
|
if task_name == "release":
|
|
42
39
|
return "packaging-and-releases"
|
|
43
40
|
if "containers" in tags:
|
|
@@ -282,4 +279,6 @@ def replace_dockerfile_reference(text: str) -> str:
|
|
|
282
279
|
"""
|
|
283
280
|
if len(DOCKERFILE_REFERENCE_PATTERN.findall(text)) != 1:
|
|
284
281
|
raise ValueError("Expected exactly one generated Dockerfile-reference block")
|
|
285
|
-
return DOCKERFILE_REFERENCE_PATTERN.sub(
|
|
282
|
+
return DOCKERFILE_REFERENCE_PATTERN.sub(
|
|
283
|
+
lambda _: build_dockerfile_reference(), text
|
|
284
|
+
)
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import contextvars
|
|
2
|
+
import inspect
|
|
3
|
+
import logging
|
|
4
|
+
import os
|
|
5
|
+
import shlex
|
|
6
|
+
from collections.abc import Callable
|
|
7
|
+
from functools import partial, wraps
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import ClassVar
|
|
10
|
+
|
|
11
|
+
from poethepoet_tasks import TaskCollection
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class _ColoredFormatter(logging.Formatter):
|
|
15
|
+
COLORS: ClassVar = {
|
|
16
|
+
"WARNING": "\033[93m",
|
|
17
|
+
"ERROR": "\033[91m",
|
|
18
|
+
"CRITICAL": "\033[91m",
|
|
19
|
+
"RESET": "\033[0m",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
def format(self, record: logging.LogRecord) -> str:
|
|
23
|
+
log_color = self.COLORS.get(record.levelname, "")
|
|
24
|
+
record.levelname = f"\033[1m{log_color}{record.levelname}{self.COLORS['RESET'] if log_color else ''}\033[0m"
|
|
25
|
+
return super().format(record)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
LOGGER = logging.getLogger("common_python_tasks")
|
|
29
|
+
handler = logging.StreamHandler()
|
|
30
|
+
handler.setFormatter(_ColoredFormatter("[%(asctime)s] %(levelname)s: %(message)s"))
|
|
31
|
+
LOGGER.addHandler(handler)
|
|
32
|
+
LOGGER.setLevel(
|
|
33
|
+
{
|
|
34
|
+
"DEBUG": logging.DEBUG,
|
|
35
|
+
"INFO": logging.INFO,
|
|
36
|
+
"WARNING": logging.WARNING,
|
|
37
|
+
"ERROR": logging.ERROR,
|
|
38
|
+
"CRITICAL": logging.CRITICAL,
|
|
39
|
+
}[os.getenv("COMMON_PYTHON_TASKS_LOG_LEVEL", "INFO").upper()]
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
tasks = TaskCollection(
|
|
44
|
+
envfile=[
|
|
45
|
+
f
|
|
46
|
+
for f in [
|
|
47
|
+
".env.defaults",
|
|
48
|
+
"project.properties",
|
|
49
|
+
".env",
|
|
50
|
+
]
|
|
51
|
+
if Path(f).exists()
|
|
52
|
+
]
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
_task_call_depth: contextvars.ContextVar[int] = contextvars.ContextVar(
|
|
56
|
+
"common_python_tasks_task_call_depth", default=0
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
_original_script = tasks.script
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _make_var_positional_task_args_optional(
|
|
63
|
+
func: callable, resolved_task_name: str
|
|
64
|
+
) -> None:
|
|
65
|
+
var_positional_arg_names = {
|
|
66
|
+
param.name
|
|
67
|
+
for param in inspect.signature(func).parameters.values()
|
|
68
|
+
if param.kind == inspect.Parameter.VAR_POSITIONAL
|
|
69
|
+
}
|
|
70
|
+
if not var_positional_arg_names:
|
|
71
|
+
return
|
|
72
|
+
|
|
73
|
+
for task_config in tasks._tasks.get(resolved_task_name, []):
|
|
74
|
+
for arg_config in task_config.options.get("args", []):
|
|
75
|
+
if arg_config.get("name") in var_positional_arg_names:
|
|
76
|
+
arg_config["required"] = False
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _wrap_task_function(func: callable, task_name: str | None) -> callable:
|
|
80
|
+
resolved_task_name = task_name or func.__name__.replace("_", "-").lower()
|
|
81
|
+
var_positional_arg_names = [
|
|
82
|
+
param.name
|
|
83
|
+
for param in inspect.signature(func).parameters.values()
|
|
84
|
+
if param.kind == inspect.Parameter.VAR_POSITIONAL
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
@wraps(func)
|
|
88
|
+
def wrapped(*args, **kwargs):
|
|
89
|
+
for arg_name in var_positional_arg_names:
|
|
90
|
+
if arg_name not in kwargs:
|
|
91
|
+
continue
|
|
92
|
+
values = kwargs.pop(arg_name)
|
|
93
|
+
if values is None:
|
|
94
|
+
continue
|
|
95
|
+
if isinstance(values, list | tuple):
|
|
96
|
+
args = (*args, *values)
|
|
97
|
+
else:
|
|
98
|
+
args = (*args, values)
|
|
99
|
+
|
|
100
|
+
if var_positional_arg_names and (
|
|
101
|
+
poe_extra_args := os.environ.pop("POE_EXTRA_ARGS", None)
|
|
102
|
+
):
|
|
103
|
+
args = (*args, *shlex.split(poe_extra_args))
|
|
104
|
+
|
|
105
|
+
current_depth = _task_call_depth.get()
|
|
106
|
+
if current_depth > 0:
|
|
107
|
+
LOGGER.log(
|
|
108
|
+
(
|
|
109
|
+
logging.INFO
|
|
110
|
+
if not resolved_task_name.startswith("_")
|
|
111
|
+
else logging.DEBUG
|
|
112
|
+
),
|
|
113
|
+
"Running task %s",
|
|
114
|
+
resolved_task_name,
|
|
115
|
+
)
|
|
116
|
+
token = _task_call_depth.set(current_depth + 1)
|
|
117
|
+
try:
|
|
118
|
+
return func(*args, **kwargs)
|
|
119
|
+
finally:
|
|
120
|
+
_task_call_depth.reset(token)
|
|
121
|
+
|
|
122
|
+
return wrapped
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _script(
|
|
126
|
+
func: Callable | None = None,
|
|
127
|
+
task_name: str | None = None,
|
|
128
|
+
help: str | None = None,
|
|
129
|
+
task_args: bool = True,
|
|
130
|
+
options: dict | None = None,
|
|
131
|
+
tags: tuple[str, ...] | None = None,
|
|
132
|
+
):
|
|
133
|
+
|
|
134
|
+
if tags is None:
|
|
135
|
+
tags = ()
|
|
136
|
+
|
|
137
|
+
if func is None:
|
|
138
|
+
return partial(
|
|
139
|
+
_script,
|
|
140
|
+
task_name=task_name,
|
|
141
|
+
help=help,
|
|
142
|
+
task_args=task_args,
|
|
143
|
+
options=options,
|
|
144
|
+
tags=tags,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
resolved_task_name = task_name or func.__name__.replace("_", "-").lower()
|
|
148
|
+
wrapped = _wrap_task_function(func, resolved_task_name)
|
|
149
|
+
decorated = _original_script(
|
|
150
|
+
wrapped,
|
|
151
|
+
task_name=resolved_task_name,
|
|
152
|
+
help=help,
|
|
153
|
+
task_args=task_args,
|
|
154
|
+
options=options,
|
|
155
|
+
tags=tags,
|
|
156
|
+
)
|
|
157
|
+
_make_var_positional_task_args_optional(wrapped, resolved_task_name)
|
|
158
|
+
return decorated
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
tasks.script = _script
|
|
162
|
+
|
|
163
|
+
NO_PROMPT_ENV_VAR = "COMMON_PYTHON_TASKS_NO_PROMPT"
|