Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to pyo3 0.22 #14

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.12"
architecture: x64
if: matrix.os == 'macOS-latest'

Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changes

## Unreleased

* Upgrade `pyo3` from 0.21 to 0.22 and `geozero` from 0.12 to 0.14.

## 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.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added data/ne_110m_land.fgb
Binary file not shown.
4 changes: 3 additions & 1 deletion src/from_py.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 8 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -33,15 +35,15 @@
//!
//! // 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):
//! return {"type": "Point", "coordinates": [5., 3.]}
//! "#, None, None).unwrap();
//!
//! // create an instance of the class and extract the geometry
//! py.eval(r#"Something()"#, None, None)?.extract::<Geometry>()
//! py.eval_bound(r#"Something()"#, None, None)?.extract::<Geometry>()
//! }).unwrap();
//! assert_eq!(geom.0, GtGeometry::Point(Point::new(5.0_f64, 3.0_f64)));
//! ```
Expand All @@ -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;
//!
Expand All @@ -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();
//! });
//! ```

Expand Down
16 changes: 8 additions & 8 deletions src/wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ macro_rules! dt_mod {
}
}

impl<'source> FromPyObject<'source> for GeometryVec {
fn extract(ob: &'source PyAny) -> PyResult<Self> {
impl FromPyObject<'_> for GeometryVec {
fn extract_bound(ob: &Bound<'_, PyAny>) -> PyResult<Self> {
ob.as_geometry_vec()
}
}
Expand All @@ -108,9 +108,9 @@ macro_rules! dt_mod {
fn as_geometry_vec(&self) -> PyResult<GeometryVec>;
}

impl AsGeometryVec for PyAny {
impl AsGeometryVec for Bound<'_, PyAny> {
fn as_geometry_vec(&self) -> PyResult<GeometryVec> {
GeometryVec::extract(self)
GeometryVec::extract_bound(self)
}
}

Expand All @@ -129,8 +129,8 @@ macro_rules! dt_mod {
}
}

impl<'source> FromPyObject<'source> for GeometryVecFc {
fn extract(ob: &'source PyAny) -> PyResult<Self> {
impl FromPyObject<'_> for GeometryVecFc {
fn extract_bound(ob: &Bound<'_, PyAny>) -> PyResult<Self> {
ob.as_geometry_vec_fc()
}
}
Expand All @@ -152,9 +152,9 @@ macro_rules! dt_mod {
fn as_geometry_vec_fc(&self) -> PyResult<GeometryVecFc>;
}

impl AsGeometryVecFc for PyAny {
impl AsGeometryVecFc for Bound<'_, PyAny> {
fn as_geometry_vec_fc(&self) -> PyResult<GeometryVecFc> {
GeometryVecFc::extract(self)
GeometryVecFc::extract_bound(self)
}
}
}
Expand Down
Loading