-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathlib.rs
More file actions
255 lines (240 loc) · 7.05 KB
/
lib.rs
File metadata and controls
255 lines (240 loc) · 7.05 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
// to allow `mod foo {}` in foo.rs; clippy thinks this is a mistake/misunderstanding of
// how `mod` works, but we want this sometimes for pymodule declarations
#![allow(clippy::module_inception)]
#[macro_use]
extern crate rustpython_derive;
extern crate alloc;
#[macro_use]
pub(crate) mod macros;
mod _asyncio;
mod _remote_debugging;
pub mod array;
mod binascii;
mod bisect;
mod bz2;
mod cmath;
mod compression; // internal module
mod contextvars;
mod csv;
#[cfg(not(any(target_os = "android", target_arch = "wasm32")))]
mod lzma;
mod zlib;
mod blake2;
mod hashlib;
mod md5;
mod sha1;
mod sha256;
mod sha3;
mod sha512;
mod json;
#[cfg(all(
feature = "host_env",
not(any(target_os = "ios", target_arch = "wasm32"))
))]
mod locale;
mod _opcode;
#[path = "_tokenize.rs"]
mod _tokenize;
mod math;
#[cfg(all(feature = "host_env", any(unix, windows)))]
mod mmap;
mod pyexpat;
mod pystruct;
mod random;
mod statistics;
mod suggestions;
// TODO: maybe make this an extension module, if we ever get those
// mod re;
#[cfg(all(feature = "host_env", not(target_arch = "wasm32")))]
pub mod socket;
#[cfg(all(feature = "host_env", unix, not(target_os = "redox")))]
mod syslog;
mod unicodedata;
#[cfg(feature = "host_env")]
mod faulthandler;
#[cfg(all(feature = "host_env", any(unix, target_os = "wasi")))]
mod fcntl;
#[cfg(all(feature = "host_env", not(target_arch = "wasm32")))]
mod multiprocessing;
#[cfg(all(
feature = "host_env",
unix,
not(target_os = "redox"),
not(target_os = "android")
))]
mod posixshmem;
#[cfg(all(feature = "host_env", unix))]
mod posixsubprocess;
// libc is missing constants on redox
#[cfg(all(
feature = "sqlite",
not(any(target_os = "android", target_arch = "wasm32"))
))]
mod _sqlite3;
#[cfg(all(feature = "host_env", windows))]
mod _testconsole;
#[cfg(all(
feature = "host_env",
unix,
not(any(target_os = "android", target_os = "redox"))
))]
mod grp;
#[cfg(all(feature = "host_env", windows))]
mod overlapped;
#[cfg(all(feature = "host_env", unix, not(target_os = "redox")))]
mod resource;
#[cfg(all(feature = "host_env", target_os = "macos"))]
mod scproxy;
#[cfg(all(feature = "host_env", any(unix, windows, target_os = "wasi")))]
mod select;
#[cfg(all(
feature = "host_env",
not(target_arch = "wasm32"),
feature = "ssl-openssl"
))]
mod openssl;
#[cfg(all(
feature = "host_env",
not(target_arch = "wasm32"),
feature = "ssl-rustls"
))]
mod ssl;
#[cfg(all(feature = "ssl-openssl", feature = "ssl-rustls"))]
compile_error!("features \"ssl-openssl\" and \"ssl-rustls\" are mutually exclusive");
#[cfg(all(
feature = "host_env",
unix,
not(target_os = "redox"),
not(target_os = "ios")
))]
mod termios;
#[cfg(all(
feature = "host_env",
not(any(
target_os = "android",
target_os = "ios",
target_os = "windows",
target_arch = "wasm32",
target_os = "redox",
))
))]
mod uuid;
#[cfg(all(feature = "host_env", feature = "tkinter"))]
mod tkinter;
use rustpython_common as common;
use rustpython_vm as vm;
use crate::vm::{Context, builtins};
/// Returns module definitions for multi-phase init modules.
/// These modules are added to sys.modules BEFORE their exec function runs,
/// allowing safe circular imports.
pub fn stdlib_module_defs(ctx: &Context) -> Vec<&'static builtins::PyModuleDef> {
vec![
_asyncio::module_def(ctx),
_opcode::module_def(ctx),
_remote_debugging::module_def(ctx),
array::module_def(ctx),
binascii::module_def(ctx),
bisect::module_def(ctx),
blake2::module_def(ctx),
bz2::module_def(ctx),
cmath::module_def(ctx),
contextvars::module_def(ctx),
csv::module_def(ctx),
#[cfg(feature = "host_env")]
faulthandler::module_def(ctx),
#[cfg(all(feature = "host_env", any(unix, target_os = "wasi")))]
fcntl::module_def(ctx),
#[cfg(all(
feature = "host_env",
unix,
not(any(target_os = "android", target_os = "redox"))
))]
grp::module_def(ctx),
hashlib::module_def(ctx),
json::module_def(ctx),
#[cfg(all(
feature = "host_env",
not(any(target_os = "ios", target_arch = "wasm32"))
))]
locale::module_def(ctx),
#[cfg(not(any(target_os = "android", target_arch = "wasm32")))]
lzma::module_def(ctx),
math::module_def(ctx),
md5::module_def(ctx),
#[cfg(all(feature = "host_env", any(unix, windows)))]
mmap::module_def(ctx),
#[cfg(all(feature = "host_env", not(target_arch = "wasm32")))]
multiprocessing::module_def(ctx),
#[cfg(all(
feature = "host_env",
not(target_arch = "wasm32"),
feature = "ssl-openssl"
))]
openssl::module_def(ctx),
#[cfg(all(feature = "host_env", windows))]
_testconsole::module_def(ctx),
#[cfg(all(feature = "host_env", windows))]
overlapped::module_def(ctx),
#[cfg(all(feature = "host_env", unix))]
posixsubprocess::module_def(ctx),
#[cfg(all(
feature = "host_env",
unix,
not(target_os = "redox"),
not(target_os = "android")
))]
posixshmem::module_def(ctx),
pyexpat::module_def(ctx),
pystruct::module_def(ctx),
random::module_def(ctx),
#[cfg(all(feature = "host_env", unix, not(target_os = "redox")))]
resource::module_def(ctx),
#[cfg(all(feature = "host_env", target_os = "macos"))]
scproxy::module_def(ctx),
#[cfg(all(feature = "host_env", any(unix, windows, target_os = "wasi")))]
select::module_def(ctx),
sha1::module_def(ctx),
sha256::module_def(ctx),
sha3::module_def(ctx),
sha512::module_def(ctx),
#[cfg(all(feature = "host_env", not(target_arch = "wasm32")))]
socket::module_def(ctx),
#[cfg(all(
feature = "sqlite",
not(any(target_os = "android", target_arch = "wasm32"))
))]
_sqlite3::module_def(ctx),
#[cfg(all(
feature = "host_env",
not(target_arch = "wasm32"),
feature = "ssl-rustls"
))]
ssl::module_def(ctx),
statistics::module_def(ctx),
suggestions::module_def(ctx),
_tokenize::module_def(ctx),
#[cfg(all(feature = "host_env", unix, not(target_os = "redox")))]
syslog::module_def(ctx),
#[cfg(all(
feature = "host_env",
unix,
not(any(target_os = "ios", target_os = "redox"))
))]
termios::module_def(ctx),
#[cfg(all(feature = "host_env", feature = "tkinter"))]
tkinter::module_def(ctx),
unicodedata::module_def(ctx),
#[cfg(all(
feature = "host_env",
not(any(
target_os = "android",
target_os = "ios",
target_os = "windows",
target_arch = "wasm32",
target_os = "redox"
))
))]
uuid::module_def(ctx),
zlib::module_def(ctx),
]
}