Skip to content

Commit 58ba1a4

Browse files
committed
feat!: drop Poetry support
1 parent 841cf89 commit 58ba1a4

21 files changed

Lines changed: 313 additions & 1003 deletions

‎.vscode/settings.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"files.exclude": {
1212
"**/.venv": true,
1313
"**/__pycache__": true,
14-
"**/.poetry": true,
1514
"**/.pytest_cache": true,
1615
"**/.git": true,
1716
"**/.gitconfig.global": true,
@@ -28,4 +27,4 @@
2827
"**/out": true,
2928
"**/*.log": true,
3029
}
31-
}
30+
}

‎.vscode/tasks.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"label": "Install Dependencies",
66
"type": "shell",
7-
"command": "poetry install",
7+
"command": "uv sync",
88
"options": {
99
"cwd": "${workspaceFolder}"
1010
},
@@ -52,7 +52,7 @@
5252
{
5353
"label": "Build",
5454
"type": "shell",
55-
"command": "poetry build",
55+
"command": "uv build",
5656
"options": {
5757
"cwd": "${workspaceFolder}"
5858
},
@@ -82,4 +82,4 @@
8282
}
8383
}
8484
]
85-
}
85+
}

‎README.md‎

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Add `common-python-tasks` as a development dependency from your project root.
1212

1313
```shell
1414
uv add --dev common-python-tasks==0.8.0
15-
# or, for Poetry projects
16-
poetry add --group dev common-python-tasks==0.8.0
1715
```
1816

1917
Configure Poe the Poet to expose the default `common` task set.
@@ -76,7 +74,7 @@ The generated tables below list public tasks only. Tags identify which tasks are
7674
| --- | --- | --- |
7775
| `publish-package` | Publish the package to the PyPI server. | common, packaging |
7876
| `publish-github-release` | Publish or update a GitHub Release for the current repository. | common, packaging, release |
79-
| `update-dependencies` | Update project dependencies with Poetry or uv. | common, packaging |
77+
| `update-dependencies` | Update project dependencies with uv. | common, packaging |
8078
| `build-package` | Build the package (wheel and sdist). | build, common, packaging |
8179
| `bump-version` | Bump the project version. | common, packaging |
8280
| `changelog` | Print the changelog for the current version based on git history and git-cliff. | common, packaging, release |
@@ -111,7 +109,7 @@ The generated tables below list public tasks only. Tags identify which tasks are
111109

112110
Every project needs a `pyproject.toml` file at its root and Poe the Poet available in its development environment.
113111

114-
Tasks that install, build, publish, or update dependencies also require either Poetry or uv. Package and release tasks need a resolvable project version from `project.version`, Poetry's version resolution, or Git tags. Dynamic-versioning plugins are supported but are not a baseline requirement.
112+
Tasks that install, build, publish, or update dependencies require uv. Package and release tasks need a resolvable project version from `project.version` or Git tags. Dynamic versioning is supported but is not a baseline requirement.
115113

116114
### Task selection
117115

@@ -131,18 +129,9 @@ include_script = "common_python_tasks:tasks(include_tags=['common', 'containers'
131129

132130
The `containers` tag also includes container-based development-stack tasks. Use the tags in the task tables to tailor a smaller task set.
133131

134-
### Package manager backend selection
132+
### Package management
135133

136-
Packaging-related tasks, including `build-package`, `publish-package`, release version resolution, and container build metadata, support Poetry and uv.
137-
138-
Backend selection uses this precedence.
139-
140-
1. `COMMON_PYTHON_TASKS_PACKAGE_MANAGER`
141-
2. `COMMON_PYTHON_TASKS_BUILD_TOOL`
142-
3. `PACKAGE_MANAGER`
143-
4. Auto-discovery (`auto`) based on installed tools and project metadata
144-
145-
Supported values are `poetry`, `uv`, and `auto`.
134+
Packaging-related tasks, including `build-package`, `publish-package`, dependency updates, release version resolution, and container build metadata, use uv exclusively. The `uv` executable must be available on `PATH`.
146135

147136
### Publish target selection
148137

@@ -151,12 +140,7 @@ The `publish-package` task resolves publish targets with this precedence.
151140
1. Explicit task arguments (`repository` or `repository_url`)
152141
2. Environment-variable fallback
153142
3. uv project configuration fallback from `[[tool.uv.index]]`
154-
4. Backend defaults (`poetry publish` or `uv publish`)
155-
156-
Poetry uses repository names only.
157-
158-
- `COMMON_PYTHON_TASKS_PUBLISH_REPOSITORY`
159-
- `POETRY_REPOSITORY`
143+
4. The `uv publish` default
160144

