diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e693af4..7b429a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.9" architecture: x64 if: matrix.os == 'macOS-latest' diff --git a/CHANGES.md b/CHANGES.md index 8eed187..6495c62 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,9 @@ # Changes ## Unreleased + +* Upgrade `pyo3` from 0.21 to 0.22 and `geozero` from 0.12 to 0.14. Require at least python 3.9. + ## 0.8.0 - 2024-04-19 * Upgrade `geozero` from 0.11 to 0.12. * Upgrade `pyo3` from 0.20 to 0.21 and switch to new `Bound` API. diff --git a/Cargo.toml b/Cargo.toml index 7d85b5c..0328364 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,13 +39,13 @@ geo-types = "0.7" num-traits = "0.2" [dependencies.pyo3] -version = "0.21" +version = "0.22" features = [ #"abi3" ] [dependencies.geozero] -version = "0.12" +version = "0.14" default-features = false features = ["with-geo", "with-wkb"] optional = true diff --git a/data/ne_110m_land.fgb b/data/ne_110m_land.fgb new file mode 100644 index 0000000..d9096f2 Binary files /dev/null and b/data/ne_110m_land.fgb differ diff --git a/src/from_py.rs b/src/from_py.rs index fedfe3a..f950097 100644 --- a/src/from_py.rs +++ b/src/from_py.rs @@ -670,7 +670,9 @@ class Something: py.run_bound( r#" import geopandas as gpd -world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres')) +import os +from pathlib import Path +world = gpd.read_file(Path(os.environ['CARGO_MANIFEST_DIR']) / 'data/ne_110m_land.fgb') "#, None, None, diff --git a/src/lib.rs b/src/lib.rs index 4376c2f..c39eb87 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,6 +25,8 @@ //! ```rust //! use geo_types::{Geometry as GtGeometry, Point}; //! use pyo3::{prepare_freethreaded_python, Python}; +//! use pyo3::types::PyDictMethods; +//! use pyo3::types::PyAnyMethods; //! use py_geo_interface::Geometry; //! //! prepare_freethreaded_python(); @@ -33,7 +35,7 @@ //! //! // Define a python class implementing the geo_interface. This could also be a shapely or geojson //! // object instead. These provide the same interface. -//! py.run(r#" +//! py.run_bound(r#" //! class Something: //! @property //! def __geo_interface__(self): @@ -41,7 +43,7 @@ //! "#, None, None).unwrap(); //! //! // create an instance of the class and extract the geometry -//! py.eval(r#"Something()"#, None, None)?.extract::() +//! py.eval_bound(r#"Something()"#, None, None)?.extract::() //! }).unwrap(); //! assert_eq!(geom.0, GtGeometry::Point(Point::new(5.0_f64, 3.0_f64))); //! ``` @@ -51,7 +53,7 @@ //! ```rust //! use geo_types::{Geometry as GtGeometry, Point}; //! use pyo3::{prepare_freethreaded_python, Python}; -//! use pyo3::types::{PyDict, PyTuple}; +//! use pyo3::types::{PyDict, PyTuple, PyDictMethods}; //! use pyo3::IntoPy; //! use py_geo_interface::Geometry; //! @@ -60,13 +62,13 @@ //! Python::with_gil(|py| { //! //! let geom: Geometry = Point::new(10.6_f64, 23.3_f64).into(); -//! let mut locals = PyDict::new(py); +//! let mut locals = PyDict::new_bound(py); //! locals.set_item("geom", geom.into_py(py)).unwrap(); //! -//! py.run(r#" +//! py.run_bound(r#" //! assert geom.__geo_interface__["type"] == "Point" //! assert geom.__geo_interface__["coordinates"] == (10.6, 23.3) -//! "#, None, Some(locals)).unwrap(); +//! "#, None, Some(&locals)).unwrap(); //! }); //! ``` diff --git a/src/wrappers.rs b/src/wrappers.rs index b59925a..bfe6c95 100644 --- a/src/wrappers.rs +++ b/src/wrappers.rs @@ -85,8 +85,8 @@ macro_rules! dt_mod { } } - impl<'source> FromPyObject<'source> for GeometryVec { - fn extract(ob: &'source PyAny) -> PyResult { + impl FromPyObject<'_> for GeometryVec { + fn extract_bound(ob: &Bound<'_, PyAny>) -> PyResult { ob.as_geometry_vec() } } @@ -108,9 +108,9 @@ macro_rules! dt_mod { fn as_geometry_vec(&self) -> PyResult; } - impl AsGeometryVec for PyAny { + impl AsGeometryVec for Bound<'_, PyAny> { fn as_geometry_vec(&self) -> PyResult { - GeometryVec::extract(self) + GeometryVec::extract_bound(self) } } @@ -129,8 +129,8 @@ macro_rules! dt_mod { } } - impl<'source> FromPyObject<'source> for GeometryVecFc { - fn extract(ob: &'source PyAny) -> PyResult { + impl FromPyObject<'_> for GeometryVecFc { + fn extract_bound(ob: &Bound<'_, PyAny>) -> PyResult { ob.as_geometry_vec_fc() } } @@ -152,9 +152,9 @@ macro_rules! dt_mod { fn as_geometry_vec_fc(&self) -> PyResult; } - impl AsGeometryVecFc for PyAny { + impl AsGeometryVecFc for Bound<'_, PyAny> { fn as_geometry_vec_fc(&self) -> PyResult { - GeometryVecFc::extract(self) + GeometryVecFc::extract_bound(self) } } }