Skip to content

Commit 4e98d59

Browse files
authored
Merge pull request #13 from ImagingDataCommons/update-dcmqi-v1.5.2-and-modernize
feat: update dcmqi to v1.5.2, modernize Python support, add auto-update workflow
2 parents a7f847c + f9455c7 commit 4e98d59

6 files changed

Lines changed: 187 additions & 42 deletions

File tree

.github/workflows/cd.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
strategy:
3838
fail-fast: false
3939
matrix:
40-
python: ["3.8", "3.12"]
40+
python: ["3.10", "3.12"]
4141

4242
steps:
4343
- uses: actions/checkout@v4
@@ -92,10 +92,6 @@ jobs:
9292
skip: "*musllinux*"
9393
arch: "x86_64"
9494

95-
- os: windows-latest
96-
arch: "ARM64"
97-
test-skip: "*-win_arm64"
98-
9995
- os: macos-14
10096
arch: "arm64"
10197

@@ -112,8 +108,8 @@ jobs:
112108
env:
113109
CIBW_BUILD: "cp312-*"
114110
CIBW_ARCHS: "${{ matrix.arch }}"
115-
CIBW_TEST_SKIP: "${{ matrix.test-skip }}"
116111
CIBW_SKIP: ${{ matrix.skip }}
112+
CIBW_ENVIRONMENT_MACOS: "MACOSX_DEPLOYMENT_TARGET=13.0"
117113

118114
- name: Upload wheels
119115
uses: actions/upload-artifact@v4

.github/workflows/ci.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,13 @@ jobs:
4040
strategy:
4141
fail-fast: false
4242
matrix:
43-
python-version: ["3.8", "3.12"]
43+
python-version: ["3.10", "3.12"]
4444
runs-on: [ubuntu-latest, macos-latest, windows-latest]
4545

4646
include:
4747
- python-version: pypy-3.10
4848
runs-on: ubuntu-latest
4949

50-
- python-version: "3.10"
51-
runs-on: macos-latest
52-
53-
exclude:
54-
- python-version: "3.8"
55-
runs-on: macos-latest
56-
5750
steps:
5851
- uses: actions/checkout@v4
5952
with:
@@ -91,11 +84,6 @@ jobs:
9184
python-version: cp312
9285
arch: "arm64"
9386

94-
- runs-on: windows-latest
95-
python-version: cp312
96-
arch: "ARM64"
97-
test-skip: "*-win_arm64"
98-
9987
steps:
10088
- uses: actions/checkout@v4
10189
with:
@@ -105,5 +93,5 @@ jobs:
10593
env:
10694
CIBW_BUILD: "${{ matrix.python-version }}-*"
10795
CIBW_ARCHS: "${{ matrix.arch }}"
108-
CIBW_TEST_SKIP: "${{ matrix.test-skip }}"
10996
CIBW_SKIP: "*musllinux*"
97+
CIBW_ENVIRONMENT_MACOS: "MACOSX_DEPLOYMENT_TARGET=13.0"

