diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml new file mode 100644 index 0000000..bee2c6f --- /dev/null +++ b/.github/workflows/test-python.yml @@ -0,0 +1,74 @@ +name: Test Python + +on: + push: + branches: + - main + pull_request: + +jobs: + lint-test: + name: Lint and Test + runs-on: ubuntu-latest + defaults: + run: + working-directory: python + steps: + - uses: actions/checkout@v3 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + + - uses: Swatinem/rust-cache@v2 + + - name: Cargo fmt + run: cargo fmt --all -- --check + + - name: "clippy --all" + run: cargo clippy --all --all-features --tests -- -D warnings + + - name: "cargo check" + run: cargo check --all --all-features + + - name: "cargo test" + run: | + cargo test --all + cargo test --all --all-features + + pytest: + name: Pytest + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + + - uses: Swatinem/rust-cache@v2 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install a specific version of uv + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + version: "0.5.x" + + - name: uv sync + working-directory: python + run: uv sync --no-install-package geoindex-rs + + - name: maturin venv Build + working-directory: python + run: uv run --no-project maturin develop + + # - name: Run pytest + # working-directory: python + # run: uv run --no-project pytest diff --git a/python/Cargo.toml b/python/Cargo.toml index 56b40c9..cad90e2 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -26,7 +26,6 @@ pyo3-async-runtimes = "0.23" pyo3-bytes = "0.1.2" pyo3-object_store = { git = "https://github.com/developmentseed/obstore", rev = "28ba07a621c1c104f084fb47ae7f8d08b1eae3ea" } thiserror = "1" -tiff = "0.9.1" # We opt-in to using rustls as the TLS provider for reqwest, which is the HTTP # library used by object_store. diff --git a/python/python/async_tiff/_ifd.pyi b/python/python/async_tiff/_ifd.pyi index dd62f88..2a9f9ca 100644 --- a/python/python/async_tiff/_ifd.pyi +++ b/python/python/async_tiff/_ifd.pyi @@ -75,15 +75,15 @@ class ImageFileDirectory: @property def predictor(self) -> Predictor | None: ... @property - def tile_width(self) -> int: ... + def tile_width(self) -> int | None: ... @property - def tile_height(self) -> int: ... + def tile_height(self) -> int | None: ... @property - def tile_offsets(self) -> list[int]: ... + def tile_offsets(self) -> list[int] | None: ... @property - def tile_byte_counts(self) -> list[int]: ... + def tile_byte_counts(self) -> list[int] | None: ... @property - def extra_samples(self) -> bytes | None: ... + def extra_samples(self) -> list[int] | None: ... @property def sample_format(self) -> list[SampleFormat]: ... @property diff --git a/python/src/decoder.rs b/python/src/decoder.rs index 63146b1..56bc8ed 100644 --- a/python/src/decoder.rs +++ b/python/src/decoder.rs @@ -1,5 +1,6 @@ use async_tiff::decoder::{Decoder, DecoderRegistry}; use async_tiff::error::AiocogeoError; +use async_tiff::tiff::tags::PhotometricInterpretation; use bytes::Bytes; use pyo3::exceptions::PyTypeError; use pyo3::intern; @@ -53,7 +54,7 @@ impl Decoder for PyDecoder { fn decode_tile( &self, buffer: bytes::Bytes, - _photometric_interpretation: tiff::tags::PhotometricInterpretation, + _photometric_interpretation: PhotometricInterpretation, _jpeg_tables: Option<&[u8]>, ) -> async_tiff::error::Result { let decoded_buffer = Python::with_gil(|py| self.call(py, buffer)) diff --git a/python/src/enums.rs b/python/src/enums.rs index 90f8afe..91baa90 100644 --- a/python/src/enums.rs +++ b/python/src/enums.rs @@ -1,10 +1,10 @@ -use pyo3::intern; -use pyo3::prelude::*; -use pyo3::types::{PyString, PyTuple}; -use tiff::tags::{ +use async_tiff::tiff::tags::{ CompressionMethod, PhotometricInterpretation, PlanarConfiguration, Predictor, ResolutionUnit, SampleFormat, }; +use pyo3::intern; +use pyo3::prelude::*; +use pyo3::types::{PyString, PyTuple}; pub(crate) struct PyCompressionMethod(CompressionMethod); diff --git a/python/src/ifd.rs b/python/src/ifd.rs index b4f3d1f..009c9ce 100644 --- a/python/src/ifd.rs +++ b/python/src/ifd.rs @@ -55,7 +55,7 @@ impl PyImageFileDirectory { } #[getter] - pub fn strip_offsets(&self) -> Option<&[u32]> { + pub fn strip_offsets(&self) -> Option<&[u64]> { self.0.strip_offsets() } @@ -80,7 +80,7 @@ impl PyImageFileDirectory { } #[getter] - pub fn strip_byte_counts(&self) -> Option<&[u32]> { + pub fn strip_byte_counts(&self) -> Option<&[u64]> { self.0.strip_byte_counts() } @@ -162,25 +162,25 @@ impl PyImageFileDirectory { } #[getter] - pub fn tile_width(&self) -> u32 { + pub fn tile_width(&self) -> Option { self.0.tile_width() } #[getter] - pub fn tile_height(&self) -> u32 { + pub fn tile_height(&self) -> Option { self.0.tile_height() } #[getter] - pub fn tile_offsets(&self) -> &[u32] { + pub fn tile_offsets(&self) -> Option<&[u64]> { self.0.tile_offsets() } #[getter] - pub fn tile_byte_counts(&self) -> &[u32] { + pub fn tile_byte_counts(&self) -> Option<&[u64]> { self.0.tile_byte_counts() } #[getter] - pub fn extra_samples(&self) -> Option<&[u8]> { + pub fn extra_samples(&self) -> Option<&[u16]> { self.0.extra_samples() }