Skip to content

Commit 126e99a

Browse files
committed
fix for #8 on windows
1 parent 3bafda9 commit 126e99a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,18 @@ fn cleanup_path_for_python(path: &PathBuf) -> String {
8686
.replace("\\", "/")
8787
}
8888

89+
fn print_path_for_python(path: &PathBuf) -> String {
90+
#[cfg(not(target_os = "windows"))] {
91+
format!("\"{}\"", cleanup_path_for_python(path))
92+
}
93+
#[cfg(target_os = "windows")] {
94+
format!("r\"{}\"", cleanup_path_for_python(path))
95+
}
96+
}
97+
8998
fn init_python(code: String, dir: PathBuf) {
9099
#[allow(unused_mut)]
91-
let mut sys_pyth_dir = vec![format!("\"{}\"", cleanup_path_for_python(&dir))];
100+
let mut sys_pyth_dir = vec![print_path_for_python(&dir)];
92101
#[cfg(feature = "venv")]
93102
{
94103
let venv_dir = dir.join(".venv").join("lib");
@@ -99,7 +108,7 @@ fn init_python(code: String, dir: PathBuf) {
99108
// use first folder with site-packages for venv, ignore venv version
100109
if Path::exists(site_packages.as_path()) {
101110
sys_pyth_dir
102-
.push(format!("\"{}\"", cleanup_path_for_python(&site_packages)));
111+
.push(print_path_for_python(&site_packages));
103112
break;
104113
}
105114
}

0 commit comments

Comments
 (0)