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
119 changes: 119 additions & 0 deletions .github/workflows/build-deptry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# This workflow drives upstream's own wheel build (release.yml `linux` job, which calls
# PyO3/maturin-action) through cibuildwheel, narrowed to riscv64.
name: Build deptry wheels (riscv64)

on:
workflow_dispatch:
inputs:
version:
description: 'deptry version/tag to build (e.g. 0.25.1)'
required: true
default: '0.25.1'
pull_request:
paths:
- '.github/workflows/build-deptry.yml'

concurrency:
group: ${{ github.workflow }}-${{ inputs.version || '0.25.1' }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read # to fetch code (actions/checkout)

env:
# `inputs.version` is empty on pull_request events; default to 0.25.1 there.
DEPTRY_VERSION: ${{ inputs.version || '0.25.1' }}
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64

jobs:
setup:
uses: $/.github/workflows/_setup.yml

build_wheels:
needs: [setup]
name: Build deptry ${{ inputs.version || '0.25.1' }} cp310-abi3-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
timeout-minutes: 360

steps:
- name: Checkout deptry ${{ env.DEPTRY_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: osprey-oss/deptry
ref: ${{ env.DEPTRY_VERSION }}
persist-credentials: false

- name: Checkout python-wheels
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: python-wheels
sparse-checkout: patches/deptry
persist-credentials: false

- name: Apply patches
run: git apply -v python-wheels/patches/deptry/${{ env.DEPTRY_VERSION }}/*.patch

# pyproject.toml carries a stale placeholder version; upstream's own release
# job stamps the real one from the tag the same way (release.yml set-version).
- name: Set version from tag
run: |
sed -i "s/^version = \".*\"/version = \"${DEPTRY_VERSION}\"/" pyproject.toml
grep -qx "version = \"${DEPTRY_VERSION}\"" pyproject.toml

- name: Build wheels
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
with:
output-dir: wheelhouse/
env:
# Cargo.toml's pyo3 dependency carries abi3-py310 unconditionally
# (gotcha 181), so every interpreter below reuses the cp310 build
# ("Found previously built wheel ... Skipping build step").
CIBW_BUILD: >-
cp310-manylinux_riscv64 cp311-manylinux_riscv64 cp312-manylinux_riscv64
cp313-manylinux_riscv64 cp314-manylinux_riscv64
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
# deptry ships no [tool.cibuildwheel]; the Rust toolchain its maturin
# backend needs is installed in-container here (gotcha 10).
CIBW_BEFORE_ALL_LINUX: >-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
CIBW_ENVIRONMENT_LINUX: >-
PATH="$PATH:$HOME/.cargo/bin"
PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/
# poetry pulls keyring -> SecretStorage -> cryptography on Linux; without
# this pip resolves a cryptography release newer than our registry has a
# riscv64 wheel for and tries (and fails) to build it from source.
CIBW_TEST_ENVIRONMENT: PYTHONIOENCODING=utf-8 PIP_ONLY_BINARY=cryptography
# tests/unit/test_core.py's test_text_reporter_only/test_all_reporters
# run deptry against cwd's own pyproject.toml (mirroring upstream's
# `uv run deptry python` quality-job step), so it has to be staged too.
CIBW_TEST_SOURCES: tests pyproject.toml
CIBW_TEST_REQUIRES: >-
pytest==9.0.2 pytest-cov==7.0.0 "pytest-xdist[psutil]==3.8.0"
inline-snapshot==0.32.5 pdm==2.26.6 poetry==2.3.2 uv
# tests/functional's conftest normally rebuilds its own wheel with `uv
# build` to install into the poetry/pdm/uv/pip venv fixtures; our patch
# points it at the wheel cibuildwheel already built and repaired
# instead of paying for a second from-scratch native Rust compile.
CIBW_TEST_COMMAND: >-
python -c "import deptry.rust as m; assert m.__file__.endswith('.so'), m.__file__" &&
python -m pytest tests/unit -v &&
DEPTRY_PREBUILT_WHEEL={wheel} python -m pytest tests/functional -n auto --dist loadgroup -v

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: deptry-${{ env.DEPTRY_VERSION }}-cp310-abi3-manylinux_riscv64
path: wheelhouse/*.whl
if-no-files-found: error

publish:
name: Publish deptry ${{ inputs.version || '0.25.1' }}
needs: [setup, build_wheels]
permissions:
contents: write
pull-requests: write
uses: $/.github/workflows/_publish-wheel.yml
with:
artifact-pattern: deptry-${{ inputs.version || '0.25.1' }}-*-manylinux_riscv64
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
From 872146c4bced3cb8e45a41d830f5068ca8b1f582 Mon Sep 17 00:00:00 2001
From: Ludovic Henry <git@ludovic.dev>
Date: Thu, 3 Sep 2026 22:38:19 +0200
Subject: [PATCH] tests: allow functional tests to reuse a prebuilt wheel

pytest_sessionstart always runs `uv build --wheel` to produce the wheel the
venv factories install into their poetry/pdm/uv/pip environments. In a
cibuildwheel job the interpreter's own wheel has already been built (and
repaired) once; rebuilding it a second time from scratch to run the
functional suite roughly doubles an already multi-minute native riscv64
Rust compile for no functional benefit; the produced wheel is identical.

DEPTRY_PREBUILT_WHEEL lets the caller point at that already-built wheel and
skip the redundant rebuild; unset, behaviour is unchanged.

Upstream-Status: Inappropriate [avoids a second from-scratch Rust compile inside a cibuildwheel test step; CI-infra only, nothing to fix in the project]
---
tests/functional/conftest.py | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py
index c2f8034..33dac90 100644
--- a/tests/functional/conftest.py
+++ b/tests/functional/conftest.py
@@ -1,6 +1,8 @@
from __future__ import annotations

+import os
import shlex
+import shutil
import subprocess
import sys
from pathlib import Path
@@ -22,6 +24,13 @@ def pytest_sessionstart(session: pytest.Session) -> None:

deptry_wheel_path = Path(DEPTRY_WHEEL_DIRECTORY)

+ prebuilt_wheel = os.environ.get("DEPTRY_PREBUILT_WHEEL")
+ if prebuilt_wheel:
+ print(f"Reusing prebuilt `deptry` wheel {prebuilt_wheel} for functional tests...") # noqa: T201
+ deptry_wheel_path.mkdir(parents=True, exist_ok=True)
+ shutil.copy2(prebuilt_wheel, deptry_wheel_path)
+ return None
+
print(f"Building `deptry` wheel in {deptry_wheel_path} to use it on functional tests...") # noqa: T201

try:
--
2.50.1 (Apple Git-155)

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
From cba283a56f34d6ace2bcad4c3cbcce5791aa6cb3 Mon Sep 17 00:00:00 2001
From: Ludovic Henry <git@ludovic.dev>
Date: Fri, 4 Sep 2026 01:36:29 +0200
Subject: [PATCH] tests: upgrade pip in each throwaway venv before installing
the wheel

VirtualEnvironment.setup creates each poetry/pdm/uv/pip fixture venv with
venv.EnvBuilder(with_pip=True), which provisions whatever pip ensurepip
bundled for that Python build. On the manylinux_riscv64 cibuildwheel image
that bundled pip predates riscv64 wheel-tag support, so `pip install
--no-cache-dir <wheel>` against our own riscv64 wheel fails with "... is
not a supported wheel on this platform" even though the outer test venv's
own (newer) pip installs the identical wheel without complaint moments
earlier.

Upstream-Status: Inappropriate [ensurepip's bundled pip on the manylinux_riscv64 image predates riscv64 wheel-tag support; not reproducible off riscv64]
---
tests/utils.py | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tests/utils.py b/tests/utils.py
index 10b22a0..7320630 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -101,6 +101,8 @@ class VirtualEnvironment:
)
virtual_env.create(self.project_path)

+ self.run("pip install --upgrade pip", check=True)
+
shutil.copytree(deptry_directory / "tests/fixtures" / self.project, self.project_path / "project")

self.run(
--
2.50.1 (Apple Git-155)