1#![allow(clippy::module_inception)]
5
6#[macro_use]
7extern crate rustpython_derive;
8extern crate alloc;
9
10#[macro_use]
11pub(crate) mod macros;
12
13mod _asyncio;
14mod _remote_debugging;
15pub mod array;
16mod binascii;
17mod bisect;
18mod bz2;
19mod cmath;
20mod compression; mod contextvars;
22mod csv;
23#[cfg(not(any(target_os = "android", target_arch = "wasm32")))]
24mod lzma;
25mod zlib;
26
27mod blake2;
28mod hashlib;
29mod md5;
30mod sha1;
31mod sha256;
32mod sha3;
33mod sha512;
34
35mod json;
36
37#[cfg(all(
38 feature = "host_env",
39 not(any(target_os = "ios", target_arch = "wasm32"))
40))]
41mod locale;
42
43mod _opcode;
44#[path = "_tokenize.rs"]
45mod _tokenize;
46mod math;
47#[cfg(all(feature = "host_env", any(unix, windows)))]
48mod mmap;
49mod pyexpat;
50mod pystruct;
51mod random;
52mod statistics;
53mod suggestions;
54#[cfg(all(feature = "host_env", not(target_arch = "wasm32")))]
57pub mod socket;
58#[cfg(all(feature = "host_env", unix, not(target_os = "redox")))]
59mod syslog;
60mod unicodedata;
61
62#[cfg(feature = "host_env")]
63mod faulthandler;
64#[cfg(all(feature = "host_env", any(unix, target_os = "wasi")))]
65mod fcntl;
66#[cfg(all(feature = "host_env", not(target_arch = "wasm32")))]
67mod multiprocessing;
68#[cfg(all(
69 feature = "host_env",
70 unix,
71 not(target_os = "redox"),
72 not(target_os = "android")
73))]
74mod posixshmem;
75#[cfg(all(feature = "host_env", unix))]
76mod posixsubprocess;
77#[cfg(all(
79 feature = "sqlite",
80 not(any(target_os = "android", target_arch = "wasm32"))
81))]
82mod _sqlite3;
83#[cfg(all(feature = "host_env", windows))]
84mod _testconsole;
85#[cfg(all(
86 feature = "host_env",
87 unix,
88 not(any(target_os = "android", target_os = "redox"))
89))]
90mod grp;
91#[cfg(all(feature = "host_env", windows))]
92mod overlapped;
93#[cfg(all(feature = "host_env", unix, not(target_os = "redox")))]
94mod resource;
95#[cfg(all(feature = "host_env", target_os = "macos"))]
96mod scproxy;
97#[cfg(all(feature = "host_env", any(unix, windows, target_os = "wasi")))]
98mod select;
99
100#[cfg(all(
101 feature = "host_env",
102 not(target_arch = "wasm32"),
103 feature = "ssl-openssl"
104))]
105mod openssl;
106#[cfg(all(
107 feature = "host_env",
108 not(target_arch = "wasm32"),
109 feature = "ssl-rustls"
110))]
111mod ssl;
112#[cfg(all(feature = "ssl-openssl", feature = "ssl-rustls"))]
113compile_error!("features \"ssl-openssl\" and \"ssl-rustls\" are mutually exclusive");
114
115#[cfg(all(
116 feature = "host_env",
117 unix,
118 not(target_os = "redox"),
119 not(target_os = "ios")
120))]
121mod termios;
122#[cfg(all(
123 feature = "host_env",
124 not(any(
125 target_os = "android",
126 target_os = "ios",
127 target_os = "windows",
128 target_arch = "wasm32",
129 target_os = "redox",
130 ))
131))]
132mod uuid;
133
134#[cfg(all(feature = "host_env", feature = "tkinter"))]
135mod tkinter;
136
137use rustpython_common as common;
138use rustpython_vm as vm;
139
140use crate::vm::{Context, builtins};
141
142pub fn stdlib_module_defs(ctx: &Context) -> Vec<&'static builtins::PyModuleDef> {
146 vec![
147 _asyncio::module_def(ctx),
148 _opcode::module_def(ctx),
149 _remote_debugging::module_def(ctx),
150 array::module_def(ctx),
151 binascii::module_def(ctx),
152 bisect::module_def(ctx),
153 blake2::module_def(ctx),
154 bz2::module_def(ctx),
155 cmath::module_def(ctx),
156 contextvars::module_def(ctx),
157 csv::module_def(ctx),
158 #[cfg(feature = "host_env")]
159 faulthandler::module_def(ctx),
160 #[cfg(all(feature = "host_env", any(unix, target_os = "wasi")))]
161 fcntl::module_def(ctx),
162 #[cfg(all(
163 feature = "host_env",
164 unix,
165 not(any(target_os = "android", target_os = "redox"))
166 ))]
167 grp::module_def(ctx),
168 hashlib::module_def(ctx),
169 json::module_def(ctx),
170 #[cfg(all(
171 feature = "host_env",
172 not(any(target_os = "ios", target_arch = "wasm32"))
173 ))]
174 locale::module_def(ctx),
175 #[cfg(not(any(target_os = "android", target_arch = "wasm32")))]
176 lzma::module_def(ctx),
177 math::module_def(ctx),
178 md5::module_def(ctx),
179 #[cfg(all(feature = "host_env", any(unix, windows)))]
180 mmap::module_def(ctx),
181 #[cfg(all(feature = "host_env", not(target_arch = "wasm32")))]
182 multiprocessing::module_def(ctx),
183 #[cfg(all(
184 feature = "host_env",
185 not(target_arch = "wasm32"),
186 feature = "ssl-openssl"
187 ))]
188 openssl::module_def(ctx),
189 #[cfg(all(feature = "host_env", windows))]
190 _testconsole::module_def(ctx),
191 #[cfg(all(feature = "host_env", windows))]
192 overlapped::module_def(ctx),
193 #[cfg(all(feature = "host_env", unix))]
194 posixsubprocess::module_def(ctx),
195 #[cfg(all(
196 feature = "host_env",
197 unix,
198 not(target_os = "redox"),
199 not(target_os = "android")
200 ))]
201 posixshmem::module_def(ctx),
202 pyexpat::module_def(ctx),
203 pystruct::module_def(ctx),
204 random::module_def(ctx),
205 #[cfg(all(feature = "host_env", unix, not(target_os = "redox")))]
206 resource::module_def(ctx),
207 #[cfg(all(feature = "host_env", target_os = "macos"))]
208 scproxy::module_def(ctx),
209 #[cfg(all(feature = "host_env", any(unix, windows, target_os = "wasi")))]
210 select::module_def(ctx),
211 sha1::module_def(ctx),
212 sha256::module_def(ctx),
213 sha3::module_def(ctx),
214 sha512::module_def(ctx),
215 #[cfg(all(feature = "host_env", not(target_arch = "wasm32")))]
216 socket::module_def(ctx),
217 #[cfg(all(
218 feature = "sqlite",
219 not(any(target_os = "android", target_arch = "wasm32"))
220 ))]
221 _sqlite3::module_def(ctx),
222 #[cfg(all(
223 feature = "host_env",
224 not(target_arch = "wasm32"),
225 feature = "ssl-rustls"
226 ))]
227 ssl::module_def(ctx),
228 statistics::module_def(ctx),
229 suggestions::module_def(ctx),
230 _tokenize::module_def(ctx),
231 #[cfg(all(feature = "host_env", unix, not(target_os = "redox")))]
232 syslog::module_def(ctx),
233 #[cfg(all(
234 feature = "host_env",
235 unix,
236 not(any(target_os = "ios", target_os = "redox"))
237 ))]
238 termios::module_def(ctx),
239 #[cfg(all(feature = "host_env", feature = "tkinter"))]
240 tkinter::module_def(ctx),
241 unicodedata::module_def(ctx),
242 #[cfg(all(
243 feature = "host_env",
244 not(any(
245 target_os = "android",
246 target_os = "ios",
247 target_os = "windows",
248 target_arch = "wasm32",
249 target_os = "redox"
250 ))
251 ))]
252 uuid::module_def(ctx),
253 zlib::module_def(ctx),
254 ]
255}