Skip to content

Commit 65c8479

Browse files
committed
migrated to Python 3.14 and updated Dockerfile
1 parent a1c9f8a commit 65c8479

6 files changed

Lines changed: 72 additions & 257 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,42 @@ on:
77
branches:
88
- develop
99

10+
permissions:
11+
contents: read
12+
packages: write
13+
1014
jobs:
1115
docker:
1216
runs-on: ubuntu-latest
1317
steps:
14-
- name: Authenticate GitHub Container Registry
15-
uses: docker/login-action@v3
18+
- name: Checkout Repository
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+
- name: Extract Docker Metadata
21+
id: meta
22+
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
1623
with:
17-
registry: ghcr.io
18-
username: kennethsible
19-
password: ${{ secrets.GH_PAT }}
24+
images: ghcr.io/kennethsible/abs-ranobedb
25+
tags: |
26+
type=ref,event=branch
27+
type=semver,pattern={{version}}
28+
type=semver,pattern={{major}}.{{minor}}
2029
- name: Initialize QEMU
21-
uses: docker/setup-qemu-action@v3
30+
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
2231
- name: Initialize Docker Buildx
23-
uses: docker/setup-buildx-action@v3
24-
- name: Set Image Tags
25-
id: tags
26-
run: |
27-
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
28-
echo "tags=ghcr.io/kennethsible/abs-ranobedb:latest,ghcr.io/kennethsible/abs-ranobedb:${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
29-
else
30-
echo "tags=ghcr.io/kennethsible/abs-ranobedb:${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
31-
fi
32+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
33+
- name: Authenticate GitHub Container Registry
34+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
3239
- name: Build and Push Image
33-
uses: docker/build-push-action@v6
40+
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
3441
with:
3542
platforms: linux/amd64,linux/arm64
3643
push: true
3744
provenance: false
38-
tags: ${{ steps.tags.outputs.tags }}
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}
47+
cache-from: type=gha
48+
cache-to: type=gha,mode=max

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
1+
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim AS builder
22
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
33
ENV UV_PYTHON_DOWNLOADS=0
44

@@ -9,7 +9,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
99
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
1010
uv sync --locked --no-install-project --no-dev
1111

12-
FROM python:3.13-slim-bookworm
12+
FROM python:3.14-slim-bookworm
1313
ENV PYTHONUNBUFFERED=1
1414

1515
WORKDIR /app

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[project]
22
name = "absranobedb"
3-
version = "1.4.0"
3+
version = "1.4.1"
44
description = "RanobeDB Metadata Provider for Audiobookshelf"
55
license = { text = "MIT" }
66
authors = [{ name = "Ken Sible", email = "ksible@outlook.com" }]
7-
requires-python = ">=3.13"
7+
requires-python = ">=3.14,<3.15"
88
dependencies = [
99
"aiohttp>=3.13.5",
1010
"aiolimiter>=1.2.1",
@@ -17,7 +17,7 @@ dependencies = [
1717
]
1818

1919
[dependency-groups]
20-
dev = ["ruff>=0.15.8", "mypy>=1.20.0", "types-requests"]
20+
dev = ["ruff>=0.15.10", "mypy>=1.20.0", "types-requests"]
2121

2222
[project.urls]
2323
homepage = "https://github.com/kennethsible/abs-ranobedb"

src/absranobedb/main.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def extract_author(details: dict[str, Any], tag: str) -> str:
3939
author_names: list[str] = []
4040
for edition in details.get('editions', []):
4141
for staff in edition.get('staff', []):
42-
if staff.get('role_type') in ['author', 'artist']:
42+
if staff.get('role_type') in ('author', 'artist'):
4343
if not PREFER_ROMAJI and tag == 'ja':
4444
name = staff.get('name') or staff.get('romaji')
4545
else:
@@ -228,8 +228,9 @@ async def gather_authors(
228228
author_string: str, session: aiohttp.ClientSession, limiter: AsyncLimiter
229229
) -> list[list[str]]:
230230
authors = [a.strip() for a in re.split(r'[;,|]', author_string) if a.strip()]
231-
tasks = [fetch_staff_ids(author, session, limiter) for author in authors]
232-
return await asyncio.gather(*tasks)
231+
async with asyncio.TaskGroup() as tg:
232+
tasks = [tg.create_task(fetch_staff_ids(author, session, limiter)) for author in authors]
233+
return [task.result() for task in tasks]
233234

234235

235236
async def extract_metadata(
@@ -270,8 +271,12 @@ async def extract_metadata(
270271
async def gather_matches(
271272
data: dict[str, Any], session: aiohttp.ClientSession, limiter: AsyncLimiter
272273
) -> list[tuple[Any | None, dict[str, Any]]]:
273-
tasks = [extract_metadata(summary, session, limiter) for summary in data.get('books', [])]
274-
return await asyncio.gather(*tasks)
274+
async with asyncio.TaskGroup() as tg:
275+
tasks = [
276+
tg.create_task(extract_metadata(summary, session, limiter))
277+
for summary in data.get('books', [])
278+
]
279+
return [task.result() for task in tasks]
275280

276281

277282
async def search(request: web.Request) -> web.Response:
@@ -377,8 +382,12 @@ async def run_server() -> None:
377382
stop_event = asyncio.Event()
378383
loop = asyncio.get_running_loop()
379384

380-
loop.add_signal_handler(signal.SIGTERM, stop_event.set)
381-
loop.add_signal_handler(signal.SIGINT, stop_event.set)
385+
def handle_signal(sig_name: str) -> None:
386+
logger.info(f'received {sig_name} signal; shutting down...')
387+
stop_event.set()
388+
389+
loop.add_signal_handler(signal.SIGTERM, lambda: handle_signal('SIGTERM'))
390+
loop.add_signal_handler(signal.SIGINT, lambda: handle_signal('SIGINT'))
382391

383392
await stop_event.wait()
384393
await runner.cleanup()

0 commit comments

Comments
 (0)