common-python-tasks 0.13.0__tar.gz → 0.13.1__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.13.1}/PKG-INFO +2 -3
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/README.md +1 -2
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/configuration.md +0 -13
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/getting-started.md +1 -1
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/index.md +0 -1
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/index.md +0 -1
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/packaging-and-releases.md +3 -1
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/pyproject.toml +1 -3
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/scripts/docs_tasks_reference.py +0 -3
- common_python_tasks-0.13.1/src/common_python_tasks/_task_registry.py +163 -0
- common_python_tasks-0.13.1/src/common_python_tasks/container_tasks.py +609 -0
- common_python_tasks-0.13.1/src/common_python_tasks/dependency_tasks.py +180 -0
- common_python_tasks-0.13.1/src/common_python_tasks/development_tasks.py +211 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/git.py +47 -30
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/github.py +4 -2
- common_python_tasks-0.13.1/src/common_python_tasks/packaging_tasks.py +161 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/project.py +0 -2
- common_python_tasks-0.13.1/src/common_python_tasks/release_tasks.py +433 -0
- common_python_tasks-0.13.1/src/common_python_tasks/tasks.py +93 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/utils.py +27 -15
- 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.13.1}/.gitignore +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/.poetry/plugins/poetry_dynamic_versioning-1.10.0.dist-info/licenses/LICENSE +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/.poetry/plugins/poetry_plugin_export-1.10.0.dist-info/licenses/LICENSE +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/LICENSE +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/documentation-workflows.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/container-images.md +1 -1
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/daily-development.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/documentation.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/build-deps-image.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/build-image.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/build-package.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/build.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/bump-version.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/changelog.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/clean.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/container-shell.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/docs-build.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/docs-serve.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/format.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/lint.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/publish-github-release.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/publish-package.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/push-image.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/release.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/run-container.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/test.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/docs/tasks/reference/update-dependencies.md +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/scripts/__init__.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/scripts/add_common_python_tasks.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/scripts/release_script.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/scripts/update_docs_tasks_reference.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/scripts/utils.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/__init__.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/__main__.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/data/dockerfile_extensions/docker-in-docker/Dockerfile +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/data/dockerfile_extensions/docker-in-docker/install.sh +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/data/dockerfile_extensions/docker-in-docker/supervisor.sh +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/data/generic/.coveragerc +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/data/generic/.dockerignore +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/data/generic/Dockerfile.deps.j2 +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/data/generic/Dockerfile.j2 +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/data/generic/cliff.toml +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/data/generic/pytest.ini +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/data/generic/ruff.toml +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/docker.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/src/common_python_tasks/env.py +0 -0
- {common_python_tasks-0.13.0 → common_python_tasks-0.13.1}/zensical.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: common-python-tasks
|
|
3
|
-
Version: 0.13.
|
|
3
|
+
Version: 0.13.1
|
|
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.13.
|
|
45
|
+
uv add --dev common-python-tasks==0.13.1
|
|
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.13.
|
|
12
|
+
uv add --dev common-python-tasks==0.13.1
|
|
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
|
|
|
@@ -70,19 +70,6 @@ Container variables are read by the host-side tasks unless their description exp
|
|
|
70
70
|
| `CONTAINER_DEPS_MOVE_SCRIPT` | Inline script that distributes copied dependency artifacts and takes precedence over mappings |
|
|
71
71
|
| `CONTAINER_DEPS_MOVE_SCRIPT_PATH` | Host path to a dependency move script; takes precedence over the inline script and mappings |
|
|
72
72
|
|
|
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
73
|
|
|
87
74
|
## Diagnostics
|
|
88
75
|
|
|
@@ -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
|
|
|
@@ -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.13.1}/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:
|
|
@@ -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"
|