@@ -34,12 +34,15 @@ mod sha512;
3434
3535mod json;
3636
37- #[ cfg( not( any( target_os = "ios" , target_arch = "wasm32" ) ) ) ]
37+ #[ cfg( all(
38+ feature = "host_env" ,
39+ not( any( target_os = "ios" , target_arch = "wasm32" ) )
40+ ) ) ]
3841mod locale;
3942
4043mod _opcode;
4144mod math;
42- #[ cfg( any( unix, windows) ) ]
45+ #[ cfg( all ( feature = "host_env" , any( unix, windows) ) ) ]
4346mod mmap;
4447mod pyexpat;
4548mod pystruct;
@@ -48,57 +51,83 @@ mod statistics;
4851mod suggestions;
4952// TODO: maybe make this an extension module, if we ever get those
5053// mod re;
51- #[ cfg( not( target_arch = "wasm32" ) ) ]
54+ #[ cfg( all ( feature = "host_env" , not( target_arch = "wasm32" ) ) ) ]
5255pub mod socket;
53- #[ cfg( all( unix, not( target_os = "redox" ) ) ) ]
56+ #[ cfg( all( feature = "host_env" , unix, not( target_os = "redox" ) ) ) ]
5457mod syslog;
5558mod unicodedata;
5659
60+ #[ cfg( feature = "host_env" ) ]
5761mod faulthandler;
58- #[ cfg( any( unix, target_os = "wasi" ) ) ]
62+ #[ cfg( all ( feature = "host_env" , any( unix, target_os = "wasi" ) ) ) ]
5963mod fcntl;
60- #[ cfg( not( target_arch = "wasm32" ) ) ]
64+ #[ cfg( all ( feature = "host_env" , not( target_arch = "wasm32" ) ) ) ]
6165mod multiprocessing;
62- #[ cfg( all( unix, not( target_os = "redox" ) , not( target_os = "android" ) ) ) ]
66+ #[ cfg( all(
67+ feature = "host_env" ,
68+ unix,
69+ not( target_os = "redox" ) ,
70+ not( target_os = "android" )
71+ ) ) ]
6372mod posixshmem;
64- #[ cfg( unix) ]
73+ #[ cfg( all ( feature = "host_env" , unix) ) ]
6574mod posixsubprocess;
6675// libc is missing constants on redox
6776#[ cfg( all(
6877 feature = "sqlite" ,
6978 not( any( target_os = "android" , target_arch = "wasm32" ) )
7079) ) ]
7180mod _sqlite3;
72- #[ cfg( all( unix, not( any( target_os = "android" , target_os = "redox" ) ) ) ) ]
81+ #[ cfg( all(
82+ feature = "host_env" ,
83+ unix,
84+ not( any( target_os = "android" , target_os = "redox" ) )
85+ ) ) ]
7386mod grp;
74- #[ cfg( windows) ]
87+ #[ cfg( all ( feature = "host_env" , windows) ) ]
7588mod overlapped;
76- #[ cfg( all( unix, not( target_os = "redox" ) ) ) ]
89+ #[ cfg( all( feature = "host_env" , unix, not( target_os = "redox" ) ) ) ]
7790mod resource;
78- #[ cfg( target_os = "macos" ) ]
91+ #[ cfg( all( feature = "host_env" , target_os = "macos" ) ) ]
7992mod scproxy;
80- #[ cfg( any( unix, windows, target_os = "wasi" ) ) ]
93+ #[ cfg( all ( feature = "host_env" , any( unix, windows, target_os = "wasi" ) ) ) ]
8194mod select;
8295
83- #[ cfg( all( not( target_arch = "wasm32" ) , feature = "ssl-openssl" ) ) ]
96+ #[ cfg( all(
97+ feature = "host_env" ,
98+ not( target_arch = "wasm32" ) ,
99+ feature = "ssl-openssl"
100+ ) ) ]
84101mod openssl;
85- #[ cfg( all( not( target_arch = "wasm32" ) , feature = "ssl-rustls" ) ) ]
102+ #[ cfg( all(
103+ feature = "host_env" ,
104+ not( target_arch = "wasm32" ) ,
105+ feature = "ssl-rustls"
106+ ) ) ]
86107mod ssl;
87108#[ cfg( all( feature = "ssl-openssl" , feature = "ssl-rustls" ) ) ]
88109compile_error ! ( "features \" ssl-openssl\" and \" ssl-rustls\" are mutually exclusive" ) ;
89110
90- #[ cfg( all( unix, not( target_os = "redox" ) , not( target_os = "ios" ) ) ) ]
111+ #[ cfg( all(
112+ feature = "host_env" ,
113+ unix,
114+ not( target_os = "redox" ) ,
115+ not( target_os = "ios" )
116+ ) ) ]
91117mod termios;
92- #[ cfg( not( any(
93- target_os = "android" ,
94- target_os = "ios" ,
95- target_os = "windows" ,
96- target_arch = "wasm32" ,
97- target_os = "redox" ,
98- ) ) ) ]
118+ #[ cfg( all(
119+ feature = "host_env" ,
120+ not( any(
121+ target_os = "android" ,
122+ target_os = "ios" ,
123+ target_os = "windows" ,
124+ target_arch = "wasm32" ,
125+ target_os = "redox" ,
126+ ) )
127+ ) ) ]
99128mod uuid;
100129
101- #[ cfg( feature = "tkinter" ) ]
130+ #[ cfg( all ( feature = "host_env" , feature = " tkinter") ) ]
102131mod tkinter;
103132
104133use rustpython_common as common;
@@ -122,69 +151,97 @@ pub fn stdlib_module_defs(ctx: &Context) -> Vec<&'static builtins::PyModuleDef>
122151 cmath:: module_def( ctx) ,
123152 contextvars:: module_def( ctx) ,
124153 csv:: module_def( ctx) ,
154+ #[ cfg( feature = "host_env" ) ]
125155 faulthandler:: module_def( ctx) ,
126- #[ cfg( any( unix, target_os = "wasi" ) ) ]
156+ #[ cfg( all ( feature = "host_env" , any( unix, target_os = "wasi" ) ) ) ]
127157 fcntl:: module_def( ctx) ,
128- #[ cfg( all( unix, not( any( target_os = "android" , target_os = "redox" ) ) ) ) ]
158+ #[ cfg( all(
159+ feature = "host_env" ,
160+ unix,
161+ not( any( target_os = "android" , target_os = "redox" ) )
162+ ) ) ]
129163 grp:: module_def( ctx) ,
130164 hashlib:: module_def( ctx) ,
131165 json:: module_def( ctx) ,
132- #[ cfg( not( any( target_os = "ios" , target_arch = "wasm32" ) ) ) ]
166+ #[ cfg( all(
167+ feature = "host_env" ,
168+ not( any( target_os = "ios" , target_arch = "wasm32" ) )
169+ ) ) ]
133170 locale:: module_def( ctx) ,
134171 #[ cfg( not( any( target_os = "android" , target_arch = "wasm32" ) ) ) ]
135172 lzma:: module_def( ctx) ,
136173 math:: module_def( ctx) ,
137174 md5:: module_def( ctx) ,
138- #[ cfg( any( unix, windows) ) ]
175+ #[ cfg( all ( feature = "host_env" , any( unix, windows) ) ) ]
139176 mmap:: module_def( ctx) ,
140- #[ cfg( not( target_arch = "wasm32" ) ) ]
177+ #[ cfg( all ( feature = "host_env" , not( target_arch = "wasm32" ) ) ) ]
141178 multiprocessing:: module_def( ctx) ,
142- #[ cfg( all( not( target_arch = "wasm32" ) , feature = "ssl-openssl" ) ) ]
179+ #[ cfg( all(
180+ feature = "host_env" ,
181+ not( target_arch = "wasm32" ) ,
182+ feature = "ssl-openssl"
183+ ) ) ]
143184 openssl:: module_def( ctx) ,
144- #[ cfg( windows) ]
185+ #[ cfg( all ( feature = "host_env" , windows) ) ]
145186 overlapped:: module_def( ctx) ,
146- #[ cfg( unix) ]
187+ #[ cfg( all ( feature = "host_env" , unix) ) ]
147188 posixsubprocess:: module_def( ctx) ,
148- #[ cfg( all( unix, not( target_os = "redox" ) , not( target_os = "android" ) ) ) ]
189+ #[ cfg( all(
190+ feature = "host_env" ,
191+ unix,
192+ not( target_os = "redox" ) ,
193+ not( target_os = "android" )
194+ ) ) ]
149195 posixshmem:: module_def( ctx) ,
150196 pyexpat:: module_def( ctx) ,
151197 pystruct:: module_def( ctx) ,
152198 random:: module_def( ctx) ,
153- #[ cfg( all( unix, not( target_os = "redox" ) ) ) ]
199+ #[ cfg( all( feature = "host_env" , unix, not( target_os = "redox" ) ) ) ]
154200 resource:: module_def( ctx) ,
155- #[ cfg( target_os = "macos" ) ]
201+ #[ cfg( all ( feature = "host_env" , target_os = "macos" ) ) ]
156202 scproxy:: module_def( ctx) ,
157- #[ cfg( any( unix, windows, target_os = "wasi" ) ) ]
203+ #[ cfg( all ( feature = "host_env" , any( unix, windows, target_os = "wasi" ) ) ) ]
158204 select:: module_def( ctx) ,
159205 sha1:: module_def( ctx) ,
160206 sha256:: module_def( ctx) ,
161207 sha3:: module_def( ctx) ,
162208 sha512:: module_def( ctx) ,
163- #[ cfg( not( target_arch = "wasm32" ) ) ]
209+ #[ cfg( all ( feature = "host_env" , not( target_arch = "wasm32" ) ) ) ]
164210 socket:: module_def( ctx) ,
165211 #[ cfg( all(
166212 feature = "sqlite" ,
167213 not( any( target_os = "android" , target_arch = "wasm32" ) )
168214 ) ) ]
169215 _sqlite3:: module_def( ctx) ,
170- #[ cfg( all( not( target_arch = "wasm32" ) , feature = "ssl-rustls" ) ) ]
216+ #[ cfg( all(
217+ feature = "host_env" ,
218+ not( target_arch = "wasm32" ) ,
219+ feature = "ssl-rustls"
220+ ) ) ]
171221 ssl:: module_def( ctx) ,
172222 statistics:: module_def( ctx) ,
173223 suggestions:: module_def( ctx) ,
174- #[ cfg( all( unix, not( target_os = "redox" ) ) ) ]
224+ #[ cfg( all( feature = "host_env" , unix, not( target_os = "redox" ) ) ) ]
175225 syslog:: module_def( ctx) ,
176- #[ cfg( all( unix, not( any( target_os = "ios" , target_os = "redox" ) ) ) ) ]
226+ #[ cfg( all(
227+ feature = "host_env" ,
228+ unix,
229+ not( any( target_os = "ios" , target_os = "redox" ) )
230+ ) ) ]
177231 termios:: module_def( ctx) ,
178- #[ cfg( feature = "tkinter" ) ]
232+ #[ cfg( all ( feature = "host_env" , feature = " tkinter") ) ]
179233 tkinter:: module_def( ctx) ,
180234 unicodedata:: module_def( ctx) ,
181- #[ cfg( not( any(
182- target_os = "android" ,
183- target_os = "ios" ,
184- target_os = "windows" ,
185- target_arch = "wasm32" ,
186- target_os = "redox"
187- ) ) ) ]
235+ #[ cfg( all(
236+ feature = "host_env" ,
237+ not( any(
238+ target_os = "android" ,
239+ target_os = "ios" ,
240+ target_os = "windows" ,
241+ target_arch = "wasm32" ,
242+ target_os = "redox"
243+ ) )
244+ ) ) ]
188245 uuid:: module_def( ctx) ,
189246 zlib:: module_def( ctx) ,
190247 ]
0 commit comments