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

Fix PyO3 0.21 deprecation warnings #222

Merged
merged 1 commit into from
May 20, 2024
Merged

Fix PyO3 0.21 deprecation warnings #222

merged 1 commit into from
May 20, 2024

Conversation

kylecarow
Copy link
Collaborator

Also add rasterio and gdal imports at the top of the OSM example notebook to fail faster (rather than waiting for grade data to download on slow PyCon wifi)

https://pyo3.rs/v0.21.2/migration#from-020-to-021

According to the above link, there are some API changes for 0.21 to remove GIL markers. This means changing the pymodule def:

#[pymodule]
- fn routee_compass_py(_py: Python, m: &PyModule) -> PyResult<()> {
+ fn routee_compass_py(m: &Bound<'_, PyModule>) -> PyResult<()> {

As well as classmethod defs (though this one could be a staticmethod and it works just fine, since we don't use the pyclass):

- #[classmethod]
- pub fn _from_config_toml_string(
-     _cls: &PyType,
-     config_string: String,
-     original_file_path: String,
- ) -> PyResult<#name> {
+ #[staticmethod]
+ pub fn _from_config_toml_string(
+     config_string: String,
+     original_file_path: String,
+ ) -> PyResult<#name> {

Also in the OSM example I had issues with failing imports during grade data building, so I added a try/except at the top to catch those errors sooner.

Fixes #167

@kylecarow kylecarow added this to the PyCon 2024 milestone May 20, 2024
@kylecarow kylecarow requested a review from nreinicke May 20, 2024 14:50
Copy link
Collaborator

@nreinicke nreinicke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for fixing!

@nreinicke nreinicke merged commit 0940a6d into main May 20, 2024
5 checks passed
@nreinicke nreinicke deleted the kjc/deprecation-fix branch May 20, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pyo3 deprecated method from latest dependency upgrade
2 participants