File tree Expand file tree Collapse file tree 3 files changed +60
-3
lines changed Expand file tree Collapse file tree 3 files changed +60
-3
lines changed Original file line number Diff line number Diff line change 1+ use pyo3:: exceptions:: PyRuntimeWarning ;
2+ use pyo3:: intern;
13use pyo3:: prelude:: * ;
4+ use pyo3:: types:: PyTuple ;
25mod algorithm;
36pub mod broadcasting;
47pub mod ffi;
@@ -11,9 +14,25 @@ fn ___version() -> &'static str {
1114 VERSION
1215}
1316
17+ /// Raise RuntimeWarning for debug builds
18+ #[ pyfunction]
19+ fn check_debug_build ( py : Python ) -> PyResult < ( ) > {
20+ #[ cfg( debug_assertions) ]
21+ {
22+ let warnings_mod = py. import_bound ( intern ! ( py, "warnings" ) ) ?;
23+ let warning = PyRuntimeWarning :: new_err (
24+ "geoarrow-rust-compute has not been compiled in release mode. Performance will be degraded." ,
25+ ) ;
26+ let args = PyTuple :: new_bound ( py, vec ! [ warning. into_py( py) ] ) ;
27+ warnings_mod. call_method1 ( intern ! ( py, "warn" ) , args) ?;
28+ }
29+ Ok ( ( ) )
30+ }
31+
1432/// A Python module implemented in Rust.
1533#[ pymodule]
16- fn _compute ( _py : Python , m : & Bound < PyModule > ) -> PyResult < ( ) > {
34+ fn _compute ( py : Python , m : & Bound < PyModule > ) -> PyResult < ( ) > {
35+ check_debug_build ( py) ?;
1736 m. add_wrapped ( wrap_pyfunction ! ( ___version) ) ?;
1837
1938 // Top-level array/chunked array functions
Original file line number Diff line number Diff line change 1+ use pyo3:: exceptions:: PyRuntimeWarning ;
2+ use pyo3:: intern;
13use pyo3:: prelude:: * ;
4+ use pyo3:: types:: PyTuple ;
25mod constructors;
36pub ( crate ) mod crs;
47pub mod ffi;
@@ -12,9 +15,25 @@ fn ___version() -> &'static str {
1215 VERSION
1316}
1417
18+ /// Raise RuntimeWarning for debug builds
19+ #[ pyfunction]
20+ fn check_debug_build ( py : Python ) -> PyResult < ( ) > {
21+ #[ cfg( debug_assertions) ]
22+ {
23+ let warnings_mod = py. import_bound ( intern ! ( py, "warnings" ) ) ?;
24+ let warning = PyRuntimeWarning :: new_err (
25+ "geoarrow-rust-core has not been compiled in release mode. Performance will be degraded." ,
26+ ) ;
27+ let args = PyTuple :: new_bound ( py, vec ! [ warning. into_py( py) ] ) ;
28+ warnings_mod. call_method1 ( intern ! ( py, "warn" ) , args) ?;
29+ }
30+ Ok ( ( ) )
31+ }
32+
1533/// A Python module implemented in Rust.
1634#[ pymodule]
17- fn _rust ( _py : Python , m : & Bound < PyModule > ) -> PyResult < ( ) > {
35+ fn _rust ( py : Python , m : & Bound < PyModule > ) -> PyResult < ( ) > {
36+ check_debug_build ( py) ?;
1837 m. add_wrapped ( wrap_pyfunction ! ( ___version) ) ?;
1938
2039 m. add_class :: < pyo3_geoarrow:: PyGeometry > ( ) ?;
Original file line number Diff line number Diff line change 1+ use pyo3:: exceptions:: PyRuntimeWarning ;
2+ use pyo3:: intern;
13use pyo3:: prelude:: * ;
4+ use pyo3:: types:: PyTuple ;
25pub ( crate ) mod crs;
36pub mod error;
47// pub mod ffi;
@@ -12,9 +15,25 @@ fn ___version() -> &'static str {
1215 VERSION
1316}
1417
18+ /// Raise RuntimeWarning for debug builds
19+ #[ pyfunction]
20+ fn check_debug_build ( py : Python ) -> PyResult < ( ) > {
21+ #[ cfg( debug_assertions) ]
22+ {
23+ let warnings_mod = py. import_bound ( intern ! ( py, "warnings" ) ) ?;
24+ let warning = PyRuntimeWarning :: new_err (
25+ "geoarrow-rust-io has not been compiled in release mode. Performance will be degraded." ,
26+ ) ;
27+ let args = PyTuple :: new_bound ( py, vec ! [ warning. into_py( py) ] ) ;
28+ warnings_mod. call_method1 ( intern ! ( py, "warn" ) , args) ?;
29+ }
30+ Ok ( ( ) )
31+ }
32+
1533/// A Python module implemented in Rust.
1634#[ pymodule]
17- fn _io ( _py : Python , m : & Bound < PyModule > ) -> PyResult < ( ) > {
35+ fn _io ( py : Python , m : & Bound < PyModule > ) -> PyResult < ( ) > {
36+ check_debug_build ( py) ?;
1837 m. add_wrapped ( wrap_pyfunction ! ( ___version) ) ?;
1938
2039 // Async IO
You can’t perform that action at this time.
0 commit comments