Skip to content

Commit

Permalink
upgrade pyo3
Browse files Browse the repository at this point in the history
  • Loading branch information
mbway committed Nov 17, 2024
1 parent ab97c72 commit 93bd51a
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 148 deletions.
1 change: 1 addition & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ To update maturin:
test crates and update `uniffi-bindgen` in `requirements.txt` to match.
- check that no crates have been added to `test-crates` that should be excluded from the import hook tests.
If so, add them to `IGNORED_TEST_CRATES` in `common.py`
- upgrade the test packages in `test_import_hook/*_helpers`
- update the version check in the import hook to ensure it allows using the new version
- run the tests to ensure everything still works

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ fn get_num() -> usize { 10 }

#[pymodule]
fn my_script(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(get_num))?;
m.add_function(wrap_pyfunction!(get_num, m)?)?;
Ok(())
}
4 changes: 2 additions & 2 deletions tests/test_import_hook/file_importer_helpers/my_script_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn get_other_num() -> usize { 100 }

#[pymodule]
fn my_script(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(get_num))?;
m.add_wrapped(wrap_pyfunction!(get_other_num))?;
m.add_function(wrap_pyfunction!(get_num, m)?)?;
m.add_function(wrap_pyfunction!(get_other_num, m)?)?;
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ fn get_num() -> usize {

#[pymodule]
fn my_script(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(get_num))?;
m.add_function(wrap_pyfunction!(get_num, m)?)?;
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ pub fn do_something(a: usize, b: usize) -> PyResult<usize> {

#[pymodule]
pub fn my_rust_module(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(do_something))?;
m.add_function(wrap_pyfunction!(do_something, m)?)?;
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ fn get_str() -> String {

fn register_child_module(py: Python<'_>, parent_module: &Bound<'_, PyModule>) -> PyResult<()> {
let child_module = PyModule::new_bound(py, "child")?;
child_module.add_wrapped(wrap_pyfunction!(get_str))?;
child_module.add_function(wrap_pyfunction!(get_str, child_module)?)?;
parent_module.add_submodule(&child_module)?;
Ok(())
}

#[pymodule]
fn my_module(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(get_num))?;
m.add_wrapped(wrap_pyfunction!(get_global_num))?;
m.add_wrapped(wrap_pyfunction!(set_global_num))?;
m.add_function(wrap_pyfunction!(get_num, m)?)?;
m.add_function(wrap_pyfunction!(get_global_num, m)?)?;
m.add_function(wrap_pyfunction!(set_global_num, m)?)?;
m.add_class::<Integer>()?;
m.add_class::<PicklableInteger>()?;

Expand Down
159 changes: 21 additions & 138 deletions tests/test_import_hook/project_importer_helpers/blank-project/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
description = ""

[dependencies]
pyo3 = { version = "0.21.2", features = ["extension-module"] }
pyo3 = { version = "0.23.1", features = ["extension-module"] }

[lib]
crate-type = ["cdylib"]

0 comments on commit 93bd51a

Please sign in to comment.