161145
uv prefers named publish indexes.
162146

@@ -223,12 +207,8 @@ addopts = "-ra"
223207
#### Project and package settings
224208

225209
- `PACKAGE_NAME`: Overrides the package name inferred from `pyproject.toml`
226-
- `COMMON_PYTHON_TASKS_PACKAGE_MANAGER`: Selects the package-manager backend as `poetry`, `uv`, or `auto`
227-
- `COMMON_PYTHON_TASKS_BUILD_TOOL`: Alias for `COMMON_PYTHON_TASKS_PACKAGE_MANAGER`
228-
- `PACKAGE_MANAGER`: Alias for `COMMON_PYTHON_TASKS_PACKAGE_MANAGER`
229210
- `COMMON_PYTHON_TASKS_PUBLISH_REPOSITORY`: Preferred publish repository/index name for `publish-package`
230211
- `COMMON_PYTHON_TASKS_PUBLISH_URL`: Preferred uv publish upload URL for `publish-package` when no repository/index is selected
231-
- `POETRY_REPOSITORY`: Poetry repository-name fallback for `publish-package`
232212
- `UV_PUBLISH_INDEX`: uv publish-index fallback for `publish-package`
233213
- `UV_PUBLISH_URL`: uv publish upload-url fallback for `publish-package`
234214

@@ -382,7 +362,7 @@ GITHUB_RELEASE_ASSETS="dist/*.whl:dist/*.tar.gz" poe publish-github-release
382362

383363
### Container build fails with "unable to find package"
384364

385-
Check that `pyproject.toml` has a correct package name and the package-discovery settings required by its build backend. For Poetry projects, this commonly includes `[tool.poetry] packages = [{ include = "your_package", from = "src" }]`.
365+
Check that `pyproject.toml` has a correct package name and the package-discovery settings required by its build backend. For a `src` layout built with Hatch, configure `[tool.hatch.build.targets.wheel] packages = ["src/your_package"]`.
386366

387367
### Stack fails to start or services cannot connect
388368

@@ -407,9 +387,9 @@ Ensure the project-root `.env` file is writable and inspect its permissions with
407387

408388
See the [standard Dockerfile template](src/common_python_tasks/data/generic/Dockerfile.j2) for the implementation.
409389

410-
- Multi-stage build: The build stage installs the selected package-manager backend and builds a wheel. The runtime stage installs only the wheel to keep the final image slim and reproducible.
411-
- Cache mounts: Pip and package-manager cache mounts speed up iterative builds without bloating the final image.
412-
- Explicit build metadata: `PYTHON_VERSION`, `PACKAGE_MANAGER`, `PACKAGE_MANAGER_VERSION`, `PACKAGE_NAME`, `AUTHORS`, and `GIT_COMMIT` make image metadata predictable and auditable.
390+
- Multi-stage build: The build stage installs uv and builds a wheel. The runtime stage installs only the wheel to keep the final image slim and reproducible.
391+
- Cache mounts: Pip and uv cache mounts speed up iterative builds without bloating the final image.
392+
- Explicit build metadata: `PYTHON_VERSION`, `UV_VERSION`, `PACKAGE_VERSION`, `PACKAGE_NAME`, `AUTHORS`, and `GIT_COMMIT` make image metadata predictable and auditable.
413393
- Project-level build settings: `CONTAINER_APT_PACKAGES`, `CONTAINER_CUSTOM_ENTRYPOINT`, and `CONTAINER_DEPS_IMAGE` configure generated image behavior without being encoded as generic Docker arguments.
414394
- Optional debug stage: The image exports and installs the `debug` dependency group only when present and does not include it in the default final image.
415395
- Stable package path: Symlinks give entrypoints and consumers consistent `/pkg` and `/_$PACKAGE_NAME` paths regardless of wheel layout.

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ package = true
7373

7474
[tool.ruff]
7575
line-length = 88
76-
extend-exclude = [".dist", ".poetry", "build"]
76+
extend-exclude = [".dist", "build"]
7777

7878
[tool.ruff.lint]
7979
select = ["E4", "E7", "E9", "F", "I", "W"]

‎scripts/add_common_python_tasks.py‎

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
from pathlib import Path
1111

