-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathmod.rs
More file actions
96 lines (88 loc) · 3.04 KB
/
mod.rs
File metadata and controls
96 lines (88 loc) · 3.04 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#[cfg(feature = "gc_pcsaft")]
use crate::gc_pcsaft::python::gc_pcsaft as gc_pcsaft_module;
#[cfg(feature = "pcsaft")]
use crate::pcsaft::python::pcsaft as pcsaft_module;
#[cfg(feature = "pets")]
use crate::pets::python::pets as pets_module;
#[cfg(feature = "saftvrqmie")]
use crate::saftvrqmie::python::saftvrqmie as saftvrqmie_module;
#[cfg(feature = "uvtheory")]
use crate::uvtheory::python::uvtheory as uvtheory_module;
use pyo3::prelude::*;
use pyo3::wrap_pymodule;
use quantity::python::quantity as quantity_module;
mod cubic;
mod eos;
mod ideal_gas;
use cubic::cubic as cubic_module;
use eos::eos as eos_module;
use ideal_gas::ideal_gas as ideal_gas_module;
#[cfg(feature = "dft")]
mod dft;
#[cfg(feature = "dft")]
use dft::dft as dft_module;
#[pymodule]
pub fn feos(py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add("__version__", env!("CARGO_PKG_VERSION"))?;
m.add_wrapped(wrap_pymodule!(quantity_module))?;
m.add_wrapped(wrap_pymodule!(eos_module))?;
#[cfg(feature = "dft")]
m.add_wrapped(wrap_pymodule!(dft_module))?;
m.add_wrapped(wrap_pymodule!(ideal_gas_module))?;
m.add_wrapped(wrap_pymodule!(cubic_module))?;
#[cfg(feature = "pcsaft")]
m.add_wrapped(wrap_pymodule!(pcsaft_module))?;
#[cfg(feature = "gc_pcsaft")]
m.add_wrapped(wrap_pymodule!(gc_pcsaft_module))?;
#[cfg(feature = "pets")]
m.add_wrapped(wrap_pymodule!(pets_module))?;
#[cfg(feature = "uvtheory")]
m.add_wrapped(wrap_pymodule!(uvtheory_module))?;
#[cfg(feature = "saftvrqmie")]
m.add_wrapped(wrap_pymodule!(saftvrqmie_module))?;
// set_path(py, m, "feos.si", "quantity")?;
// set_path(py, m, "feos.eos", "eos")?;
// #[cfg(feature = "estimator")]
// set_path(py, m, "feos.eos.estimator", "eos.estimator_eos")?;
// #[cfg(feature = "dft")]
// set_path(py, m, "feos.dft", "dft")?;
// #[cfg(all(feature = "dft", feature = "estimator"))]
// set_path(py, m, "feos.dft.estimator", "dft.estimator_dft")?;
// set_path(py, m, "feos.ideal_gas", "ideal_gas")?;
// set_path(py, m, "feos.cubic", "cubic")?;
// #[cfg(feature = "pcsaft")]
// set_path(py, m, "feos.pcsaft", "pcsaft")?;
// #[cfg(feature = "gc_pcsaft")]
// set_path(py, m, "feos.gc_pcsaft", "gc_pcsaft")?;
// #[cfg(feature = "pets")]
// set_path(py, m, "feos.pets", "pets")?;
// #[cfg(feature = "uvtheory")]
// set_path(py, m, "feos.uvtheory", "uvtheory")?;
// #[cfg(feature = "saftvrqmie")]
// set_path(py, m, "feos.saftvrqmie", "saftvrqmie")?;
// py.run(
// "\
// import sys
// quantity.SINumber.__module__ = 'feos.si'
// quantity.SIArray1.__module__ = 'feos.si'
// quantity.SIArray2.__module__ = 'feos.si'
// quantity.SIArray3.__module__ = 'feos.si'
// quantity.SIArray4.__module__ = 'feos.si'
// ",
// None,
// Some(m.dict()),
// )?;
Ok(())
}
fn set_path(py: Python<'_>, m: &PyModule, path: &str, module: &str) -> PyResult<()> {
py.run(
&format!(
"\
import sys
sys.modules['{path}'] = {module}
"
),
None,
Some(m.dict()),
)
}