From adfd31d645805ee8609ab2139e4116919b6a4171 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 6 Jun 2026 12:05:10 +0100 Subject: [PATCH] refac --- .dockerignore | 2 -- Dockerfile | 4 ++-- cptr/utils/changelog.py | 4 +++- pyproject.toml | 3 +++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index bb28d6f..023660f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,7 +11,5 @@ build/ cptr/frontend/node_modules/ cptr/frontend/.svelte-kit/ cptr/frontend/build/ -*.md -LICENSE CONTRIBUTOR_LICENSE_AGREEMENT .DS_Store diff --git a/Dockerfile b/Dockerfile index c27eedd..c6116f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN npm run build FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS backend-builder WORKDIR /build -COPY pyproject.toml uv.lock ./ +COPY pyproject.toml uv.lock LICENSE README.md CHANGELOG.md ./ COPY cptr/ cptr/ # Drop the pre-built frontend into the package tree @@ -40,7 +40,7 @@ USER cptr WORKDIR /home/cptr # Install the wheel into an isolated venv -COPY --from=backend-builder /dist/*.whl /tmp/ +COPY --chown=cptr:cptr --from=backend-builder /dist/*.whl /tmp/ RUN uv venv /home/cptr/.venv && \ uv pip install --python /home/cptr/.venv/bin/python /tmp/*.whl && \ rm /tmp/*.whl diff --git a/cptr/utils/changelog.py b/cptr/utils/changelog.py index 3c766e4..af10095 100644 --- a/cptr/utils/changelog.py +++ b/cptr/utils/changelog.py @@ -26,8 +26,10 @@ def parse_changelog(path: Path | None = None) -> dict: } """ if path is None: - # Look relative to project root (two levels up from this file) + # Look relative to project root (two levels up from this file) or inside the package path = Path(__file__).resolve().parent.parent.parent / "CHANGELOG.md" + if not path.exists(): + path = Path(__file__).resolve().parent.parent / "CHANGELOG.md" try: content = path.read_text(encoding="utf-8") diff --git a/pyproject.toml b/pyproject.toml index 36175ba..94e5661 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,9 @@ build-backend = "hatchling.build" packages = ["cptr"] artifacts = ["cptr/frontend/build"] +[tool.hatch.build.targets.wheel.force-include] +"CHANGELOG.md" = "cptr/CHANGELOG.md" + [tool.ruff] line-length = 100 target-version = "py39"