test-crates/lib_with_disallowed_lib/src/lib.rs
raw| 1 | use std::os::raw::c_ulong; |
| 2 | |
| 3 | use pyo3::prelude::*; |
| 4 | |
| 5 | #[link(name = "z")] |
| 6 | extern "C" { |
| 7 | fn gzflags() -> c_ulong; |
| 8 | } |
| 9 | |
| 10 | #[pyfunction] |
| 11 | fn add(x: usize, y: usize) -> usize { |
| 12 | let _version = unsafe { libz_sys::zlibVersion() }; |
| 13 | let _flags = unsafe { gzflags() }; |
| 14 | let sum = x + y; |
| 15 | sum |
| 16 | } |
| 17 | |
| 18 | #[pymodule] |
| 19 | fn lib_with_disallowed_lib(m: &Bound<'_, PyModule>) -> PyResult<()> { |
| 20 | m.add_wrapped(wrap_pyfunction!(add))?; |
| 21 | |
| 22 | Ok(()) |
| 23 | } |