-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Migrate sys_info to sysinfo #16746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Migrate sys_info to sysinfo #16746
Conversation
- Replace sys_info::os_type() with std::env::consts::OS and sysinfo equivalents - Replace sys_info::os_release() with sysinfo::System::kernel_version() - Replace sys_info::linux_os_release() with sysinfo::System::name(), os_version(), and custom parsing for VERSION_CODENAME - Add heck dependency for string case conversion - Update linehaul.rs and tests to use new system info retrieval - Fix Clippy disallowed_types by using fs_err instead of std::fs - Ensure cross-platform compatibility and test coverage
|
Thanks for the contribution. From a historical perspective, I did not use sysinfo due to its performance at the time and yielding wildly different results than what's expected in linehaul for some distros (when compared to pip). Things may have changed by now though, so I believe we'll need to look at two things here:
|
|
If you're trying to build uv for termux, I'd encourage you to take a look at https://github.com/termux/termux-packages/tree/master/packages/uv which shows the minimal patches needed to get uv to build for it. |
But now is different from the past, sys-info has not been updated for a long time.Sysinfo has been updated in recent months.I can try measuring the performance difference between the two, and I can also test it on a Linux system without using WSL. |
Thank you, successfully compiling on termux is not very interesting. Becoming one of the contributors to UV is my goal. I will continue testing, and if I find that it is really as you described, I will close this PR. Thank you |
|
As an aside, please don't use screenshots of text. |
|
While I agree that sysinfo looks better than sys_info, this PR is hard to review, because we need to ensure that the linehaul data doesn't have regressions from this, and we need to check this for Windows, macOS, and major Linux distros, across several versions. |
By directly comparing the source code, I found the API mappings; only one was missing. Also, feel free to modify the code here; you have a better understanding of this project. I haven't strictly followed the project's coding style here. |



Summary
Migrate the usage of the
sys_infocrate to thesysinfocrate throughout the project.Key changes:
sys_info::os_type()withstd::env::consts::OS(standardized to lowercase) orsysinfoequivalents for consistency.sys_info::os_release()withsysinfo::System::kernel_version().sys_info::linux_os_release()withsysinfo::System::name()andos_version(), plus custom parsing of/etc/os-releaseforVERSION_CODENAME(assysinfolacks direct support).heckdependency touv-pythonfor string case conversion (e.g., title casing OS names).This migration eliminates reliance on the unmaintained
sys_infocrate, improves cross-platform system info accuracy, and aligns with modern Rust ecosystem practices.build
ubuntu(wsl)

windows(host)

android(cross)

Test Plan
test_sysinfo.zip
I couldn't find the method to obtain version odename in the sysinfo library. I copied the corresponding function source code directly from the sys info source code and added a private function, which is not elegant, so it still needs to be confirmed by the developer.
To ensure consistency, I need to add a string (std::env::consts::OS), for which I added a dependency to the heck library, I'm not sure if I agree to add a dependency, this task is very simple, if you don't want to add a dependency, you can change it to a standard library implementation.
sys_info::linux_os_release : remove
id: info.version_codename --> Find the source code for this function from the sys_info library and apply it.
name: info.name --> sysinfo::System::name() e.g Some("Ubuntu")
version: info.version_id --> sysinfo::System::os_version() Some("24.04")
...
sys_info::os_release() -->sysinfo::System::kernel_version() e.g Some("6.6.87.2-microsoft-standard-WSL2")
If you find that sysinfo provides version_codename relevant API, please alert me.