Skip to main content

rustpython_vm/stdlib/
mod.rs

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