.github/workflows/update-dcmqi.yml

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
name: Update dcmqi
2+
3+
on:
4+
schedule:
5+
- cron: "0 9 * * 1" # Every Monday at 9am UTC
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
check-update:
14+
name: Check for new dcmqi release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Check for update and open PR
20+
env:
21+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
run: |
23+
set -euo pipefail
24+
25+
# Get current version from dcmqiUrls.cmake
26+
current_version=$(grep 'set(version' dcmqiUrls.cmake | sed 's/set(version "\(.*\)")/\1/')
27+
echo "Current version: $current_version"
28+
29+
# Get latest upstream release (skip drafts and prereleases)
30+
latest_tag=$(gh api repos/QIICR/dcmqi/releases/latest --jq '.tag_name')
31+
latest_version="${latest_tag#v}"
32+
echo "Latest upstream version: $latest_version"
33+
34+
if [ "$current_version" = "$latest_version" ]; then
35+
echo "Already up-to-date at v$current_version"
36+
exit 0
37+
fi
38+
39+
echo "Update available: v$current_version -> v$latest_version"
40+
41+
# Check if a PR already exists for this version
42+
existing_pr=$(gh pr list --search "dcmqi v$latest_version" --json number --jq '.[0].number // empty')
43+
if [ -n "$existing_pr" ]; then
44+
echo "PR #$existing_pr already exists for v$latest_version"
45+
exit 0
46+
fi
47+
48+
# Get asset list
49+
assets=$(gh api "repos/QIICR/dcmqi/releases/tags/$latest_tag" --jq '.assets[].name')
50+
echo "Assets: $assets"
51+
52+
# Download assets and compute checksums
53+
declare -A checksums
54+
for asset in $assets; do
55+
echo "Downloading $asset..."
56+
url="https://github.com/QIICR/dcmqi/releases/download/$latest_tag/$asset"
57+
sha256=$(curl -sL "$url" | sha256sum | awk '{print $1}')
58+
checksums["$asset"]="$sha256"
59+
echo " SHA256: $sha256"
60+
done
61+
62+
# Determine macOS asset pattern
63+
has_mac_split=false
64+
for asset in $assets; do
65+
case "$asset" in
66+
*-mac-arm64*) has_mac_split=true ;;
67+
esac
68+
done
69+
70+
# Generate dcmqiUrls.cmake
71+
{
72+
echo '# Checksums computed from assets associated with the dcmqi GitHub release'
73+
echo ''
74+
echo "set(version \"$latest_version\")"
75+
echo ''
76+
77+
# Linux
78+
linux_file="dcmqi-${latest_version}-linux.tar.gz"
79+
echo "set(linux_filename \"$linux_file\")"
80+
echo "set(linux_sha256 \"${checksums[$linux_file]}\")"
81+
echo ''
82+
83+
# macOS
84+
if [ "$has_mac_split" = true ]; then
85+
mac_arm64_file="dcmqi-${latest_version}-mac-arm64.tar.gz"
86+
mac_x86_64_file="dcmqi-${latest_version}-mac-x86_64.tar.gz"
87+
echo "set(macos_arm64_filename \"$mac_arm64_file\")"
88+
echo "set(macos_arm64_sha256 \"${checksums[$mac_arm64_file]}\")"
89+
echo ''
90+
echo "set(macos_x86_64_filename \"$mac_x86_64_file\")"
91+
echo "set(macos_x86_64_sha256 \"${checksums[$mac_x86_64_file]}\")"
92+
else
93+
mac_file="dcmqi-${latest_version}-mac.tar.gz"
94+
echo "set(macos_filename \"$mac_file\")"
95+
echo "set(macos_sha256 \"${checksums[$mac_file]}\")"
96+
fi
97+
echo ''
98+
99+
# Windows
100+
win_file="dcmqi-${latest_version}-win64.zip"
101+
echo "set(win64_filename \"$win_file\")"
102+
echo "set(win64_sha256 \"${checksums[$win_file]}\")"
103+
echo ''
104+
echo ''
105+
106+
# Platform detection
107+
echo 'cmake_host_system_information(RESULT is_64bit QUERY IS_64BIT)'
108+
echo ''
109+
echo 'set(archive "linux")'
110+
echo ''
111+
echo 'if(APPLE)'
112+
if [ "$has_mac_split" = true ]; then
113+
echo ' if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")'
114+
echo ' set(archive "macos_arm64")'
115+
echo ' else()'
116+
echo ' set(archive "macos_x86_64")'
117+
echo ' endif()'
118+
else
119+
echo ' set(archive "macos")'
120+
fi
121+
echo 'endif()'
122+
echo ''
123+
echo 'if(WIN32)'
124+
echo ' if(is_64bit AND NOT (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ARM64"))'
125+
echo ' set(archive "win64")'
126+
echo ' endif()'
127+
echo 'endif()'
128+
echo ''
129+
echo 'if(NOT DEFINED "${archive}_filename")'
130+
echo ' message(FATAL_ERROR "Failed to determine which archive to download: '"'"'${archive}_filename'"'"' variable is not defined")'
131+
echo 'endif()'
132+
echo ''
133+
echo 'if(NOT DEFINED "${archive}_sha256")'
134+
echo ' message(FATAL_ERROR "Could you make sure variable '"'"'${archive}_sha256'"'"' is defined ?")'
135+
echo 'endif()'
136+
echo ''
137+
echo 'set(dcmqi_archive_filename "${${archive}_filename}")'
138+
echo 'set(dcmqi_archive_sha256 "${${archive}_sha256}")'
139+
echo ''
140+
echo 'set(dcmqi_archive_url "https://github.com/QIICR/dcmqi/releases/download/v${version}/${dcmqi_archive_filename}")'
141+
} > dcmqiUrls.cmake
142+
143+
# Configure git and create branch
144+
git config user.name "github-actions[bot]"
145+
git config user.email "github-actions[bot]@users.noreply.github.com"
146+
147+
branch="dcmqi-v${latest_version}"
148+
git checkout -b "$branch"
149+
git add dcmqiUrls.cmake
150+
git commit -m "feat: update dcmqi from version v$current_version to v$latest_version"
151+
git push origin "$branch"
152+
153+
gh pr create \
154+
--title "feat: update dcmqi from v$current_version to v$latest_version" \
155+
--body "## Summary
156+
- Updates packaged dcmqi binaries from v$current_version to v$latest_version
157+
- SHA256 checksums computed from downloaded release assets
158+
159+
**Upstream release:** https://github.com/QIICR/dcmqi/releases/tag/$latest_tag
160+
161+
---
162+
*This PR was automatically created by the update-dcmqi workflow.*"

