Skip to content

Commit cecdefb

Browse files
Copilotyouknowone
andauthored
fix: resolve latest host env ci regressions
Agent-Logs-Url: https://github.com/RustPython/RustPython/sessions/899eb717-ebc6-4a4a-870c-2a15c5f33e02 Co-authored-by: youknowone <[email protected]>
1 parent 9b606c9 commit cecdefb

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

crates/host_env/src/os.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ pub fn vars_os() -> env::VarsOs {
4848
env::vars_os()
4949
}
5050

51+
pub fn vars() -> env::Vars {
52+
env::vars()
53+
}
54+
5155
/// # Safety
5256
/// The caller must ensure no other threads can concurrently read or write
5357
/// the process environment while this mutation is performed.

crates/vm/src/getpath.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ fn get_executable_path() -> Option<PathBuf> {
370370
}
371371

372372
/// Parse pyvenv.cfg and extract the 'home' key value
373+
#[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
373374
fn parse_pyvenv_home(pyvenv_cfg: &Path) -> Option<String> {
374375
let content = crate::host_env::fs::read_to_string(pyvenv_cfg).ok()?;
375376

@@ -384,6 +385,11 @@ fn parse_pyvenv_home(pyvenv_cfg: &Path) -> Option<String> {
384385
None
385386
}
386387

388+
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
389+
fn parse_pyvenv_home(_pyvenv_cfg: &Path) -> Option<String> {
390+
None
391+
}
392+
387393
#[cfg(test)]
388394
mod tests {
389395
use super::*;

crates/vm/src/stdlib/nt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub(crate) mod module {
2222
use rustpython_common::wtf8::Wtf8Buf;
2323
use rustpython_host_env::nt as host_nt;
2424
use std::os::windows::io::AsRawHandle;
25-
use std::{env, io, os::windows::ffi::OsStringExt};
25+
use std::{io, os::windows::ffi::OsStringExt};
2626
use windows_sys::Win32::{
2727
Foundation::{self, INVALID_HANDLE_VALUE},
2828
Storage::FileSystem,
@@ -236,7 +236,7 @@ pub(crate) mod module {
236236
fn environ(vm: &VirtualMachine) -> PyDictRef {
237237
let environ = vm.ctx.new_dict();
238238

239-
for (key, value) in env::vars() {
239+
for (key, value) in crate::host_env::os::vars() {
240240
// Skip hidden Windows environment variables (e.g., =C:, =D:, =ExitCode)
241241
// These are internal cmd.exe bookkeeping variables that store per-drive
242242
// current directories and cannot be reliably modified via _wputenv().
@@ -251,7 +251,7 @@ pub(crate) mod module {
251251
#[pyfunction]
252252
fn _create_environ(vm: &VirtualMachine) -> PyDictRef {
253253
let environ = vm.ctx.new_dict();
254-
for (key, value) in env::vars() {
254+
for (key, value) in crate::host_env::os::vars() {
255255
if key.starts_with('=') {
256256
continue;
257257
}

crates/vm/src/stdlib/posix_compat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(crate) mod module {
1313
ospath::OsPath,
1414
stdlib::os::{_os, DirFd, SupportFunc, TargetIsDirectory},
1515
};
16-
use std::{env, fs};
16+
use std::fs;
1717

1818
#[pyfunction]
1919
pub(super) fn access(_path: PyStrRef, _mode: u8, vm: &VirtualMachine) -> PyResult<bool> {
@@ -49,7 +49,7 @@ pub(crate) mod module {
4949
use rustpython_host_env::os::ffi::OsStringExt;
5050

5151
let environ = vm.ctx.new_dict();
52-
for (key, value) in env::vars_os() {
52+
for (key, value) in crate::host_env::os::vars_os() {
5353
let key: PyObjectRef = vm.ctx.new_bytes(key.into_vec()).into();
5454
let value: PyObjectRef = vm.ctx.new_bytes(value.into_vec()).into();
5555
environ.set_item(&*key, value, vm).unwrap();

0 commit comments

Comments
 (0)