Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
!src
!LICENSE.txt
!pyproject.toml
!poetry.lock
!uv.lock
!README.md

# Filter unwanted files from included folders.
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ on:
branches: [main]

env:
POETRY_VERSION: "2.1.1"
UV_VERSION: "2.1.1"
PYTHON_VERSION: "3.11"

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry==${POETRY_VERSION}
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry
- name: Install Nox and doc dependencies
run: poetry sync --only nox,docs
- name: Install dependencies
run: uv sync --locked
- name: Publish Docs
run: poetry run nox -s docs_github_pages
run: uv run nox -s docs_github_pages
47 changes: 24 additions & 23 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: python
on: [push, pull_request]

env:
POETRY_VERSION: "2.1.1"
UV_VERSION: "0.6.9"
PYTHON_VERSION: "3.11"

jobs:
Expand All @@ -14,49 +14,50 @@ jobs:
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry==${POETRY_VERSION}
- name: Install uv
uses: astral-sh/setup-uv@v5
# Caching is enabled by default for GitHub-hosted runners:
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
with:
version: ${{ env.UV_VERSION }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# https://github.com/actions/setup-python#caching-packages-dependencies
cache: poetry
- name: Install Nox
run: poetry sync --only nox
run: uv sync --locked --only-group nox
- name: Test with Nox
run: poetry run nox -s test-${{ matrix.python-version }}
run: uv run nox -s test-${{ matrix.python-version }}
quality:
runs-on: ubuntu-24.04
strategy:
matrix:
job:
- { nox-session: lint, poetry-groups: "lint" }
# type_check needs main and test dependencies for inline type annotations.
- { nox-session: type_check, poetry-groups: "type_check,main,test" }
- { nox-session: docs, poetry-groups: "docs" }
nox-session: ["lint", "type_check", "docs"]
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry==${POETRY_VERSION}
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry
- name: Install Nox and group dependencies
run: poetry sync --only nox,${{ matrix.job.poetry-groups }}
- name: Install dependencies
run: uv sync --locked
- name: Test with Nox
run: poetry run nox -s ${{ matrix.job.nox-session }}
poetry-check:
run: uv run nox -s ${{ matrix.nox-session }}
lock-check:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry==${POETRY_VERSION}
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Validate Poetry Configuration and Lockfile Freshness
run: poetry check --lock --strict
- name: Validate Lockfile Up-to-date
run: uv lock --check
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
23 changes: 11 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
# - Most Python packages that require C code are tested against GLIBC, so there could be
# subtle errors when using MUSL.
# - These Python packages usually only provide binary wheels for GLIBC, so the packages
# will need to be recompiled fully within the Docker images, increasing build times.
# will need to be recompiled fully within the container images, increasing build times.
FROM python:3.11-slim-bookworm AS python_builder

# Pin Poetry to a specific version to make Docker builds reproducible.
ENV POETRY_VERSION=2.1.1
# Pin uv to a specific version to make container builds reproducible.
ENV UV_VERSION=0.6.9

# Set ENV variables that make Python more friendly to running inside a container.
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONBUFFERED=1

# By default, pip caches copies of downloaded packages from PyPI. These are not useful within
# a Docker image, so disable this to reduce the size of images.
# a contain image, so disable this to reduce the size of images.
ENV PIP_NO_CACHE_DIR=1
ENV WORKDIR=/src

Expand All @@ -30,9 +30,8 @@ WORKDIR ${WORKDIR}
# gcc \
# && rm -rf /var/lib/apt/lists/*

# Install Poetry into the global environment to isolate it from the venv. This prevents Poetry
# from uninstalling parts of itself.
RUN pip install "poetry==${POETRY_VERSION}"
# Install uv into the global environment to isolate it from the venv it creates.
RUN pip install "uv==${UV_VERSION}"

# Pre-download/compile wheel dependencies into a virtual environment.
# Doing this in a multi-stage build allows omitting compile dependencies from the final image.
Expand All @@ -43,17 +42,17 @@ RUN python -m venv ${VIRTUAL_ENV}
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"

# Copy in project dependency specification.
COPY pyproject.toml poetry.lock ./
COPY pyproject.toml uv.lock ./

# Don't install the package itself with Poetry because it will install it as an editable install.
RUN poetry sync --only main --no-root
# Don't install the package itself with uv because it will install it as an editable install.
RUN uv sync --locked --no-default-groups --no-install-project

# Copy in source files.
COPY README.md ./
COPY src src

# Manually build/install the package.
RUN poetry build && \
RUN uv build && \
pip install dist/*.whl

## Final Image
Expand All @@ -73,7 +72,7 @@ RUN mkdir -p ${HOME}

# Create the user so the program doesn't run as root. This increases security of the container.
RUN groupadd -r user && \
useradd -r -g user -d ${HOME} -s /sbin/nologin -c "Docker image user" user
useradd -r -g user -d ${HOME} -s /sbin/nologin -c "Container image user" user

# Setup application install directory.
RUN mkdir ${APP_HOME}
Expand Down
Loading