-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlib.rs
More file actions
45 lines (35 loc) · 1.12 KB
/
lib.rs
File metadata and controls
45 lines (35 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
// Use patched version of zarrs-metadata
use zarrs_metadata as _;
mod table;
use pyo3::prelude::*;
const VERSION: &str = env!("CARGO_PKG_VERSION");
#[pyfunction]
fn ___version() -> &'static str {
VERSION
}
/// Raise RuntimeWarning for debug builds
#[pyfunction]
fn check_debug_build(_py: Python) -> PyResult<()> {
#[cfg(debug_assertions)]
{
use pyo3::exceptions::PyRuntimeWarning;
use pyo3::intern;
use pyo3::types::PyTuple;
let warnings_mod = _py.import(intern!(_py, "warnings"))?;
let warning = PyRuntimeWarning::new_err(
"zarr-datafusion-search has not been compiled in release mode. Performance will be degraded.",
);
let args = PyTuple::new(_py, vec![warning])?;
warnings_mod.call_method1(intern!(_py, "warn"), args)?;
}
Ok(())
}
/// A Python module implemented in Rust.
#[pymodule]
fn _rust(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
check_debug_build(py)?;
m.add_wrapped(wrap_pyfunction!(___version))?;
m.add_class::<table::PyZarrTable>()?;
Ok(())
}