diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fa3a981..6293e02 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,10 +24,10 @@ jobs: - runner: ubuntu-latest target: ppc64le steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 with: - python-version: '3.10' + python-version: '3.12' - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -36,7 +36,7 @@ jobs: sccache: 'true' manylinux: auto - name: Upload wheels - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: wheels-linux-${{ matrix.platform.target }} path: dist @@ -48,13 +48,13 @@ jobs: platform: - runner: windows-latest target: x64 - # - runner: windows-latest - # target: x86 + - runner: windows-11-arm + target: aarch64 steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 with: - python-version: '3.10' + python-version: '3.12' architecture: ${{ matrix.platform.target }} - name: Build wheels uses: PyO3/maturin-action@v1 @@ -63,7 +63,7 @@ jobs: args: --release --out dist sccache: 'true' - name: Upload wheels - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: wheels-windows-${{ matrix.platform.target }} path: dist @@ -78,10 +78,10 @@ jobs: - runner: macos-14 target: aarch64 steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 with: - python-version: '3.10' + python-version: '3.12' - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -89,7 +89,7 @@ jobs: args: --release --out dist sccache: 'true' - name: Upload wheels - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: wheels-macos-${{ matrix.platform.target }} path: dist @@ -97,14 +97,14 @@ jobs: sdist: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Build sdist uses: PyO3/maturin-action@v1 with: command: sdist args: --out dist - name: Upload sdist - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: wheels-sdist path: dist @@ -114,7 +114,7 @@ jobs: runs-on: ubuntu-latest needs: [linux, windows, macos, sdist] steps: - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v7 - name: Publish to PyPI uses: PyO3/maturin-action@v1 env: @@ -128,12 +128,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 25 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - uses: dtolnay/rust-toolchain@stable - name: cargo-release Cache id: cargo_release_cache - uses: actions/cache@v3 + uses: actions/cache@v5 with: path: ~/.cargo/bin/cargo-release key: ${{ runner.os }}-cargo-release diff --git a/.gitignore b/.gitignore index cec2916..a878be3 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,4 @@ docs/_build/ # Pyenv .python-version /Cargo.lock +/tests/om/ diff --git a/Cargo.toml b/Cargo.toml index 32b8650..1d09f5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ome-metadata" -version = "0.3.1" +version = "0.3.2" edition = "2024" rust-version = "1.85.1" authors = ["Wim Pomp "] @@ -8,6 +8,7 @@ license = "MIT" description = "Ome metadata as a rust/python structure." homepage = "https://github.com/wimpomp/ome-metadata" repository = "https://github.com/wimpomp/ome-metadata" +documentation = "https://docs.rs/ome-metadata" readme = "README.md" keywords = ["bioformats", "imread", "ome", "metadata"] categories = ["multimedia::images", "science"] @@ -19,13 +20,13 @@ name = "ome_metadata" crate-type = ["cdylib", "rlib"] [dependencies] -enum-utils = "0.1.2" -serde = { version = "1.0.219", features = ["derive"] } -thiserror = "2.0.16" -quick-xml = { version = "0.38.0", features = ["serialize"] } +enum-utils = "0.1" +serde = { version = "1", features = ["derive"] } +thiserror = "2" +quick-xml = { version = "0.38", features = ["serialize"] } [dependencies.pyo3] -version = "0.24.2" +version = "0.27" features = ["extension-module", "abi3-py310", "generate-import-lib", "anyhow"] optional = true diff --git a/src/error.rs b/src/error.rs index afb4e06..ff2e755 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,12 +1,11 @@ -use quick_xml::DeError; use thiserror::Error; #[derive(Debug, Error)] pub enum Error { - #[error("io error: {0}")] + #[error(transparent)] IO(#[from] std::io::Error), - #[error("serde error: {0}")] - SerdeXml(#[from] DeError), + #[error(transparent)] + SerdeXml(#[from] quick_xml::DeError), #[error("size of {0} is unknown")] SizeOfUnknown(String), #[error("no conversion to K by multiplication only")] diff --git a/src/ome.rs b/src/ome.rs index 9b06675..3a19323 100644 --- a/src/ome.rs +++ b/src/ome.rs @@ -1817,7 +1817,7 @@ pub struct Pixels { #[serde(rename = "BinData")] pub bin_data: Option, #[serde(rename = "TiffData")] - pub tiff_data: Option, + pub tiff_data: Vec, #[serde(rename = "MetadataOnly")] pub metadata_only: Option, #[serde(rename = "Plane")] diff --git a/src/py.rs b/src/py.rs index ac443ad..c2036cb 100644 --- a/src/py.rs +++ b/src/py.rs @@ -6,14 +6,12 @@ use crate::ome::{ use pyo3::exceptions::PyValueError; use pyo3::prelude::*; - impl From for PyErr { fn from(err: crate::error::Error) -> PyErr { PyErr::new::(err.to_string()) } } - macro_rules! impl_enum_into_py_object { ($($s:ident: $t:ty $(,)?)*) => { $( @@ -81,6 +79,11 @@ impl_enum_into_py_object! { Time: UnitsTime } +#[pyfunction] +fn ome(text: &str) -> PyResult { + Ok(text.parse()?) +} + #[pymodule] #[pyo3(name = "ome_metadata_rs")] fn ome_metadata_rs(m: &Bound<'_, PyModule>) -> PyResult<()> { @@ -91,11 +94,6 @@ fn ome_metadata_rs(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::