common-python-tasks 0.13.1__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.1 → common_python_tasks-0.14.0}/PKG-INFO +2 -2
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/README.md +1 -1
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/configuration.md +24 -1
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/container-images.md +38 -32
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/scripts/docs_tasks_reference.py +3 -1
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/Dockerfile.j2 +28 -27
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/packaging_tasks.py +2 -3
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/project.py +15 -37
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/release_tasks.py +2 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/utils.py +11 -1
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/.gitignore +0 -0
- {common_python_tasks-0.13.1 → 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.1 → 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.1 → common_python_tasks-0.14.0}/LICENSE +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/documentation-workflows.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/getting-started.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/index.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/daily-development.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/documentation.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/index.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/packaging-and-releases.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/build-deps-image.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/build-image.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/build-package.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/build.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/bump-version.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/changelog.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/clean.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/container-shell.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/docs-build.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/docs-serve.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/format.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/lint.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/publish-github-release.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/publish-package.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/push-image.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/release.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/run-container.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/test.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/update-dependencies.md +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/pyproject.toml +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/scripts/__init__.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/scripts/add_common_python_tasks.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/scripts/release_script.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/scripts/update_docs_tasks_reference.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/scripts/utils.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/__init__.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/__main__.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/_task_registry.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/container_tasks.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/data/dockerfile_extensions/docker-in-docker/Dockerfile +0 -0
- {common_python_tasks-0.13.1 → 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.1 → 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.1 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/.coveragerc +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/.dockerignore +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/Dockerfile.deps.j2 +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/cliff.toml +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/pytest.ini +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/data/generic/ruff.toml +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/dependency_tasks.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/development_tasks.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/docker.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/env.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/git.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/github.py +0 -0
- {common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/tasks.py +0 -0
- {common_python_tasks-0.13.1 → 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`.
|
|
@@ -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`.
|
|
@@ -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
|
|
|
@@ -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 %}
|
|
@@ -279,4 +279,6 @@ def replace_dockerfile_reference(text: str) -> str:
|
|
|
279
279
|
"""
|
|
280
280
|
if len(DOCKERFILE_REFERENCE_PATTERN.findall(text)) != 1:
|
|
281
281
|
raise ValueError("Expected exactly one generated Dockerfile-reference block")
|
|
282
|
-
return DOCKERFILE_REFERENCE_PATTERN.sub(
|
|
282
|
+
return DOCKERFILE_REFERENCE_PATTERN.sub(
|
|
283
|
+
lambda _: build_dockerfile_reference(), text
|
|
284
|
+
)
|
|
@@ -6,11 +6,13 @@ ARG PYTHON_VERSION=3
|
|
|
6
6
|
# Variant for the runtime image, e.g. slim, alpine, etc.
|
|
7
7
|
# See https://hub.docker.com/_/python for available variants. Leave empty for no variant.
|
|
8
8
|
ARG PYTHON_VARIANT=slim
|
|
9
|
+
ARG UV_VERSION=latest
|
|
10
|
+
|
|
11
|
+
FROM ghcr.io/astral-sh/uv:${UV_VERSION:-latest} AS uv-tool
|
|
9
12
|
|
|
10
13
|
FROM python:${PYTHON_VERSION} AS builder
|
|
11
14
|
|
|
12
15
|
ARG PACKAGE_VERSION
|
|
13
|
-
ARG UV_VERSION
|
|
14
16
|
|
|
15
17
|
{% if CONTAINER_ENV_VARS %}
|
|
16
18
|
# Make configured variables available to package build commands.
|
|
@@ -24,32 +26,18 @@ ENV {{ env_var }}
|
|
|
24
26
|
# false dirty-version detection from a partial working tree.
|
|
25
27
|
ENV UV_DYNAMIC_VERSIONING_BYPASS=${PACKAGE_VERSION}
|
|
26
28
|
|
|
27
|
-
# Install uv for package build and dependency export steps
|
|
28
|
-
RUN --mount=type=cache,target=/root/.cache/pip,id=pip-cache{{ CACHE_ID_SUFFIX }} \
|
|
29
|
-
sh -c 'if [ -n "${UV_VERSION:-}" ]; then \
|
|
30
|
-
pip install --root-user-action=ignore "uv==$UV_VERSION"; \
|
|
31
|
-
else \
|
|
32
|
-
pip install --root-user-action=ignore uv; \
|
|
33
|
-
fi'
|
|
34
|
-
|
|
35
29
|
# Build package
|
|
36
30
|
WORKDIR /tmp/build
|
|
37
31
|
COPY . /tmp/build/
|
|
38
32
|
|
|
39
|
-
{% if HAS_DEBUG_DEPS %}
|
|
40
|
-
# Export debug requirements when the project defines a debug dependency group
|
|
41
|
-
RUN --mount=type=cache,target=/root/.cache/uv,id=uv-cache{{ CACHE_ID_SUFFIX }}{% for mount in UV_INDEX_SECRET_MOUNTS %} \
|
|
42
|
-
--mount={{ mount }}{% endfor %} \
|
|
43
|
-
uv export --frozen --only-group debug --no-hashes --format requirements-txt --output-file requirements-debug.txt
|
|
44
|
-
{% endif %}
|
|
45
|
-
|
|
46
33
|
# Build the wheel, caching the uv cache directory to speed up subsequent builds.
|
|
47
34
|
# If running this in a CI system, you must be using a persistent builder to take
|
|
48
35
|
# advantage of the cache mount, and you should configure your CI to persist the
|
|
49
36
|
# cache directory between builds
|
|
50
|
-
RUN --mount=
|
|
37
|
+
RUN --mount=from=uv-tool,source=/uv,target=/usr/local/bin/uv \
|
|
38
|
+
--mount=type=cache,target=/root/.cache/uv,id=uv-cache{{ CACHE_ID_SUFFIX }}{% for mount in UV_INDEX_SECRET_MOUNTS %} \
|
|
51
39
|
--mount={{ mount }}{% endfor %} \
|
|
52
|
-
uv build --wheel
|
|
40
|
+
uv build --wheel --out-dir /tmp/wheels
|
|
53
41
|
|
|
54
42
|
FROM python:${PYTHON_VERSION}${PYTHON_VARIANT:+-${PYTHON_VARIANT}} AS runtime
|
|
55
43
|
ARG PYTHON_VERSION
|
|
@@ -110,11 +98,21 @@ RUN set -eux; \
|
|
|
110
98
|
|
|
111
99
|
WORKDIR ${WORKDIR_PATH}
|
|
112
100
|
|
|
113
|
-
#
|
|
114
|
-
|
|
101
|
+
# Sync locked dependencies for the runtime platform, then install the built wheel.
|
|
102
|
+
ARG PACKAGE_VERSION
|
|
103
|
+
RUN --mount=from=uv-tool,source=/uv,target=/usr/local/bin/uv \
|
|
104
|
+
--mount=from=builder,source=/tmp/build,target=/tmp/build,rw \
|
|
105
|
+
--mount=from=builder,source=/tmp/wheels,target=/tmp/wheels \
|
|
106
|
+
--mount=type=cache,target=/root/.cache/uv,id=uv-cache{{ CACHE_ID_SUFFIX }}{% for mount in UV_INDEX_SECRET_MOUNTS %} \
|
|
107
|
+
--mount={{ mount }}{% endfor %} \
|
|
108
|
+
UV_DYNAMIC_VERSIONING_BYPASS="${PACKAGE_VERSION}" UV_PROJECT_ENVIRONMENT=/opt/venv \
|
|
109
|
+
uv sync --project /tmp/build --python /usr/local/bin/python --no-python-downloads \
|
|
110
|
+
--locked --no-default-groups --no-install-project --no-editable --link-mode copy \
|
|
111
|
+
&& uv pip install --python /opt/venv/bin/python --no-deps --link-mode copy /tmp/wheels/*.whl \
|
|
112
|
+
&& /usr/local/bin/python -m pip uninstall --yes --root-user-action=ignore pip
|
|
113
|
+
|
|
114
|
+
ENV PATH="/opt/venv/bin:${PATH}"
|
|
115
115
|
|
|
116
|
-
# Install package
|
|
117
|
-
RUN --mount=type=cache,target=/root/.cache/pip,id=pip-cache{{ CACHE_ID_SUFFIX }} pip install --root-user-action=ignore /tmp/*.whl
|
|
118
116
|
# Create symlinks for the package
|
|
119
117
|
ARG PACKAGE_NAME
|
|
120
118
|
ENV PACKAGE_NAME=${PACKAGE_NAME}
|
|
@@ -133,7 +131,7 @@ LABEL git.commit=${GIT_COMMIT}
|
|
|
133
131
|
# This entrypoint is deliberately not configurable via environment variables in order to
|
|
134
132
|
# ensure that the container always uses the entrypoint selected at build time. If the
|
|
135
133
|
# current package does not provide a console script, the entrypoint will default to `python`
|
|
136
|
-
RUN
|
|
134
|
+
RUN printf '%s\n' '#!/bin/sh' '' "exec {{ ENTRYPOINT_COMMAND|default('python') }} \"\$@\"" >/pkg/entrypoint.sh \
|
|
137
135
|
&& chmod +x /pkg/entrypoint.sh
|
|
138
136
|
|
|
139
137
|
ARG RUNTIME_USER=py
|
|
@@ -144,16 +142,19 @@ USER ${RUNTIME_USER}
|
|
|
144
142
|
{% endif %}
|
|
145
143
|
|
|
146
144
|
{% if HAS_DEBUG_DEPS %}
|
|
147
|
-
#
|
|
148
|
-
# be built by default (the final stage below is the runtime image), and it will safely do
|
|
149
|
-
# nothing if there are no debug requirements
|
|
145
|
+
# The debug target adds its locked dependency group to the runtime environment.
|
|
150
146
|
FROM runtime AS debug
|
|
151
147
|
|
|
152
148
|
USER root
|
|
153
149
|
|
|
154
150
|
COPY --from=builder /tmp/build /tmp/build
|
|
155
151
|
|
|
156
|
-
RUN --mount=
|
|
152
|
+
RUN --mount=from=uv-tool,source=/uv,target=/usr/local/bin/uv \
|
|
153
|
+
--mount=type=cache,target=/root/.cache/uv,id=uv-cache{{ CACHE_ID_SUFFIX }}{% for mount in UV_INDEX_SECRET_MOUNTS %} \
|
|
154
|
+
--mount={{ mount }}{% endfor %} \
|
|
155
|
+
UV_DYNAMIC_VERSIONING_BYPASS="${PACKAGE_VERSION}" UV_PROJECT_ENVIRONMENT=/opt/venv \
|
|
156
|
+
uv sync --project /tmp/build --python /usr/local/bin/python --no-python-downloads \
|
|
157
|
+
--locked --no-default-groups --group debug --no-install-project --no-editable --inexact --link-mode copy
|
|
157
158
|
|
|
158
159
|
USER ${RUNTIME_USER}
|
|
159
160
|
{% endif %}
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/packaging_tasks.py
RENAMED
|
@@ -20,11 +20,10 @@ def publish_package(
|
|
|
20
20
|
from .project import get_publish_command
|
|
21
21
|
from .utils import run_command
|
|
22
22
|
|
|
23
|
+
command = get_publish_command(repository=repository, repository_url=repository_url)
|
|
23
24
|
if build_first:
|
|
24
25
|
build_package(clean_dist=True)
|
|
25
|
-
run_command(
|
|
26
|
-
get_publish_command(repository=repository, repository_url=repository_url)
|
|
27
|
-
)
|
|
26
|
+
run_command(command, unset_env=("UV_PUBLISH_INDEX", "UV_PUBLISH_URL"))
|
|
28
27
|
|
|
29
28
|
|
|
30
29
|
@tasks.script(
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/project.py
RENAMED
|
@@ -18,14 +18,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
18
18
|
|
|
19
19
|
PUBLISH_REPOSITORY_ENV_VAR = "COMMON_PYTHON_TASKS_PUBLISH_REPOSITORY"
|
|
20
20
|
PUBLISH_REPOSITORY_URL_ENV_VAR = "COMMON_PYTHON_TASKS_PUBLISH_URL"
|
|
21
|
-
PUBLISH_REPOSITORY_ENV_VARS = (
|
|
22
|
-
PUBLISH_REPOSITORY_ENV_VAR,
|
|
23
|
-
"UV_PUBLISH_INDEX",
|
|
24
|
-
)
|
|
25
|
-
PUBLISH_URL_ENV_VARS = (
|
|
26
|
-
PUBLISH_REPOSITORY_URL_ENV_VAR,
|
|
27
|
-
"UV_PUBLISH_URL",
|
|
28
|
-
)
|
|
29
21
|
|
|
30
22
|
|
|
31
23
|
def _parse_tool_version_output(output: str, tool_name: str) -> str:
|
|
@@ -44,14 +36,6 @@ def _parse_tool_version_output(output: str, tool_name: str) -> str:
|
|
|
44
36
|
utils.fatal(f"Unable to parse {tool_name} version output: {output!r}")
|
|
45
37
|
|
|
46
38
|
|
|
47
|
-
def _find_non_empty_env_override(env_vars: Sequence[str]) -> tuple[str, str] | None:
|
|
48
|
-
for env_var in env_vars:
|
|
49
|
-
value = os.getenv(env_var)
|
|
50
|
-
if value is not None and value.strip():
|
|
51
|
-
return env_var, value.strip()
|
|
52
|
-
return None
|
|
53
|
-
|
|
54
|
-
|
|
55
39
|
def _resolve_uv_publish_repository_from_config() -> str | None:
|
|
56
40
|
pyproject_data = read_pyproject_toml()
|
|
57
41
|
uv_config = pyproject_data.get("tool", {}).get("uv", {})
|
|
@@ -101,27 +85,17 @@ def _resolve_uv_publish_repository_from_config() -> str | None:
|
|
|
101
85
|
|
|
102
86
|
|
|
103
87
|
def _resolve_default_publish_target() -> tuple[str | None, str | None]:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
)
|
|
116
|
-
return config_repository_name, None
|
|
117
|
-
|
|
118
|
-
repository_url_override = _find_non_empty_env_override(PUBLISH_URL_ENV_VARS)
|
|
119
|
-
if repository_url_override is None:
|
|
120
|
-
return None, None
|
|
121
|
-
|
|
122
|
-
env_var, repository_url = repository_url_override
|
|
123
|
-
LOGGER.debug("Using uv publish URL %s from %s", repository_url, env_var)
|
|
124
|
-
return None, repository_url
|
|
88
|
+
for repository_var, url_var in (
|
|
89
|
+
(PUBLISH_REPOSITORY_ENV_VAR, PUBLISH_REPOSITORY_URL_ENV_VAR),
|
|
90
|
+
("UV_PUBLISH_INDEX", "UV_PUBLISH_URL"),
|
|
91
|
+
):
|
|
92
|
+
repository = os.getenv(repository_var, "").strip()
|
|
93
|
+
repository_url = os.getenv(url_var, "").strip()
|
|
94
|
+
if repository and repository_url:
|
|
95
|
+
utils.fatal(f"Specify either {repository_var} or {url_var}, not both.")
|
|
96
|
+
if repository or repository_url:
|
|
97
|
+
return repository or None, repository_url or None
|
|
98
|
+
return _resolve_uv_publish_repository_from_config(), None
|
|
125
99
|
|
|
126
100
|
|
|
127
101
|
def get_build_command(wheel_only: bool = False) -> list[str]:
|
|
@@ -174,6 +148,10 @@ def get_publish_command(
|
|
|
174
148
|
|
|
175
149
|
Returns:
|
|
176
150
|
Command tokens for the package publish command.
|
|
151
|
+
|
|
152
|
+
Raises:
|
|
153
|
+
SystemExit: The winning target source specifies both an index and URL,
|
|
154
|
+
or configured publishing indexes are ambiguous.
|
|
177
155
|
"""
|
|
178
156
|
if repository is not None and repository_url is not None:
|
|
179
157
|
utils.fatal("Specify either `repository` or `repository_url`, not both.")
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/release_tasks.py
RENAMED
|
@@ -150,11 +150,13 @@ def _run_release_flow(
|
|
|
150
150
|
parse_release_stage,
|
|
151
151
|
)
|
|
152
152
|
from .packaging_tasks import bump_version, publish_github_release
|
|
153
|
+
from .project import get_publish_command
|
|
153
154
|
from .utils import (
|
|
154
155
|
log_dry_run,
|
|
155
156
|
run_command,
|
|
156
157
|
)
|
|
157
158
|
|
|
159
|
+
get_publish_command(repository=repository, repository_url=repository_url)
|
|
158
160
|
release_component = parse_release_component(component)
|
|
159
161
|
release_stage = parse_release_stage(stage)
|
|
160
162
|
pre_script = pre_script or os.getenv("RELEASE_PRE_SCRIPT")
|
|
@@ -114,6 +114,7 @@ def run_command(
|
|
|
114
114
|
env: dict[str, str] | None = None,
|
|
115
115
|
always_show_command: bool = False,
|
|
116
116
|
dry_run: bool = False,
|
|
117
|
+
unset_env: Collection[str] | None = None,
|
|
117
118
|
) -> subprocess.CompletedProcess | None:
|
|
118
119
|
"""Run a command as a subprocess and handle errors.
|
|
119
120
|
|
|
@@ -128,6 +129,7 @@ def run_command(
|
|
|
128
129
|
always_show_command: If `True`, log the command with INFO when not in dry-run
|
|
129
130
|
mode.
|
|
130
131
|
dry_run: If `True`, log the command without executing it.
|
|
132
|
+
unset_env: Environment variable names to remove after merging overrides.
|
|
131
133
|
|
|
132
134
|
Returns:
|
|
133
135
|
The `CompletedProcess` instance from the subprocess run, or `None` for dry-run
|
|
@@ -151,12 +153,20 @@ def run_command(
|
|
|
151
153
|
log_dry_run("Would run command: %s", " ".join(command))
|
|
152
154
|
return None
|
|
153
155
|
|
|
154
|
-
merged_env =
|
|
156
|
+
merged_env = (
|
|
157
|
+
{**os.environ, **(env or {})}
|
|
158
|
+
if env is not None or unset_env is not None
|
|
159
|
+
else None
|
|
160
|
+
)
|
|
161
|
+
if merged_env is not None:
|
|
162
|
+
for name in unset_env or ():
|
|
163
|
+
merged_env.pop(name, None)
|
|
155
164
|
|
|
156
165
|
out = subprocess.run(
|
|
157
166
|
command,
|
|
158
167
|
capture_output=capture_output,
|
|
159
168
|
check=False,
|
|
169
|
+
shell=False,
|
|
160
170
|
text=True,
|
|
161
171
|
env=merged_env,
|
|
162
172
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/packaging-and-releases.md
RENAMED
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/build-deps-image.md
RENAMED
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/build-image.md
RENAMED
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/build-package.md
RENAMED
|
File without changes
|
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/bump-version.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/container-shell.md
RENAMED
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/docs-build.md
RENAMED
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/docs-serve.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/publish-package.md
RENAMED
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/push-image.md
RENAMED
|
File without changes
|
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/docs/tasks/reference/run-container.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/scripts/add_common_python_tasks.py
RENAMED
|
File without changes
|
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/scripts/update_docs_tasks_reference.py
RENAMED
|
File without changes
|
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/__init__.py
RENAMED
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/__main__.py
RENAMED
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/_task_registry.py
RENAMED
|
File without changes
|
{common_python_tasks-0.13.1 → common_python_tasks-0.14.0}/src/common_python_tasks/container_tasks.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|