Skip to content

Commit e20adb3

Browse files
committed
Use BUILDTIME_RUSTPYTHONPATH env variable
1 parent 0d6c536 commit e20adb3

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

redox_recipe.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
GIT=https://github.com/RustPython/RustPython
22
BRANCH=redox
33
CARGOFLAGS=--no-default-features
4+
export BUILDTIME_RUSTPYTHONPATH=/lib/rustpython/
45

56
function recipe_stage() {
67
dest="$(realpath "$1")"

src/main.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,22 @@ fn main() {
6969
let res = (|| {
7070
import::init_importlib(&vm, true)?;
7171

72-
if cfg!(target_os = "redox") {
72+
if let Some(paths) = option_env!("BUILDTIME_RUSTPYTHONPATH") {
7373
let sys_path = vm.get_attribute(vm.sys_module.clone(), "path")?;
74-
vm.call_method(
75-
&sys_path,
76-
"insert",
77-
vec![
78-
vm.ctx.new_int(0),
79-
vm.ctx.new_str("/lib/rustpython/".to_string()),
80-
],
81-
)?;
74+
for (i, path) in std::env::split_paths(paths).enumerate() {
75+
vm.call_method(
76+
&sys_path,
77+
"insert",
78+
vec![
79+
vm.ctx.new_int(i),
80+
vm.ctx.new_str(
81+
path.into_os_string()
82+
.into_string()
83+
.expect("Invalid UTF8 in BUILDTIME_RUSTPYTHONPATH"),
84+
),
85+
],
86+
)?;
87+
}
8288
}
8389

8490
// Figure out if a -c option was given:

0 commit comments

Comments
 (0)