forked from RustPython/RustPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsysconfigdata.rs
More file actions
25 lines (23 loc) · 887 Bytes
/
sysconfigdata.rs
File metadata and controls
25 lines (23 loc) · 887 Bytes
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
pub(crate) use _sysconfigdata::make_module;
#[pymodule]
pub(crate) mod _sysconfigdata {
use crate::{builtins::PyDictRef, convert::ToPyObject, stdlib::sys::MULTIARCH, VirtualMachine};
#[pyattr]
fn build_time_vars(vm: &VirtualMachine) -> PyDictRef {
let vars = vm.ctx.new_dict();
macro_rules! sysvars {
($($key:literal => $value:expr),*$(,)?) => {{
$(vars.set_item($key, $value.to_pyobject(vm), vm).unwrap();)*
}};
}
sysvars! {
// fake shared module extension
"EXT_SUFFIX" => format!(".rustpython-{}", MULTIARCH),
"MULTIARCH" => MULTIARCH,
// enough for tests to stop expecting urandom() to fail after restricting file resources
"HAVE_GETRANDOM" => 1,
}
include!(concat!(env!("OUT_DIR"), "/env_vars.rs"));
vars
}
}