Skip to content

Commit 6c9d344

Browse files
beoinformaticseckartuetedil
authored
feat(repo, grz-check) V2: Build and publish grz-check as pyproject as well (#543)
## Summary - Package `grz-check` as a Python extension via maturin (PyO3/Bound API). - Add streaming interfaces for FASTQ and BAM checks. - Unify path-based and stream-based APIs into a single set of functions. - CI: workflow to build and publish maturin wheels (pinned action hash). - Tests: 11 Python binding tests (path/stream parity, gzip streams, input validation). This PR supercedes PR #509: feat(repo, grz-check) : Build and publish grz-check as pyproject as well Closes #509 --------- Co-authored-by: Eckart Bindewald <eckart.bindewald@uni-tuebingen.de> Co-authored-by: Till Hartmann <till.hartmann@bih-charite.de>
1 parent 03f2e0d commit 6c9d344

14 files changed

Lines changed: 1435 additions & 103 deletions

File tree

.github/workflows/pypi-rust.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Publish Rust Package to PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- 'grz-check-v[0-9]+.[0-9]+.[0-9]+*'
8+
9+
jobs:
10+
linux:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
target: [x86_64, aarch64]
15+
steps:
16+
# actions/checkout v6.0.2
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
18+
# actions/setup-python v6.2.0
19+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
20+
with:
21+
python-version: '3.12'
22+
- name: Build wheels
23+
# PyO3/maturin-action v1.51.0
24+
uses: PyO3/maturin-action@3e2bdf6ba6453a61e649744019b8a2d906c7eb38
25+
with:
26+
target: ${{ matrix.target }}
27+
args: --release --out dist --find-interpreter
28+
sccache: 'true'
29+
manylinux: auto
30+
working-directory: packages/grz-check
31+
- name: Upload wheels
32+
# actions/upload-artifact v7.0.1
33+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
34+
with:
35+
name: wheels-linux-${{ matrix.target }}
36+
path: dist
37+
38+
sdist:
39+
runs-on: ubuntu-latest
40+
steps:
41+
# actions/checkout v6.0.2
42+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
43+
- name: Build sdist
44+
# PyO3/maturin-action v1.51.0
45+
uses: PyO3/maturin-action@3e2bdf6ba6453a61e649744019b8a2d906c7eb38
46+
with:
47+
command: sdist
48+
args: --out dist
49+
working-directory: packages/grz-check
50+
- name: Upload sdist
51+
# actions/upload-artifact v7.0.1
52+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
53+
with:
54+
name: wheels-sdist
55+
path: dist
56+
57+
release:
58+
name: Release to PyPI
59+
runs-on: ubuntu-latest
60+
needs: [linux, sdist]
61+
environment:
62+
name: pypi
63+
url: https://pypi.org/p/grz-check
64+
permissions:
65+
id-token: write
66+
contents: read
67+
steps:
68+
# actions/download-artifact v8.0.1
69+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
70+
with:
71+
pattern: wheels-*
72+
path: dist
73+
merge-multiple: true
74+
- name: Publish to PyPI
75+
# pypa/gh-action-pypi-publish release/v1
76+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
77+
with:
78+
packages-dir: dist

packages/grz-check/Cargo.lock

Lines changed: 106 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/grz-check/Cargo.toml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,32 @@ repository = "https://github.com/BfArM-MVH/grz-tools"
1010
readme = "README.md"
1111
categories = ["command-line-utilities"]
1212

13+
[lib]
14+
name = "grz_check"
15+
crate-type = ["cdylib"]
16+
17+
[[bin]]
18+
name = "grz-check"
19+
path = "src/main.rs"
20+
1321
[dependencies]
1422
anyhow = "1.0.98"
15-
clap = { version = "4.5.40", features = ["derive"] }
23+
clap = { version = "4.5.40", features = ["derive"], optional = true }
1624
noodles = { version = "0.100.0", features = ["sam", "bam", "fastq", "bgzf"] }
1725
niffler = "3.0.0"
18-
rayon = "1.10.0"
26+
rayon = { version = "1.10.0", optional = true }
1927
indicatif = { version = "0.18.0", features = ["rayon", "improved_unicode"] }
2028
serde = { version = "1.0.219", features = ["derive"] }
2129
sha2 = "0.10.9"
2230
serde_json = "1.0.140"
2331
itertools = "0.14.0"
24-
ctrlc = "3.4.7"
32+
ctrlc = { version = "3.4.7", optional = true }
33+
pyo3 = { version = "0.23", features = ["extension-module"], optional = true }
34+
35+
[features]
36+
default = ["cli"]
37+
cli = ["clap", "rayon", "ctrlc"]
38+
python = ["pyo3"]
2539

2640
[dev-dependencies]
2741
tempfile = "3.20"

packages/grz-check/pyproject.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[build-system]
2+
requires = ["maturin>=1.0,<2.0"]
3+
build-backend = "maturin"
4+
5+
[project]
6+
name = "grz-check"
7+
version = "0.2.1"
8+
description = "Fast validation of sequencing files (FASTQ, BAM) powered by Rust"
9+
readme = "README.md"
10+
requires-python = ">=3.12"
11+
classifiers = [
12+
"Programming Language :: Python :: 3",
13+
"Programming Language :: Rust",
14+
]
15+
16+
[project.optional-dependencies]
17+
dev = ["pytest", "maturin"]
18+
19+
[dependency-groups]
20+
test = ["pytest >=8,<9"]
21+
dev = ["tox >=4.23", "tox-uv"]
22+
23+
[tool.maturin]
24+
features = ["python"]
25+
python-source = "python"
26+
module-name = "grz_check"
27+
28+
[tool.tox]
29+
requires = ["tox>=4.23", "tox-uv"]
30+
env_list = ["3.12", "3.13"]
31+
32+
[tool.tox.env_run_base]
33+
runner = "uv-venv-lock-runner"
34+
dependency_groups = ["test"]
35+
commands = [["pytest", { replace = "posargs", default = ["tests"], extend = true }]]

0 commit comments

Comments
 (0)