forked from RustPython/RustPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrozen.rs
More file actions
43 lines (38 loc) · 1.32 KB
/
frozen.rs
File metadata and controls
43 lines (38 loc) · 1.32 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
use crate::bytecode::FrozenModule;
pub fn core_frozen_inits() -> impl Iterator<Item = (String, FrozenModule)> {
let iter = std::iter::empty();
macro_rules! ext_modules {
($iter:ident, ($modules:expr)) => {
let $iter = $iter.chain($modules);
};
($iter:ident, $($t:tt)*) => {
ext_modules!($iter, (py_freeze!($($t)*)))
};
}
ext_modules!(
iter,
source = "initialized = True; print(\"Hello world!\")\n",
module_name = "__hello__",
);
// Python modules that the vm calls into, but are not actually part of the stdlib. They could
// in theory be implemented in Rust, but are easiest to do in Python for one reason or another.
// Includes _importlib_bootstrap and _importlib_bootstrap_external
ext_modules!(
iter,
(rustpython_derive::py_freeze!(
dir = "./Lib/python_builtins",
crate_name = "rustpython_compiler_core"
))
);
// core stdlib Python modules that the vm calls into, but are still used in Python
// application code, e.g. copyreg
#[cfg(not(feature = "freeze-stdlib"))]
ext_modules!(
iter,
(rustpython_derive::py_freeze!(
dir = "./Lib/core_modules",
crate_name = "rustpython_compiler_core"
))
);
iter
}