dcmqiUrls.cmake

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1-
# Checksum copied from "dcmqi_checksums.txt" associated with the dcmqi GitHub release
1+
# Checksums computed from assets associated with the dcmqi GitHub release
22

3-
set(version "1.3.4")
3+
set(version "1.5.2")
44

5-
set(linux_filename "dcmqi-${version}-linux.tar.gz")
6-
set(linux_sha256 "4b9ecc27bde8befd35c0b95449744c3a3b43466592a7211e8f5adbfe9e497608")
5+
set(linux_filename "dcmqi-${version}-linux.tar.gz")
6+
set(linux_sha256 "09e59dac5d11941e3d49298cc43e91763763badf750c56bd8f3c185021f5f757")
77

8-
set(macos_filename "dcmqi-${version}-mac.tar.gz")
9-
set(macos_sha256 "691cc64815016b76665c798713dee38447ec8acf9a6f059db5e78415a902c4b0")
8+
set(macos_arm64_filename "dcmqi-${version}-mac-arm64.tar.gz")
9+
set(macos_arm64_sha256 "feab6633536dd506cb5d806118595dad3d73991965b5e0929aa35c58c973f919")
1010

11-
set(win64_filename "dcmqi-${version}-win64.zip")
12-
set(win64_sha256 "f9d5ec1bf9e5b0ba4e2cddabfa8d773afee167a48f71a48ec61549a6dcba06bd")
11+
set(macos_x86_64_filename "dcmqi-${version}-mac-x86_64.tar.gz")
12+
set(macos_x86_64_sha256 "8de7d962644b28366589ffbf487649a9d3532e109cf6853f5af51d4c97f0b7bf")
13+
14+
set(win64_filename "dcmqi-${version}-win64.zip")
15+
set(win64_sha256 "6a8798c9201a99afe6cdafd5eeb89c40d3436f40d66f8ecaabe45d9294aecfd4")
1316

1417

1518
cmake_host_system_information(RESULT is_64bit QUERY IS_64BIT)
1619

1720
set(archive "linux")
1821

1922
if(APPLE)
20-
set(archive "macos")
23+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
24+
set(archive "macos_arm64")
25+
else()
26+
set(archive "macos_x86_64")
27+
endif()
2128
endif()
2229

2330
if(WIN32)

pyproject.toml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@ authors = [
1111
description = "Python distribution of the DCMQI library collection."
1212
readme = "README.md"
1313
license.file = "LICENSE"
14-
requires-python = ">=3.8"
14+
requires-python = ">=3.10"
1515
classifiers = [
16-
"Development Status :: 1 - Planning",
16+
"Development Status :: 4 - Beta",
1717
"Intended Audience :: Science/Research",
1818
"Intended Audience :: Developers",
1919
"License :: OSI Approved :: MIT License",
2020
"Operating System :: OS Independent",
2121
"Programming Language :: Python",
2222
"Programming Language :: Python :: 3",
2323
"Programming Language :: Python :: 3 :: Only",
24-
"Programming Language :: Python :: 3.8",
25-
"Programming Language :: Python :: 3.9",
2624
"Programming Language :: Python :: 3.10",
2725
"Programming Language :: Python :: 3.11",
2826
"Programming Language :: Python :: 3.12",
@@ -34,7 +32,6 @@ dependencies = []
3432

3533
[project.optional-dependencies]
3634
test = [
37-
"importlib_metadata>=2.0; python_version<'3.10'",
3835
"pytest >=6",
3936
"pytest-cov >=3",
4037
]
@@ -104,7 +101,7 @@ report.exclude_also = [
104101

105102
[tool.mypy]
106103
files = ["src", "tests"]
107-
python_version = "3.8"
104+
python_version = "3.10"
108105
warn_unused_configs = true
109106
strict = true
110107
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
@@ -163,7 +160,7 @@ isort.required-imports = ["from __future__ import annotations"]
163160

164161

165162
[tool.pylint]
166-
py-version = "3.8"
163+
py-version = "3.10"
167164
ignore-paths = [".*/_version.py"]
168165
extension-pkg-allow-list = []
169166
reports.output-format = "colorized"

tests/test_executable.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
from __future__ import annotations
22

33
import subprocess
4-
import sys
54
import sysconfig
5+
from importlib.metadata import distribution
66
from pathlib import Path
77

88
import pytest
99

10-
if sys.version_info < (3, 10):
11-
from importlib_metadata import distribution
12-
else:
13-
from importlib.metadata import distribution
14-
1510
import dcmqi
1611

1712
from . import push_argv

0 commit comments

Comments
 (0)