From a21a8e6732c1223ffab9f40d93c711550b30ffde Mon Sep 17 00:00:00 2001 From: Simon Li Date: Sun, 22 Jun 2025 19:54:30 +0100 Subject: [PATCH 1/3] Handle breaking changes in repo2docker https://github.com/jupyterhub/repo2docker/pull/1421 --- .github/workflows/build.yml | 34 +++++++++++++++++++++++++++++----- repo2podman/podman.py | 22 ++++++++++++++++++++++ 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1363951..ffc3fff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,6 +21,9 @@ jobs: python_version: ["3.9"] container_engine: - podman + repo2docker_version: + # Use version in dev-requirements.txt + - "" repo_type: # Only test a subset of the repo2docker tests since we're testing podman, # not the full repo2docker functionality @@ -48,6 +51,11 @@ jobs: - python_version: "3.11" container_engine: nerdctl repo_type: venv/default + - python_version: "3.13" + container_engine: podman + repo_type: base + # 2025-05-12 + repo2docker_version: e795060aec3555a6203ed79c3676765fb3f3b850 steps: - name: Checkout repo @@ -69,9 +77,16 @@ jobs: containerd-rootless-setuptool.sh install containerd-rootless-setuptool.sh install-buildkit - - name: Install + - name: Install dependencies run: | pip install -r dev-requirements.txt + if [ -n "${{ matrix.repo2docker_version }}" ]; then + pip install git+https://github.com/jupyterhub/repo2docker@${{ matrix.repo2docker_version }} + fi + pip freeze + + - name: Install + run: | # Make a wheel and install it to catch possible issues with releases python -m build --wheel pip install dist/*.whl @@ -80,10 +95,19 @@ jobs: - name: Fetch repo2docker tests run: | # Tests need to match the r2d version, need to convert YYYY.M.N to YYYY.MM.N - R2D_PY_VERSION=$(grep jupyter-repo2docker== dev-requirements.txt | cut -d= -f3) - GIT_TAG=$(echo $R2D_PY_VERSION | sed -re 's/\.([[:digit:]])\./.0\1./') - echo "Cloning repo2docker test from tag: $GIT_TAG" - git clone --depth 1 --branch=$GIT_TAG https://github.com/jupyter/repo2docker tests-repo2docker + + if [ -n "${{ matrix.repo2docker_version }}" ]; then + echo "Cloning repo2docker test: ${{ matrix.repo2docker_version }}" + git clone https://github.com/jupyter/repo2docker tests-repo2docker + cd tests-repo2docker + git checkout ${{ matrix.repo2docker_version }} + cd .. + else + R2D_PY_VERSION=$(grep jupyter-repo2docker== dev-requirements.txt | cut -d= -f3) + GIT_TAG=$(echo $R2D_PY_VERSION | sed -re 's/\.([[:digit:]])\./.0\1./') + echo "Cloning repo2docker test from tag: $GIT_TAG" + git clone --depth 1 --branch=$GIT_TAG https://github.com/jupyter/repo2docker tests-repo2docker + fi for d in ./tests-repo2docker/tests/*/; do if [ "${d##*tests/}" != "unit/" ]; then cp -a $d tests diff --git a/repo2podman/podman.py b/repo2podman/podman.py index 56333f1..5da10f4 100644 --- a/repo2podman/podman.py +++ b/repo2podman/podman.py @@ -381,6 +381,8 @@ def __init__(self, *, parent): def build( self, *, + push=False, + load=False, buildargs=None, cache_from=None, container_limits=None, @@ -449,6 +451,11 @@ def build( # except KeyError: # pass + # load is ignored, only used by docker buildx + # https://github.com/jupyterhub/repo2docker/pull/1421/files + if push and not tag: + raise ValueError("tag required when push=True") + if kwargs: raise ValueError("Additional kwargs not supported") @@ -474,6 +481,10 @@ def build( ): yield line + if push: + for line in self.push(tag): + yield line + def images(self): def remove_local(tags): if tags: @@ -503,6 +514,17 @@ def remove_local(tags): ] def inspect_image(self, image): + # https://github.com/jupyterhub/repo2docker/pull/1421 + # Return None if image doesn't exist + try: + exec_podman( + ["image", "exists", image], capture="both", exe=self.podman_executable + ) + except PodmanCommandError as e: + if isinstance(e.e, CalledProcessError) and e.e.returncode == 1: + return None + raise + lines = exec_podman( ["inspect", "--type", "image", "--format", self.format_arg, image], capture="stdout", From 7d3a09a9e8eab70fe1229f0ed4ce4329d56ce8e2 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Sun, 22 Jun 2025 19:56:27 +0100 Subject: [PATCH 2/3] update pre-commit --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 05341b7..536ad64 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,12 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.3.0 + rev: v0.12.0 hooks: - id: ruff args: [--fix] - id: ruff-format - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.3 + - repo: https://github.com/rbubley/mirrors-prettier + rev: v3.5.3 hooks: - id: prettier From d117f13ebd3b86ac34fd7bcc980ab9a41fabadd7 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Sun, 22 Jun 2025 20:02:38 +0100 Subject: [PATCH 3/3] pipes.quote removed in Python 3.13 --- tests/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 68e5dcd..13f3b63 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,7 +9,7 @@ """ import os -import pipes +import shlex import requests import time @@ -87,7 +87,7 @@ def reportinfo(self): def repr_failure(self, excinfo): err = excinfo.value if isinstance(err, SystemExit): - cmd = "jupyter-repo2docker %s" % " ".join(map(pipes.quote, self.args)) + cmd = "jupyter-repo2docker %s" % " ".join(map(shlex.quote, self.args)) return "%s | exited with status=%s" % (cmd, err.code) else: return super().repr_failure(excinfo)