Skip to content

Commit e16f1aa

Browse files
Use correct dirs crate; drop uname for rustix (RustPython#7906)
RustPython used an ancient, unmaintained version of the `dirs` crate. This pulled in `winapi-rs` on Windows, which is an old crate that has been deprecated in favor of `windows-rs`. `windows-rs` is maintained by Microsoft. Bumping `dirs` to the latest version removes more `winapi-rs` from Cargo.lock. As for `uname`, `rustix` handles it safely so the additional crate isn't needed.
1 parent 6e56d93 commit e16f1aa

5 files changed

Lines changed: 38 additions & 63 deletions

File tree

Cargo.lock

Lines changed: 28 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ log = { workspace = true }
4242
flame = { workspace = true, optional = true }
4343

4444
lexopt = "0.3"
45-
dirs = { package = "dirs-next", version = "2.0" }
45+
dirs = "6"
4646
env_logger = "0.11"
4747
flamescope = { version = "0.1.2", optional = true }
4848

crates/host_env/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ paste = { workspace = true }
2020
[target.'cfg(unix)'.dependencies]
2121
nix = { workspace = true }
2222
rustix = { workspace = true }
23-
uname = "0.1.1"
2423

2524
[target.'cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))'.dependencies]
2625
num_cpus = "1.17.0"

crates/host_env/src/posix.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,14 @@ pub fn fchownat(
380380
.map_err(std::io::Error::from)
381381
}
382382

383-
pub fn uname_info() -> std::io::Result<UnameInfo> {
384-
let info = uname::uname()?;
383+
pub fn uname_info() -> Result<UnameInfo, core::str::Utf8Error> {
384+
let info = rustix::system::uname();
385385
Ok(UnameInfo {
386-
sysname: info.sysname,
387-
nodename: info.nodename,
388-
release: info.release,
389-
version: info.version,
390-
machine: info.machine,
386+
sysname: info.sysname().to_str()?.into(),
387+
nodename: info.nodename().to_str()?.into(),
388+
release: info.release().to_str()?.into(),
389+
version: info.version().to_str()?.into(),
390+
machine: info.machine().to_str()?.into(),
391391
})
392392
}
393393

crates/vm/src/stdlib/posix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,8 +1279,8 @@ pub mod module {
12791279

12801280
#[pyfunction]
12811281
fn uname(vm: &VirtualMachine) -> PyResult<_os::UnameResultData> {
1282-
let info =
1283-
rustpython_host_env::posix::uname_info().map_err(|err| err.into_pyexception(vm))?;
1282+
let info = rustpython_host_env::posix::uname_info()
1283+
.map_err(|err| vm.new_unicode_decode_error(err.to_string()))?;
12841284
Ok(_os::UnameResultData {
12851285
sysname: info.sysname,
12861286
nodename: info.nodename,

0 commit comments

Comments
 (0)