|
1 |
| -use super::sys::MULTIARCH; |
2 |
| -use crate::{function::IntoPyObject, ItemProtocol, PyObjectRef, VirtualMachine}; |
| 1 | +pub(crate) use _sysconfigdata::make_module; |
3 | 2 |
|
4 |
| -pub fn make_module(vm: &VirtualMachine) -> PyObjectRef { |
5 |
| - let vars = vm.ctx.new_dict(); |
6 |
| - macro_rules! sysvars { |
7 |
| - ($($key:literal => $value:expr),*$(,)?) => {{ |
8 |
| - $(vars.set_item($key, $value.into_pyobject(vm), vm).unwrap();)* |
9 |
| - }}; |
10 |
| - } |
11 |
| - sysvars! { |
12 |
| - // fake shared module extension |
13 |
| - "EXT_SUFFIX" => format!(".rustpython-{}", MULTIARCH), |
14 |
| - "MULTIARCH" => MULTIARCH, |
15 |
| - // enough for tests to stop expecting urandom() to fail after restricting file resources |
16 |
| - "HAVE_GETRANDOM" => 1, |
17 |
| - } |
18 |
| - include!(concat!(env!("OUT_DIR"), "/env_vars.rs")); |
| 3 | +#[pymodule] |
| 4 | +pub(crate) mod _sysconfigdata { |
| 5 | + use crate::{ |
| 6 | + builtins::PyDictRef, function::IntoPyObject, stdlib::sys::MULTIARCH, ItemProtocol, |
| 7 | + VirtualMachine, |
| 8 | + }; |
19 | 9 |
|
20 |
| - py_module!(vm, "_sysconfigdata", { |
21 |
| - "build_time_vars" => vars, |
22 |
| - }) |
| 10 | + #[pyattr] |
| 11 | + fn build_time_vars(vm: &VirtualMachine) -> PyDictRef { |
| 12 | + let vars = vm.ctx.new_dict(); |
| 13 | + macro_rules! sysvars { |
| 14 | + ($($key:literal => $value:expr),*$(,)?) => {{ |
| 15 | + $(vars.set_item($key, $value.into_pyobject(vm), vm).unwrap();)* |
| 16 | + }}; |
| 17 | + } |
| 18 | + sysvars! { |
| 19 | + // fake shared module extension |
| 20 | + "EXT_SUFFIX" => format!(".rustpython-{}", MULTIARCH), |
| 21 | + "MULTIARCH" => MULTIARCH, |
| 22 | + // enough for tests to stop expecting urandom() to fail after restricting file resources |
| 23 | + "HAVE_GETRANDOM" => 1, |
| 24 | + } |
| 25 | + include!(concat!(env!("OUT_DIR"), "/env_vars.rs")); |
| 26 | + vars |
| 27 | + } |
23 | 28 | }
|
0 commit comments