diff --git a/python/Cargo.lock b/python/Cargo.lock index c330f9eb7..5cf9a8095 100644 --- a/python/Cargo.lock +++ b/python/Cargo.lock @@ -1143,7 +1143,7 @@ dependencies = [ "parquet", "pyo3", "pyo3-arrow", - "pyo3-asyncio-0-21", + "pyo3-async-runtimes", "pythonize", "reqwest", "serde_json", @@ -1926,9 +1926,9 @@ dependencies = [ [[package]] name = "numpy" -version = "0.21.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec170733ca37175f5d75a5bea5911d6ff45d2cd52849ce98b685394e4f2f37f4" +checksum = "edb929bc0da91a4d85ed6c0a84deaa53d411abfb387fc271124f91bf6b89f14e" dependencies = [ "half", "libc", @@ -2284,9 +2284,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" +checksum = "3d922163ba1f79c04bc49073ba7b32fd5a8d3b76a87c955921234b8e77333c51" dependencies = [ "anyhow", "cfg-if", @@ -2296,7 +2296,7 @@ dependencies = [ "indoc", "libc", "memoffset", - "parking_lot", + "once_cell", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -2307,9 +2307,9 @@ dependencies = [ [[package]] name = "pyo3-arrow" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e23a03fb0bc2b06103d4bc6948424292ad410ef31ed14b1af620c5937f6fac37" +checksum = "a641506190769c9cb5e3e187b64514afaf318e904accf0137a6ed5ca436d27d5" dependencies = [ "arrow", "arrow-array", @@ -2323,10 +2323,10 @@ dependencies = [ ] [[package]] -name = "pyo3-asyncio-0-21" -version = "0.21.0" +name = "pyo3-async-runtimes" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fde289486f7d5cee0ac7c20b2637a0657654681079cc5eedc90d9a2a79af1e5" +checksum = "2529f0be73ffd2be0cc43c013a640796558aa12d7ca0aab5cc14f375b4733031" dependencies = [ "futures", "once_cell", @@ -2337,9 +2337,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" +checksum = "bc38c5feeb496c8321091edf3d63e9a6829eab4b863b4a6a65f26f3e9cc6b179" dependencies = [ "once_cell", "target-lexicon", @@ -2347,9 +2347,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" +checksum = "94845622d88ae274d2729fcefc850e63d7a3ddff5e3ce11bd88486db9f1d357d" dependencies = [ "libc", "pyo3-build-config", @@ -2376,9 +2376,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" +checksum = "e655aad15e09b94ffdb3ce3d217acf652e26bbc37697ef012f5e5e348c716e5e" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -2388,11 +2388,11 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" +checksum = "ae1e3f09eecd94618f60a455a23def79f79eba4dc561a97324bf9ac8c6df30ce" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "pyo3-build-config", "quote", @@ -2401,9 +2401,9 @@ dependencies = [ [[package]] name = "pythonize" -version = "0.21.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d0664248812c38cc55a4ed07f88e4df516ce82604b93b1ffdc041aa77a6cb3c" +checksum = "90fcf491425978bd889015d5430f6473d91bdfa2097262f1e731aadcf6c2113e" dependencies = [ "pyo3", "serde", diff --git a/python/Cargo.toml b/python/Cargo.toml index 1a351c990..86271fb34 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -24,9 +24,10 @@ geoarrow = { path = "../rust/geoarrow" } # geoarrow = { version = "0.4.0-beta.1" } geozero = "0.14" indexmap = "2.5.0" +numpy = "0.22" object_store = "0.11" parquet = "53" -pyo3 = { version = "0.21.0", features = ["hashbrown", "serde", "anyhow"] } -pyo3-arrow = "0.4" +pyo3 = { version = "0.22.0", features = ["hashbrown", "serde", "anyhow"] } +pyo3-arrow = "0.5.1" serde_json = "1" thiserror = "1" diff --git a/python/geoarrow-compute/Cargo.toml b/python/geoarrow-compute/Cargo.toml index d4af2612b..fa9c5ebba 100644 --- a/python/geoarrow-compute/Cargo.toml +++ b/python/geoarrow-compute/Cargo.toml @@ -32,7 +32,7 @@ pyo3-geoarrow = { path = "../pyo3-geoarrow" } geo = "0.28" geoarrow = { workspace = true } geozero = { version = "0.14", features = ["with-svg"] } -numpy = "0.21" +numpy = { workspace = true } serde_json = "1" thiserror = "1" url = "2.5" diff --git a/python/geoarrow-compute/src/algorithm/geo/area.rs b/python/geoarrow-compute/src/algorithm/geo/area.rs index 571c7dca7..35b299f70 100644 --- a/python/geoarrow-compute/src/algorithm/geo/area.rs +++ b/python/geoarrow-compute/src/algorithm/geo/area.rs @@ -15,7 +15,7 @@ pub enum AreaMethod { } impl<'a> FromPyObject<'a> for AreaMethod { - fn extract(ob: &'a PyAny) -> PyResult { + fn extract_bound(ob: &Bound<'a, PyAny>) -> PyResult { let s: String = ob.extract()?; match s.to_lowercase().as_str() { "ellipsoidal" => Ok(Self::Geodesic), diff --git a/python/geoarrow-compute/src/broadcasting/primitive.rs b/python/geoarrow-compute/src/broadcasting/primitive.rs index 6ebfef9f6..568fc4711 100644 --- a/python/geoarrow-compute/src/broadcasting/primitive.rs +++ b/python/geoarrow-compute/src/broadcasting/primitive.rs @@ -38,7 +38,7 @@ use pyo3::prelude::*; pub struct BroadcastableFloat(pub(crate) BroadcastablePrimitive); impl<'a> FromPyObject<'a> for BroadcastableFloat { - fn extract(_ob: &'a PyAny) -> PyResult { + fn extract_bound(_ob: &Bound<'a, PyAny>) -> PyResult { todo!() // Python::with_gil(|py| { // let pa = py.import_bound("pyarrow")?; diff --git a/python/geoarrow-core/Cargo.toml b/python/geoarrow-core/Cargo.toml index 71e368b8b..633ddd1e6 100644 --- a/python/geoarrow-core/Cargo.toml +++ b/python/geoarrow-core/Cargo.toml @@ -32,7 +32,7 @@ pyo3-geoarrow = { path = "../pyo3-geoarrow" } geo = "0.28" geoarrow = { workspace = true } geozero = { version = "0.14", features = ["with-svg"] } -numpy = "0.21" +numpy = { workspace = true } serde_json = "1" thiserror = "1" url = "2.5" diff --git a/python/geoarrow-core/src/interop/shapely/from_shapely.rs b/python/geoarrow-core/src/interop/shapely/from_shapely.rs index be33d8fe0..60db2ffca 100644 --- a/python/geoarrow-core/src/interop/shapely/from_shapely.rs +++ b/python/geoarrow-core/src/interop/shapely/from_shapely.rs @@ -12,7 +12,8 @@ use geoarrow::datatypes::{Dimension, NativeType}; use pyo3::exceptions::PyValueError; use pyo3::intern; use pyo3::prelude::*; -use pyo3::types::{PyBytes, PyDict, PyString, PyTuple}; +use pyo3::pybacked::PyBackedBytes; +use pyo3::types::{PyDict, PyString, PyTuple}; use pyo3::PyAny; use pyo3_geoarrow::PyGeoArrowResult; @@ -90,7 +91,7 @@ pub fn from_shapely( shapely_mod.call_method(intern!(py, "to_ragged_array"), (input,), Some(&kwargs)) { let (geom_type, coords, offsets) = - ragged_array_output.extract::<(&PyAny, Bound, PyObject)>()?; + ragged_array_output.extract::<(Bound, Bound, PyObject)>()?; let coords = numpy_mod.call_method1( intern!(py, "ascontiguousarray"), PyTuple::new_bound(py, vec![coords]), @@ -181,8 +182,8 @@ fn make_wkb_arr( let mut builder = BinaryBuilder::with_capacity(wkb_result.len()?, 0); for item in wkb_result.iter()? { - let x = item?.extract::<&PyBytes>()?; - builder.append_value(x.as_bytes()); + let buf = item?.extract::()?; + builder.append_value(buf.as_ref()); } Ok(geoarrow::array::WKBArray::new(builder.finish(), metadata)) diff --git a/python/geoarrow-io/Cargo.toml b/python/geoarrow-io/Cargo.toml index e3c26ea53..ca9ea7063 100644 --- a/python/geoarrow-io/Cargo.toml +++ b/python/geoarrow-io/Cargo.toml @@ -23,7 +23,7 @@ async = [ "dep:futures", "dep:object_store", "parquet/object_store", - "dep:pyo3-asyncio-0-21", + "dep:pyo3-async-runtimes", "geoarrow/flatgeobuf_async", "geoarrow/parquet_async", "geoarrow/postgis", @@ -45,10 +45,10 @@ object_store = { workspace = true, features = [ parquet = { workspace = true } pyo3 = { workspace = true } pyo3-arrow = { workspace = true } -pyo3-asyncio-0-21 = { version = "0.21", features = [ +pyo3-async-runtimes = { version = "0.22", features = [ "tokio-runtime", ], optional = true } -pythonize = "0.21" +pythonize = "0.22" geo = "0.28" geo-traits = { workspace = true } geoarrow = { workspace = true, features = [ diff --git a/python/geoarrow-io/src/error.rs b/python/geoarrow-io/src/error.rs index 92fe43ec3..1f80ad5bf 100644 --- a/python/geoarrow-io/src/error.rs +++ b/python/geoarrow-io/src/error.rs @@ -3,8 +3,8 @@ use pyo3::prelude::*; pub enum PyGeoArrowError { GeoArrowError(geoarrow::error::GeoArrowError), - PyErr(PyErr), PyArrowError(pyo3_arrow::error::PyArrowError), + PyErr(PyErr), PythonizeError(pythonize::PythonizeError), #[cfg(feature = "async")] ObjectStoreError(object_store::Error), @@ -75,15 +75,15 @@ impl From for PyGeoArrowError { } } -impl From for PyGeoArrowError { - fn from(other: PyTypeError) -> Self { - Self::PyErr((&other).into()) +impl From> for PyGeoArrowError { + fn from(other: Bound<'_, PyTypeError>) -> Self { + Self::PyErr(other.into()) } } -impl From for PyGeoArrowError { - fn from(other: PyValueError) -> Self { - Self::PyErr((&other).into()) +impl From> for PyGeoArrowError { + fn from(other: Bound<'_, PyValueError>) -> Self { + Self::PyErr((other).into()) } } diff --git a/python/geoarrow-io/src/io/flatgeobuf/async.rs b/python/geoarrow-io/src/io/flatgeobuf/async.rs index 796e86e8e..f1ee0d7d3 100644 --- a/python/geoarrow-io/src/io/flatgeobuf/async.rs +++ b/python/geoarrow-io/src/io/flatgeobuf/async.rs @@ -5,6 +5,7 @@ use geoarrow::io::flatgeobuf::read_flatgeobuf_async as _read_flatgeobuf_async; use geoarrow::io::flatgeobuf::FlatGeobufReaderOptions; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; +use pyo3_async_runtimes::tokio::future_into_py; #[pyfunction] #[pyo3(signature = (path, *, fs=None, batch_size=65536, bbox=None))] @@ -18,7 +19,7 @@ pub fn read_flatgeobuf_async( let reader = construct_reader(py, path, fs)?; match reader { AnyFileReader::Async(async_reader) => { - let fut = pyo3_asyncio_0_21::tokio::future_into_py(py, async move { + let fut = future_into_py(py, async move { let options = FlatGeobufReaderOptions { batch_size: Some(batch_size), bbox, diff --git a/python/geoarrow-io/src/io/input/sync.rs b/python/geoarrow-io/src/io/input/sync.rs index e09b7b502..b1773ae15 100644 --- a/python/geoarrow-io/src/io/input/sync.rs +++ b/python/geoarrow-io/src/io/input/sync.rs @@ -19,10 +19,22 @@ use std::path::{Path, PathBuf}; #[derive(Debug)] pub struct PyFileLikeObject { + // We use PyObject instead of Bound because Bound is a GIL-bound type. + // We want to avoid holding the GIL when creating the struct. + // The GIL will be re-taken when the methods are called. inner: PyObject, is_text_io: bool, } +impl Clone for PyFileLikeObject { + fn clone(&self) -> Self { + Python::with_gil(|py| PyFileLikeObject { + inner: self.inner.clone_ref(py), + is_text_io: self.is_text_io, + }) + } +} + /// Wraps a `PyObject`, and implements read, seek, and write for it. impl PyFileLikeObject { /// Creates an instance of a `PyFileLikeObject` from a `PyObject`. @@ -89,14 +101,6 @@ impl PyFileLikeObject { } } -impl Clone for PyFileLikeObject { - fn clone(&self) -> Self { - Python::with_gil(|py| { - PyFileLikeObject::new(self.inner.clone_ref(py)).expect("Failed to clone") - }) - } -} - /// Extracts a string repr from, and returns an IO error to send back to rust. fn pyerr_to_io_err(e: PyErr) -> io::Error { Python::with_gil(|py| { @@ -326,13 +330,7 @@ impl<'py> FromPyObject<'py> for FileReader { Ok(Self::File(path.clone(), BufReader::new(File::open(path)?))) } else { Ok(Self::FileLike(BufReader::new( - PyFileLikeObject::with_requirements( - ob.as_gil_ref().into(), - true, - false, - true, - false, - )?, + PyFileLikeObject::with_requirements(ob.clone().unbind(), true, false, true, false)?, ))) } } @@ -406,13 +404,7 @@ impl<'py> FromPyObject<'py> for FileWriter { )) } else { Ok(Self::FileLike(BufWriter::new( - PyFileLikeObject::with_requirements( - ob.as_gil_ref().into(), - false, - true, - true, - false, - )?, + PyFileLikeObject::with_requirements(ob.clone().unbind(), false, true, true, false)?, ))) } } diff --git a/python/geoarrow-io/src/io/object_store/store.rs b/python/geoarrow-io/src/io/object_store/store.rs index c404adad9..23bdf29a0 100644 --- a/python/geoarrow-io/src/io/object_store/store.rs +++ b/python/geoarrow-io/src/io/object_store/store.rs @@ -378,6 +378,7 @@ impl PyObjectStore { /// options: a dict of options (e.g. authentication settings) for connecting to the object /// store. #[new] + #[pyo3(signature = (root, options = None, client_options = None))] fn new( root: String, options: Option>, diff --git a/python/geoarrow-io/src/io/parquet/async.rs b/python/geoarrow-io/src/io/parquet/async.rs index c53c02eb2..88c2e937c 100644 --- a/python/geoarrow-io/src/io/parquet/async.rs +++ b/python/geoarrow-io/src/io/parquet/async.rs @@ -23,7 +23,8 @@ use parquet::arrow::async_reader::ParquetObjectReader; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; use pyo3_arrow::{PyArray, PySchema}; -use pythonize::depythonize_bound; +use pyo3_async_runtimes::tokio::future_into_py; +use pythonize::depythonize; use tokio::runtime::Runtime; #[pyfunction] @@ -37,7 +38,7 @@ pub fn read_parquet_async( let reader = construct_reader(py, path, fs)?; match reader { AnyFileReader::Async(async_reader) => { - let fut = pyo3_asyncio_0_21::tokio::future_into_py(py, async move { + let fut = future_into_py(py, async move { let object_meta = async_reader .store .head(&async_reader.path) @@ -126,6 +127,7 @@ impl ParquetFile { Ok(PySchema::new(schema).to_arro3(py)?) } + #[pyo3(signature = (column_name=None))] fn crs(&self, py: Python, column_name: Option<&str>) -> PyGeoArrowResult { if let Some(crs) = self.geoparquet_meta.crs(column_name)? { // TODO: remove clone @@ -135,13 +137,14 @@ impl ParquetFile { } } + #[pyo3(signature = (row_group_idx, bbox_paths=None))] pub fn row_group_bounds( &self, row_group_idx: usize, bbox_paths: Option>, ) -> PyGeoArrowResult>> { let paths: Option = - bbox_paths.map(|x| depythonize_bound(x)).transpose()?; + bbox_paths.map(|x| depythonize(&x)).transpose()?; if let Some(bounds) = self .geoparquet_meta @@ -158,17 +161,19 @@ impl ParquetFile { } } + #[pyo3(signature = (bbox_paths=None))] pub fn row_groups_bounds( &self, py: Python, bbox_paths: Option>, ) -> PyGeoArrowResult { let paths: Option = - bbox_paths.map(|x| depythonize_bound(x)).transpose()?; + bbox_paths.map(|x| depythonize(&x)).transpose()?; let bounds = self.geoparquet_meta.row_groups_bounds(paths.as_ref())?; Ok(PyArray::new(bounds.to_array_ref(), bounds.extension_field()).to_arro3(py)?) } + #[pyo3(signature = (column_name=None))] fn file_bbox(&self, column_name: Option<&str>) -> PyGeoArrowResult>> { let bbox = self.geoparquet_meta.file_bbox(column_name)?; Ok(bbox.map(|b| b.to_vec())) @@ -192,7 +197,7 @@ impl ParquetFile { options, ) .build()?; - let fut = pyo3_asyncio_0_21::tokio::future_into_py(py, async move { + let fut = future_into_py(py, async move { let table = stream .read_table() .await @@ -381,6 +386,7 @@ impl ParquetDataset { Ok(PySchema::new(schema).to_arro3(py)?) } + #[pyo3(signature = (column_name=None))] fn crs(&self, py: Python, column_name: Option<&str>) -> PyGeoArrowResult { if let Some(crs) = self.meta.crs(column_name)? { // TODO: remove clone @@ -404,7 +410,7 @@ impl ParquetDataset { let readers = self.to_readers(options)?; let output_schema = self.meta.resolved_schema(Default::default())?; - let fut = pyo3_asyncio_0_21::tokio::future_into_py(py, async move { + let fut = future_into_py(py, async move { let request_futures = readers.into_iter().map(|reader| reader.read_table()); let tables = futures::future::join_all(request_futures) .await diff --git a/python/geoarrow-io/src/io/parquet/options.rs b/python/geoarrow-io/src/io/parquet/options.rs index 53c2eae26..212e9e2b0 100644 --- a/python/geoarrow-io/src/io/parquet/options.rs +++ b/python/geoarrow-io/src/io/parquet/options.rs @@ -3,7 +3,7 @@ use geoarrow::array::CoordType; use geoarrow::io::parquet::metadata::GeoParquetBboxCovering; use geoarrow::io::parquet::GeoParquetReaderOptions; use pyo3::prelude::*; -use pythonize::depythonize_bound; +use pythonize::depythonize; use crate::error::PyGeoArrowResult; @@ -21,7 +21,7 @@ pub fn create_options( ) }); let bbox_paths: Option = - bbox_paths.map(|x| depythonize_bound(x)).transpose()?; + bbox_paths.map(|x| depythonize(&x)).transpose()?; let mut options = GeoParquetReaderOptions::default(); diff --git a/python/geoarrow-io/src/io/parquet/sync.rs b/python/geoarrow-io/src/io/parquet/sync.rs index c546259cd..b88809b48 100644 --- a/python/geoarrow-io/src/io/parquet/sync.rs +++ b/python/geoarrow-io/src/io/parquet/sync.rs @@ -94,7 +94,7 @@ pub enum GeoParquetEncoding { } impl<'a> FromPyObject<'a> for GeoParquetEncoding { - fn extract(ob: &'a PyAny) -> PyResult { + fn extract_bound(ob: &Bound<'a, PyAny>) -> PyResult { let s: String = ob.extract()?; match s.to_lowercase().as_str() { "wkb" => Ok(Self::WKB), diff --git a/python/geoarrow-io/src/io/postgis.rs b/python/geoarrow-io/src/io/postgis.rs index 3461f6c89..d0574220d 100644 --- a/python/geoarrow-io/src/io/postgis.rs +++ b/python/geoarrow-io/src/io/postgis.rs @@ -3,6 +3,7 @@ use crate::util::table_to_pytable; use geoarrow::error::GeoArrowError; use geoarrow::io::postgis::read_postgis as _read_postgis; use pyo3::prelude::*; +use pyo3_async_runtimes::tokio::future_into_py; use sqlx::postgres::PgPoolOptions; #[pyfunction] @@ -38,7 +39,7 @@ pub fn read_postgis_async( connection_url: String, sql: String, ) -> PyGeoArrowResult { - let fut = pyo3_asyncio_0_21::tokio::future_into_py(py, async move { + let fut = future_into_py(py, async move { let pool = PgPoolOptions::new() .connect(&connection_url) .await diff --git a/python/pyo3-geoarrow/src/array.rs b/python/pyo3-geoarrow/src/array.rs index 3d661de84..3350a0108 100644 --- a/python/pyo3-geoarrow/src/array.rs +++ b/python/pyo3-geoarrow/src/array.rs @@ -65,7 +65,7 @@ impl PyNativeArray { data.extract() } - #[allow(unused_variables)] + #[pyo3(signature = (requested_schema=None))] fn __arrow_c_array__<'py>( &'py self, py: Python<'py>, @@ -209,7 +209,7 @@ impl PySerializedArray { data.extract() } - #[allow(unused_variables)] + #[pyo3(signature = (requested_schema=None))] fn __arrow_c_array__<'py>( &'py self, py: Python<'py>, diff --git a/python/pyo3-geoarrow/src/chunked_array.rs b/python/pyo3-geoarrow/src/chunked_array.rs index 28e0f2429..ba524fe82 100644 --- a/python/pyo3-geoarrow/src/chunked_array.rs +++ b/python/pyo3-geoarrow/src/chunked_array.rs @@ -54,7 +54,7 @@ impl PyChunkedNativeArray { #[pymethods] impl PyChunkedNativeArray { - #[allow(unused_variables)] + #[pyo3(signature = (requested_schema=None))] fn __arrow_c_stream__<'py>( &self, py: Python<'py>, diff --git a/python/pyo3-geoarrow/src/coord_type.rs b/python/pyo3-geoarrow/src/coord_type.rs index cf0f63fa9..28d1781c8 100644 --- a/python/pyo3-geoarrow/src/coord_type.rs +++ b/python/pyo3-geoarrow/src/coord_type.rs @@ -9,7 +9,7 @@ pub enum PyCoordType { } impl<'a> FromPyObject<'a> for PyCoordType { - fn extract(ob: &'a PyAny) -> PyResult { + fn extract_bound(ob: &Bound<'a, PyAny>) -> PyResult { let s: String = ob.extract()?; match s.to_lowercase().as_str() { "interleaved" => Ok(Self::Interleaved), diff --git a/python/pyo3-geoarrow/src/data_type.rs b/python/pyo3-geoarrow/src/data_type.rs index 14aa26e74..7b32d3cec 100644 --- a/python/pyo3-geoarrow/src/data_type.rs +++ b/python/pyo3-geoarrow/src/data_type.rs @@ -32,6 +32,7 @@ impl PyNativeType { #[pymethods] impl PyNativeType { #[new] + #[pyo3(signature = (r#type, dimension=None, coord_type=None))] fn py_new( r#type: &str, dimension: Option, diff --git a/python/pyo3-geoarrow/src/dimension.rs b/python/pyo3-geoarrow/src/dimension.rs index 92f0a4df4..df32266b9 100644 --- a/python/pyo3-geoarrow/src/dimension.rs +++ b/python/pyo3-geoarrow/src/dimension.rs @@ -10,7 +10,7 @@ pub enum PyDimension { } impl<'a> FromPyObject<'a> for PyDimension { - fn extract(ob: &'a PyAny) -> PyResult { + fn extract_bound(ob: &Bound<'a, PyAny>) -> PyResult { let s: String = ob.extract()?; match s.to_lowercase().as_str() { "xy" => Ok(Self::XY), diff --git a/python/pyo3-geoarrow/src/error.rs b/python/pyo3-geoarrow/src/error.rs index 77b3509c8..2e50f6bb8 100644 --- a/python/pyo3-geoarrow/src/error.rs +++ b/python/pyo3-geoarrow/src/error.rs @@ -45,15 +45,15 @@ impl From for PyGeoArrowError { } } -impl From for PyGeoArrowError { - fn from(other: PyTypeError) -> Self { - Self::PyErr((&other).into()) +impl From> for PyGeoArrowError { + fn from(other: Bound<'_, PyTypeError>) -> Self { + Self::PyErr((other).into()) } } -impl From for PyGeoArrowError { - fn from(other: PyValueError) -> Self { - Self::PyErr((&other).into()) +impl From> for PyGeoArrowError { + fn from(other: Bound<'_, PyValueError>) -> Self { + Self::PyErr((other).into()) } } diff --git a/python/pyo3-geoarrow/src/scalar.rs b/python/pyo3-geoarrow/src/scalar.rs index 5a1964521..aa7d1ef1e 100644 --- a/python/pyo3-geoarrow/src/scalar.rs +++ b/python/pyo3-geoarrow/src/scalar.rs @@ -49,6 +49,7 @@ impl PyGeometry { #[pymethods] impl PyGeometry { + #[pyo3(signature = (requested_schema=None))] fn __arrow_c_array__<'py>( &'py self, py: Python<'py>,