@@ -7,7 +7,6 @@ extern crate log;
7
7
extern crate rustpython_parser;
8
8
extern crate rustpython_vm;
9
9
extern crate rustyline;
10
- extern crate xdg;
11
10
12
11
use clap:: { App , Arg } ;
13
12
use rustpython_parser:: parser;
@@ -143,6 +142,23 @@ fn shell_exec(vm: &mut VirtualMachine, source: &str, scope: PyObjectRef) -> bool
143
142
true
144
143
}
145
144
145
+ #[ cfg( target_family = "windows" ) ]
146
+ fn get_history_path ( ) -> String {
147
+ //
148
+ String :: from ( ".repl_history.txt" )
149
+ }
150
+
151
+ #[ cfg( target_family = "unix" ) ]
152
+ fn get_history_path ( ) -> String {
153
+ //work around for windows dependent builds. The xdg crate is unix specific
154
+ //so access to the BaseDirectories struct breaks builds on python.
155
+ extern crate xdg;
156
+
157
+ let xdg_dirs = xdg:: BaseDirectories :: with_prefix ( "rustpython" ) . unwrap ( ) ;
158
+ let repl_history_path = xdg_dirs. place_cache_file ( "repl_history.txt" ) . unwrap ( ) ;
159
+ repl_history_path. to_str ( ) . unwrap ( )
160
+ }
161
+
146
162
fn run_shell ( vm : & mut VirtualMachine ) -> PyResult {
147
163
println ! (
148
164
"Welcome to the magnificent Rust Python {} interpreter" ,
@@ -155,9 +171,8 @@ fn run_shell(vm: &mut VirtualMachine) -> PyResult {
155
171
let mut input = String :: new ( ) ;
156
172
let mut rl = Editor :: < ( ) > :: new ( ) ;
157
173
158
- let xdg_dirs = xdg:: BaseDirectories :: with_prefix ( "rustpython" ) . unwrap ( ) ;
159
- let repl_history_path = xdg_dirs. place_cache_file ( "repl_history.txt" ) . unwrap ( ) ;
160
- let repl_history_path_str = repl_history_path. to_str ( ) . unwrap ( ) ;
174
+ //retrieve a history_path_str dependent to the os
175
+ let repl_history_path_str = & get_history_path ( ) ;
161
176
if rl. load_history ( repl_history_path_str) . is_err ( ) {
162
177
println ! ( "No previous history." ) ;
163
178
}
0 commit comments