- use color-eyre
This commit is contained in:
4
.github/workflows/publish.yml
vendored
4
.github/workflows/publish.yml
vendored
@@ -52,8 +52,8 @@ jobs:
|
||||
platform:
|
||||
- runner: windows-latest
|
||||
target: x64
|
||||
# - runner: windows-latest
|
||||
# target: x86
|
||||
# - runner: windows-11-arm
|
||||
# target: aarch64
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-python@v6
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tiffwrite"
|
||||
version = "2025.12.0"
|
||||
version = "2026.1.1"
|
||||
edition = "2024"
|
||||
rust-version = "1.85.1"
|
||||
authors = ["Wim Pomp <w.pomp@nki.nl>"]
|
||||
@@ -20,6 +20,7 @@ crate-type = ["cdylib", "rlib"]
|
||||
[dependencies]
|
||||
colorcet = "0.2"
|
||||
colorgrad = "0.8"
|
||||
color-eyre = { version = "0.6", optional = true }
|
||||
chrono = "0.4"
|
||||
css-color = "0.2"
|
||||
flate2 = "1"
|
||||
@@ -32,8 +33,8 @@ zstd = "0.13"
|
||||
|
||||
[dependencies.pyo3]
|
||||
version = "0.27"
|
||||
features = ["extension-module", "abi3-py310", "generate-import-lib", "anyhow", "multiple-pymethods"]
|
||||
features = ["extension-module", "abi3-py310", "eyre", "generate-import-lib", "multiple-pymethods"]
|
||||
optional = true
|
||||
|
||||
[features]
|
||||
python = ["dep:pyo3", "dep:numpy"]
|
||||
python = ["dep:pyo3", "dep:numpy", "dep:color-eyre"]
|
||||
|
||||
@@ -135,8 +135,8 @@ impl Tag {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn byte(code: u16, value: &Vec<u8>) -> Self {
|
||||
Tag::new(code, value.to_owned(), 1)
|
||||
pub fn byte(code: u16, value: &[u8]) -> Self {
|
||||
Tag::new(code, value.to_vec(), 1)
|
||||
}
|
||||
|
||||
pub fn ascii(code: u16, value: &str) -> Self {
|
||||
|
||||
29
src/py.rs
29
src/py.rs
@@ -6,7 +6,7 @@ use pyo3::prelude::*;
|
||||
|
||||
impl From<crate::error::Error> for PyErr {
|
||||
fn from(err: crate::error::Error) -> PyErr {
|
||||
PyErr::new::<PyValueError, _>(err.to_string())
|
||||
color_eyre::eyre::Report::from(err).into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +333,8 @@ impl PyIJTiffFile {
|
||||
}
|
||||
|
||||
macro_rules! impl_save {
|
||||
($T:ty, $t:ident) => {
|
||||
($($T:ty: $t:ident $(,)?)*) => {
|
||||
$(
|
||||
#[pymethods]
|
||||
impl PyIJTiffFile {
|
||||
fn $t(
|
||||
@@ -349,23 +350,27 @@ macro_rules! impl_save {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
impl_save!(u8, save_u8);
|
||||
impl_save!(u16, save_u16);
|
||||
impl_save!(u32, save_u32);
|
||||
impl_save!(u64, save_u64);
|
||||
impl_save!(i8, save_i8);
|
||||
impl_save!(i16, save_i16);
|
||||
impl_save!(i32, save_i32);
|
||||
impl_save!(i64, save_i64);
|
||||
impl_save!(f32, save_f32);
|
||||
impl_save!(f64, save_f64);
|
||||
impl_save! {
|
||||
u8: save_u8,
|
||||
u16: save_u16,
|
||||
u32: save_u32,
|
||||
u64: save_u64,
|
||||
i8: save_i8,
|
||||
i16: save_i16,
|
||||
i32: save_i32,
|
||||
i64: save_i64,
|
||||
f32: save_f32,
|
||||
f64: save_f64,
|
||||
}
|
||||
|
||||
#[pymodule]
|
||||
#[pyo3(name = "tiffwrite_rs")]
|
||||
fn tiffwrite_rs(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
||||
color_eyre::install()?;
|
||||
m.add_class::<PyTag>()?;
|
||||
m.add_class::<PyIJTiffFile>()?;
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user