Skip to main content

rustpython_vm/stdlib/
mod.rs

1mod _abc;
2#[cfg(feature = "ast")]
3pub(crate) mod _ast;
4mod _codecs;
5mod _collections;
6mod _functools;
7mod _imp;
8pub mod _io;
9mod _operator;
10mod _sre;
11mod _stat;
12mod _string;
13#[cfg(feature = "compiler")]
14mod _symtable;
15mod _sysconfig;
16mod _sysconfigdata;
17mod _types;
18pub mod _typing;
19pub mod _warnings;
20mod _weakref;
21pub mod atexit;
22pub mod builtins;
23pub mod errno;
24mod gc;
25mod itertools;
26mod marshal;
27pub mod time;
28mod typevar;
29
30#[cfg(feature = "host_env")]
31#[macro_use]
32pub mod os;
33#[cfg(all(feature = "host_env", windows))]
34pub mod nt;
35#[cfg(all(feature = "host_env", unix))]
36pub mod posix;
37#[cfg(all(feature = "host_env", not(any(unix, windows))))]
38#[path = "posix_compat.rs"]
39pub mod posix;
40
41#[cfg(all(
42    feature = "host_env",
43    any(
44        target_os = "linux",
45        target_os = "macos",
46        target_os = "windows",
47        target_os = "android"
48    ),
49    not(any(target_env = "musl", target_env = "sgx"))
50))]
51mod _ctypes;
52#[cfg(all(feature = "host_env", windows))]
53pub(crate) mod msvcrt;
54
55#[cfg(all(
56    feature = "host_env",
57    unix,
58    not(any(target_os = "ios", target_os = "wasi", target_os = "redox"))
59))]
60mod pwd;
61
62#[cfg(feature = "host_env")]
63pub(crate) mod _signal;
64#[cfg(feature = "threading")]
65pub mod _thread;
66#[cfg(all(feature = "host_env", windows))]
67mod _wmi;
68pub mod sys;
69#[cfg(all(feature = "host_env", windows))]
70#[path = "_winapi.rs"]
71mod winapi;
72#[cfg(all(feature = "host_env", windows))]
73mod winreg;
74#[cfg(all(feature = "host_env", windows))]
75mod winsound;
76
77use crate::{Context, builtins::PyModuleDef};
78
79/// Returns module definitions for multi-phase init modules.
80///
81/// These modules use multi-phase initialization pattern:
82/// 1. Create module from def and add to sys.modules
83/// 2. Call exec slot (can safely import other modules without circular import issues)
84pub fn builtin_module_defs(ctx: &Context) -> Vec<&'static PyModuleDef> {
85    vec![
86        _abc::module_def(ctx),
87        _types::module_def(ctx),
88        #[cfg(feature = "ast")]
89        _ast::module_def(ctx),
90        atexit::module_def(ctx),
91        _codecs::module_def(ctx),
92        _collections::module_def(ctx),
93        #[cfg(all(
94            feature = "host_env",
95            any(
96                target_os = "linux",
97                target_os = "macos",
98                target_os = "windows",
99                target_os = "android"
100            ),
101            not(any(target_env = "musl", target_env = "sgx"))
102        ))]
103        _ctypes::module_def(ctx),
104        errno::module_def(ctx),
105        _functools::module_def(ctx),
106        gc::module_def(ctx),
107        _imp::module_def(ctx),
108        _io::module_def(ctx),
109        itertools::module_def(ctx),
110        marshal::module_def(ctx),
111        #[cfg(all(feature = "host_env", windows))]
112        msvcrt::module_def(ctx),
113        #[cfg(all(feature = "host_env", windows))]
114        nt::module_def(ctx),
115        _operator::module_def(ctx),
116        #[cfg(all(feature = "host_env", any(unix, target_os = "wasi")))]
117        posix::module_def(ctx),
118        #[cfg(all(feature = "host_env", not(any(unix, windows, target_os = "wasi"))))]
119        posix::module_def(ctx),
120        #[cfg(all(
121            feature = "host_env",
122            unix,
123            not(any(target_os = "ios", target_os = "wasi", target_os = "redox"))
124        ))]
125        pwd::module_def(ctx),
126        #[cfg(feature = "host_env")]
127        _signal::module_def(ctx),
128        _sre::module_def(ctx),
129        _stat::module_def(ctx),
130        _string::module_def(ctx),
131        #[cfg(feature = "compiler")]
132        _symtable::module_def(ctx),
133        _sysconfigdata::module_def(ctx),
134        _sysconfig::module_def(ctx),
135        #[cfg(feature = "threading")]
136        _thread::module_def(ctx),
137        time::module_def(ctx),
138        _typing::module_def(ctx),
139        _warnings::module_def(ctx),
140        _weakref::module_def(ctx),
141        #[cfg(all(feature = "host_env", windows))]
142        winapi::module_def(ctx),
143        #[cfg(all(feature = "host_env", windows))]
144        winreg::module_def(ctx),
145        #[cfg(all(feature = "host_env", windows))]
146        winsound::module_def(ctx),
147        #[cfg(all(feature = "host_env", windows))]
148        _wmi::module_def(ctx),
149    ]
150}