Skip to content

Commit 3c7bcdf

Browse files
committed
Init Python bindings
1 parent 30990ce commit 3c7bcdf

File tree

9 files changed

+123
-2
lines changed

9 files changed

+123
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[package]
2+
name = "async-tiff"
3+
version = "0.1.0-beta.1"
4+
authors = ["Kyle Barron <[email protected]>"]
5+
edition = "2021"
6+
# description = "Fast, memory-efficient 2D spatial indexes for Python."
7+
readme = "README.md"
8+
repository = "https://github.com/developmentseed/async-tiff"
9+
license = "MIT OR Apache-2.0"
10+
keywords = ["python", "geospatial"]
11+
categories = ["science::geo"]
12+
rust-version = "1.75"
13+
14+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
15+
[lib]
16+
name = "_async_tiff"
17+
crate-type = ["cdylib"]
18+
19+
[dependencies]
20+
async-tiff = { path = "../" }
21+
bytes = "1.8"
22+
pyo3 = { version = "0.23.0", features = ["macros"] }
23+
pyo3-bytes = "0.1.2"
24+
thiserror = "1"
25+
26+
[profile.release]
27+
lto = true
28+
codegen-units = 1

python/python/async_tiff/DEVELOP.md

Whitespace-only changes.

python/python/async_tiff/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# async-tiff
2+
3+
<!-- [![PyPI][pypi_badge]][pypi_link]
4+
5+
[pypi_badge]: https://badge.fury.io/py/geoindex-rs.svg
6+
[pypi_link]: https://pypi.org/project/geoindex-rs/ -->
7+
8+
Fast, async TIFF and GeoTIFF reader for Python.
9+
10+
<!-- This documentation is for the Python bindings. [Refer here for the Rust crate documentation](https://docs.rs/geo-index). -->
11+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from ._async_tiff import ___version
2+
3+
__version__: str = ___version()

python/python/async_tiff/_async_tiff.pyi

Whitespace-only changes.

python/python/async_tiff/py.typed

Whitespace-only changes.
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.4.0,<2.0"]
3+
build-backend = "maturin"
4+
5+
[project]
6+
name = "async-tiff"
7+
requires-python = ">=3.9"
8+
dependencies = []
9+
dynamic = ["version"]
10+
classifiers = [
11+
"Programming Language :: Rust",
12+
"Programming Language :: Python :: Implementation :: CPython",
13+
"Programming Language :: Python :: Implementation :: PyPy",
14+
]
15+
16+
[tool.maturin]
17+
features = ["pyo3/extension-module"]
18+
module-name = "async_tiff._async_tiff"
19+
python-source = "python"
20+
21+
[tool.uv]
22+
dev-dependencies = [
23+
"griffe-inherited-docstrings>=1.0.1",
24+
"ipykernel>=6.29.5",
25+
"maturin>=1.7.4",
26+
"mike>=2.1.3",
27+
"mkdocs-material[imaging]>=9.5.40",
28+
"mkdocs>=1.6.1",
29+
"mkdocstrings-python>=1.13.0",
30+
"mkdocstrings>=0.27.0",
31+
"numpy>=1",
32+
"pip>=24.2",
33+
"pytest>=8.3.3",
34+
"ruff>=0.8.4",
35+
]

python/src/lib.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#![deny(clippy::undocumented_unsafe_blocks)]
2+
3+
mod coord_type;
4+
mod kdtree;
5+
mod rtree;
6+
pub(crate) mod util;
7+
8+
use pyo3::prelude::*;
9+
10+
const VERSION: &str = env!("CARGO_PKG_VERSION");
11+
12+
#[pyfunction]
13+
fn ___version() -> &'static str {
14+
VERSION
15+
}
16+
17+
/// Raise RuntimeWarning for debug builds
18+
#[pyfunction]
19+
fn check_debug_build(_py: Python) -> PyResult<()> {
20+
#[cfg(debug_assertions)]
21+
{
22+
use pyo3::exceptions::PyRuntimeWarning;
23+
use pyo3::intern;
24+
use pyo3::types::PyTuple;
25+
26+
let warnings_mod = _py.import(intern!(_py, "warnings"))?;
27+
let warning = PyRuntimeWarning::new_err(
28+
"async-tiff has not been compiled in release mode. Performance will be degraded.",
29+
);
30+
let args = PyTuple::new(_py, vec![warning])?;
31+
warnings_mod.call_method1(intern!(_py, "warn"), args)?;
32+
}
33+
34+
Ok(())
35+
}
36+
37+
#[pymodule]
38+
fn _async_tiff(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
39+
check_debug_build(py)?;
40+
41+
m.add_wrapped(wrap_pyfunction!(___version))?;
42+
43+
Ok(())
44+
}

src/async_reader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use crate::error::{AiocogeoError, Result};
1616
///
1717
/// Notes:
1818
///
19-
/// 1. There is a default implementation for types that implement [`AsyncRead`]
20-
/// and [`AsyncSeek`], for example [`tokio::fs::File`].
19+
/// 1. There is a default implementation for types that implement [`tokio::io::AsyncRead`]
20+
/// and [`tokio::io::AsyncSeek`], for example [`tokio::fs::File`].
2121
///
2222
/// 2. [`ObjectReader`], available when the `object_store` crate feature
2323
/// is enabled, implements this interface for [`ObjectStore`].

0 commit comments

Comments
 (0)