1212
PACKAGE_NAME = "common-python-tasks"
13-
PACKAGE_MANAGER_ENV_VARS = (
14-
"COMMON_PYTHON_TASKS_PACKAGE_MANAGER",
15-
"COMMON_PYTHON_TASKS_BUILD_TOOL",
16-
"PACKAGE_MANAGER",
17-
)
1813
PYPROJECT_PATH = Path("pyproject.toml")
1914
TOOL_POE_PATTERN = re.compile(r"^\s*\[tool\.poe\]\s*(?:#.*)?$")
2015
TABLE_PATTERN = re.compile(r"^\s*\[")
@@ -26,47 +21,18 @@ def _require_command(command: str) -> None:
2621
sys.exit(f"Required command not found: {command}")
2722

2823

29-
def _get_requested_package_manager() -> str:
30-
for env_var in PACKAGE_MANAGER_ENV_VARS:
31-
if os.getenv(env_var, "").strip():
32-
return os.environ[env_var].strip().lower()
33-
return "auto"
34-
35-
36-
def _select_package_manager() -> str:
37-
requested_manager = _get_requested_package_manager()
38-
if requested_manager in {"poetry", "uv"}:
39-
_require_command(requested_manager)
40-
return requested_manager
41-
if requested_manager != "auto":
42-
sys.exit(f"Unsupported package manager: {requested_manager}")
43-
44-
for lock_file, package_manager in (
45-
(Path("uv.lock"), "uv"),
46-
(Path("poetry.lock"), "poetry"),
47-
):
48-
if lock_file.is_file() and shutil.which(package_manager) is not None:
49-
return package_manager
50-
51-
for package_manager in ("uv", "poetry"):
52-
if shutil.which(package_manager) is not None:
53-
return package_manager
54-
55-
sys.exit("Neither uv nor Poetry is installed.")
56-
57-
5824
def _get_package_requirement() -> str:
5925
if os.getenv("COMMON_PYTHON_TASKS_VERSION", "").strip():
6026
return f"{PACKAGE_NAME}=={os.environ['COMMON_PYTHON_TASKS_VERSION'].strip()}"
6127
return PACKAGE_NAME
6228

6329

64-
def _install_package(package_manager: str) -> None:
65-
if package_manager == "uv":
66-
command = ["uv", "add", "--dev", _get_package_requirement()]
67-
else:
68-
command = ["poetry", "add", "--group", "dev", _get_package_requirement()]
69-
subprocess.run(command, check=True, shell=False)
30+
def _install_package() -> None:
31+
subprocess.run(
32+
["uv", "add", "--dev", _get_package_requirement()],
33+
check=True,
34+
shell=False,
35+
)
7036

7137

7238
def _get_include_script() -> str:
@@ -132,7 +98,8 @@ def _print_available_tasks() -> None:
13298

13399
def main() -> None:
134100
"""Install common tasks and configure Poe in the current project."""
135-
_install_package(_select_package_manager())
101+
_require_command("uv")
102+
_install_package()
136103
_configure_poe()
137104
print("\n\033[1;32mCommon Python tasks added to project.\033[0m")
138105
print("\n\033[1mAvailable tasks:\033[0m")

‎src/common_python_tasks/data/fastapi/compose-base.yml.j2‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ x-common-environment: &common-environment
99
x-common-build-args: &common-build-args
1010
PACKAGE_NAME: ${PACKAGE_NAME}
1111
PYTHON_VERSION: ${PYTHON_VERSION}
12-
PACKAGE_MANAGER: ${PACKAGE_MANAGER}
13-
PACKAGE_MANAGER_VERSION: ${PACKAGE_MANAGER_VERSION}
12+
UV_VERSION: ${UV_VERSION}
1413

1514
services:
1615
api:

‎src/common_python_tasks/data/fastapi/compose-db.yml.j2‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ x-common-environment: &common-environment
88
x-common-build-args: &common-build-args
99
PACKAGE_NAME: ${PACKAGE_NAME}
1010
PYTHON_VERSION: ${PYTHON_VERSION}
11-
PACKAGE_MANAGER: ${PACKAGE_MANAGER}
12-
PACKAGE_MANAGER_VERSION: ${PACKAGE_MANAGER_VERSION}
11+
UV_VERSION: ${UV_VERSION}
1312
WORKDIR_PATH: ${WORKDIR_PATH}
1413

1514
services:

‎src/common_python_tasks/data/fastapi/compose-debug.yml.j2‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ services:
2222
path: ./src/${PACKAGE_UNDERSCORE_NAME}
2323
target: /${PACKAGE_UNDERSCORE_NAME}
2424
- action: rebuild
25-
path: poetry.lock
25+
path: uv.lock
2626
ports:
2727
- mode: ingress
2828
target: 5678

