@@ -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,22 @@ fn shell_exec(vm: &mut VirtualMachine, source: &str, scope: PyObjectRef) -> bool
143
142
true
144
143
}
145
144
145
+ #[ cfg( not( target_family = "unix" ) ) ]
146
+ fn get_history_path ( ) -> PathBuf {
147
+ //Path buffer
148
+ PathBuf :: from ( ".repl_history.txt" )
149
+ }
150
+
151
+ #[ cfg( target_family = "unix" ) ]
152
+ fn get_history_path ( ) -> PathBuf {
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
+ xdg_dirs. place_cache_file ( "repl_history.txt" ) . unwrap ( )
159
+ }
160
+
146
161
fn run_shell ( vm : & mut VirtualMachine ) -> PyResult {
147
162
println ! (
148
163
"Welcome to the magnificent Rust Python {} interpreter" ,
@@ -155,9 +170,8 @@ fn run_shell(vm: &mut VirtualMachine) -> PyResult {
155
170
let mut input = String :: new ( ) ;
156
171
let mut rl = Editor :: < ( ) > :: new ( ) ;
157
172
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 ( ) ;
173
+ //retrieve a history_path_str dependent to the os
174
+ let repl_history_path_str = & get_history_path ( ) ;
161
175
if rl. load_history ( repl_history_path_str) . is_err ( ) {
162
176
println ! ( "No previous history." ) ;
163
177
}
0 commit comments