From cbb135e13e2928fa0d990bc4bb1ff3b21a3d2205 Mon Sep 17 00:00:00 2001 From: Wim Pomp Date: Wed, 30 Apr 2025 12:52:12 +0200 Subject: [PATCH] also publish on pypi --- .github/workflows/publish.yml | 117 ++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- py/ome_metadata/__init__.py | 5 +- src/ome.rs | 1 + 4 files changed, 122 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 18d0e47..fa3a981 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,6 +6,123 @@ permissions: contents: read jobs: + linux: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: ubuntu-latest + target: x86_64 + - runner: ubuntu-latest + target: x86 + - runner: ubuntu-latest + target: aarch64 + - runner: ubuntu-latest + target: armv7 + - runner: ubuntu-latest + target: s390x + - runner: ubuntu-latest + target: ppc64le + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: 'true' + manylinux: auto + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-linux-${{ matrix.platform.target }} + path: dist + + windows: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: windows-latest + target: x64 + # - runner: windows-latest + # target: x86 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + architecture: ${{ matrix.platform.target }} + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-windows-${{ matrix.platform.target }} + path: dist + + macos: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: macos-latest + target: x86_64 + - runner: macos-14 + target: aarch64 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-macos-${{ matrix.platform.target }} + path: dist + + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: Upload sdist + uses: actions/upload-artifact@v4 + with: + name: wheels-sdist + path: dist + + release: + name: Release + runs-on: ubuntu-latest + needs: [linux, windows, macos, sdist] + steps: + - uses: actions/download-artifact@v4 + - name: Publish to PyPI + uses: PyO3/maturin-action@v1 + env: + MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + with: + command: upload + args: --non-interactive --skip-existing wheels-*/* + crates_io_publish: name: Publish (crates.io) runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index 66f3278..40939a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ome-metadata" -version = "0.2.0" +version = "0.2.1" edition = "2024" rust-version = "1.85.1" authors = ["Wim Pomp "] diff --git a/py/ome_metadata/__init__.py b/py/ome_metadata/__init__.py index 6025a15..d96f131 100644 --- a/py/ome_metadata/__init__.py +++ b/py/ome_metadata/__init__.py @@ -1,9 +1,10 @@ from __future__ import annotations +from collections import UserDict, UserList from . import ome_metadata_rs as rs # noqa -class Ome(dict): +class Ome(UserDict): @staticmethod def from_xml(xml: str) -> Ome: """Create the OME structure from an XML string""" @@ -27,7 +28,7 @@ class Ome(dict): return new -class OmeList(list): +class OmeList(UserList): def __getitem__(self, item: int) -> Ome | OmeList | int | float | str: new = super().__getitem__(item) if isinstance(new, dict): diff --git a/src/ome.rs b/src/ome.rs index fd0b458..2d5edcf 100644 --- a/src/ome.rs +++ b/src/ome.rs @@ -2778,6 +2778,7 @@ macro_rules! impl_enum_variants { ($($t:ty $(,)?)*) => { $( impl $t { + /// all possible variants of this enum that can be constructed or converted into pub fn variants() -> Vec { Self::iter().collect::>() }