‎src/common_python_tasks/data/generic/.dockerignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
*
22
!dist/*.whl
33
!pyproject.toml
4-
!poetry.lock
4+
!uv.lock
55
!README.md
66
!LICENSE
77

‎src/common_python_tasks/data/generic/Dockerfile.j2‎

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,10 @@ ARG PYTHON_VERSION=3
77
# See https://hub.docker.com/_/python for available variants
88
ARG PYTHON_VARIANT=slim
99
ARG WORKDIR_PATH=/workspace
10-
{% set package_manager = PACKAGE_MANAGER|default('poetry') %}
1110

1211
FROM python:${PYTHON_VERSION} AS builder
1312

1413
ARG PACKAGE_VERSION
15-
16-
{% if package_manager == 'poetry' %}
17-
ARG POETRY_VERSION
18-
ARG POETRY_DYNAMIC_VERSIONING_PLUGIN_VERSION
19-
ARG POETRY_PLUGIN_EXPORT_VERSION
20-
21-
# Bypass VCS-based version detection: use the host-computed version directly.
22-
# This avoids requiring a .git directory in the build context and prevents
23-
# false dirty-version detection from a partial working tree.
24-
ENV POETRY_DYNAMIC_VERSIONING_BYPASS=${PACKAGE_VERSION}
25-
26-
# Install Poetry and required Poetry plugins for package build
27-
RUN --mount=type=cache,target=/root/.cache/pip,id=pip-cache{{ CACHE_ID_SUFFIX }} \
28-
sh -c 'set -eu; \
29-
poetry_spec="poetry"; \
30-
if [ -n "${POETRY_VERSION:-}" ]; then poetry_spec="poetry==$POETRY_VERSION"; fi; \
31-
dynamic_spec="poetry-dynamic-versioning[plugin]"; \
32-
if [ -n "${POETRY_DYNAMIC_VERSIONING_PLUGIN_VERSION:-}" ]; then dynamic_spec="poetry-dynamic-versioning[plugin]==$POETRY_DYNAMIC_VERSIONING_PLUGIN_VERSION"; fi; \
33-
export_spec="poetry-plugin-export"; \
34-
if [ -n "${POETRY_PLUGIN_EXPORT_VERSION:-}" ]; then export_spec="poetry-plugin-export==$POETRY_PLUGIN_EXPORT_VERSION"; fi; \
35-
pip install --root-user-action=ignore "$poetry_spec" "$dynamic_spec" "$export_spec"'
36-
{% else %}
3714
ARG UV_VERSION
3815

3916
# Bypass VCS-based version detection: use the host-computed version directly.
@@ -48,32 +25,22 @@ RUN --mount=type=cache,target=/root/.cache/pip,id=pip-cache{{ CACHE_ID_SUFFIX }}
4825
else \
4926
pip install --root-user-action=ignore uv; \
5027
fi'
51-
{% endif %}
5228

5329
# Build package
5430
WORKDIR /tmp/build
5531
COPY . /tmp/build/
5632

5733
{% if HAS_DEBUG_DEPS %}
5834
# Export debug requirements when the project defines a debug dependency group
59-
{% if package_manager == 'poetry' %}
60-
RUN --mount=type=cache,target=/root/.cache/pip,id=pip-cache{{ CACHE_ID_SUFFIX }} \
61-
poetry export --only debug --without-hashes -f requirements.txt --output requirements-debug.txt
62-
{% else %}
6335
RUN --mount=type=cache,target=/root/.cache/uv,id=uv-cache{{ CACHE_ID_SUFFIX }} \
6436
uv export --group debug --no-hashes --format requirements-txt --output-file requirements-debug.txt
6537
{% endif %}
66-
{% endif %}
6738

68-
# Build the wheel, caching the package-manager cache directory to speed up subsequent builds.
39+
# Build the wheel, caching the uv cache directory to speed up subsequent builds.
6940
# If running this in a CI system, you must be using a persistent builder to take
7041
# advantage of the cache mount, and you should configure your CI to persist the
7142
# cache directory between builds
72-
{% if package_manager == 'poetry' %}
73-
RUN --mount=type=cache,target=/root/.cache/pypoetry,id=pypoetry-cache{{ CACHE_ID_SUFFIX }} poetry build --format=wheel
74-
{% else %}
7543
RUN --mount=type=cache,target=/root/.cache/uv,id=uv-cache{{ CACHE_ID_SUFFIX }} uv build --wheel
76-
{% endif %}
7744

7845
FROM python:${PYTHON_VERSION}-${PYTHON_VARIANT} AS runtime
7946
ARG WORKDIR_PATH=/workspace

0 commit comments

Comments
 (0)