Skip to content

Commit

Permalink
Upgrade platform-info to 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed May 26, 2023
1 parent 15bde24 commit ee305e1
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 52 deletions.
99 changes: 54 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ cargo-options = "0.6.0"
cbindgen = { version = "0.24.2", default-features = false }
flate2 = "1.0.18"
goblin = "0.6.1"
platform-info = "1.0.0"
platform-info = "2.0.0"
regex = "1.7.0"
serde = { version = "1.0.141", features = ["derive"] }
serde_json = "1.0.80"
Expand Down
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ skip = [
# from cbindgen
{ name = "toml", version = "0.5.11" },
{ name = "syn" },
{ name = "portable-atomic", version = "0.3.20"},
]
# Similarly to `skip` allows you to skip certain crates during duplicate
# detection. Unlike skip, it also includes the entire tree of transitive
Expand Down
7 changes: 4 additions & 3 deletions src/build_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,10 @@ impl BuildContext {
}
// osname_release_machine fallback for any POSIX system
(_, _) => {
let info = PlatformInfo::new()?;
let mut release = info.release().replace(['.', '-'], "_");
let mut machine = info.machine().replace([' ', '/'], "_");
let info = PlatformInfo::new()
.map_err(|e| anyhow!("Failed to fetch platform information: {e}"))?;
let mut release = info.release().to_string_lossy().replace(['.', '-'], "_");
let mut machine = info.machine().to_string_lossy().replace([' ', '/'], "_");

let mut os = target.target_os().to_string().to_ascii_lowercase();
// See https://github.com/python/cpython/blob/46c8d915715aa2bd4d697482aa051fe974d440e1/Lib/sysconfig.py#L722-L730
Expand Down
7 changes: 4 additions & 3 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl Target {
if self.cross_compiling {
return Ok(self.arch.to_string());
}
let machine = PlatformInfo::new().map(|info| info.machine().into_owned());
let machine = PlatformInfo::new().map(|info| info.machine().to_string_lossy().into_owned());
let arch = match machine {
Ok(machine) => {
let linux32 = (machine == "x86_64" && self.arch != Arch::X86_64)
Expand Down Expand Up @@ -296,8 +296,9 @@ impl Target {
let release = match os_version {
Ok(os_ver) => os_ver,
Err(_) => {
let info = PlatformInfo::new()?;
info.release().to_string()
let info = PlatformInfo::new()
.map_err(|e| anyhow!("Failed to fetch platform information: {e}"))?;
info.release().to_string_lossy().into_owned()
}
};
let release = release.replace(['.', '-'], "_");
Expand Down

0 comments on commit ee305e1

Please sign in to comment.