uv-python: use windows-sys instead of winapi (#5591)

<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

use windows-sys bindings maintained by microsoft devs. winapi didn't has
any updates for more than 3 years

## Test Plan

cargo test. it failed locally because I don't have Python 3.12 installed
This commit is contained in:
Maksim Bondarenkov 2024-07-30 12:43:04 +03:00 committed by GitHub
parent c0d3da8b6a
commit 228a803fde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 10 deletions

2
Cargo.lock generated
View File

@ -4958,7 +4958,7 @@ dependencies = [
"uv-state", "uv-state",
"uv-warnings", "uv-warnings",
"which", "which",
"winapi", "windows-sys 0.52.0",
"winsafe", "winsafe",
] ]

View File

@ -153,7 +153,7 @@ url = { version = "2.5.0" }
urlencoding = { version = "2.1.3" } urlencoding = { version = "2.1.3" }
walkdir = { version = "2.5.0" } walkdir = { version = "2.5.0" }
which = { version = "6.0.0", features = ["regex"] } which = { version = "6.0.0", features = ["regex"] }
winapi = { version = "0.3.9", features = ["fileapi", "handleapi", "ioapiset", "winbase", "winioctl", "winnt"] } windows-sys = { version = "0.52.0", features = ["Win32_Foundation", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Ioctl", "Win32_System_IO"] }
winreg = { version = "0.52.0" } winreg = { version = "0.52.0" }
winsafe = { version = "0.0.19", features = ["kernel"] } winsafe = { version = "0.0.19", features = ["kernel"] }
wiremock = { version = "0.6.0" } wiremock = { version = "0.6.0" }

View File

@ -55,7 +55,7 @@ which = { workspace = true }
rustix = { workspace = true } rustix = { workspace = true }
[target.'cfg(target_os = "windows")'.dependencies] [target.'cfg(target_os = "windows")'.dependencies]
winapi = { workspace = true } windows-sys = { workspace = true }
winsafe = { workspace = true } winsafe = { workspace = true }
[dev-dependencies] [dev-dependencies]

View File

@ -923,12 +923,13 @@ fn warn_on_unsupported_python(interpreter: &Interpreter) {
pub(crate) fn is_windows_store_shim(path: &Path) -> bool { pub(crate) fn is_windows_store_shim(path: &Path) -> bool {
use std::os::windows::fs::MetadataExt; use std::os::windows::fs::MetadataExt;
use std::os::windows::prelude::OsStrExt; use std::os::windows::prelude::OsStrExt;
use winapi::um::fileapi::{CreateFileW, OPEN_EXISTING}; use windows_sys::Win32::Foundation::{CloseHandle, INVALID_HANDLE_VALUE};
use winapi::um::handleapi::{CloseHandle, INVALID_HANDLE_VALUE}; use windows_sys::Win32::Storage::FileSystem::{
use winapi::um::ioapiset::DeviceIoControl; CreateFileW, FILE_ATTRIBUTE_REPARSE_POINT, FILE_FLAG_BACKUP_SEMANTICS,
use winapi::um::winbase::{FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_OPEN_REPARSE_POINT}; FILE_FLAG_OPEN_REPARSE_POINT, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, OPEN_EXISTING,
use winapi::um::winioctl::FSCTL_GET_REPARSE_POINT; };
use winapi::um::winnt::{FILE_ATTRIBUTE_REPARSE_POINT, MAXIMUM_REPARSE_DATA_BUFFER_SIZE}; use windows_sys::Win32::System::Ioctl::FSCTL_GET_REPARSE_POINT;
use windows_sys::Win32::System::IO::DeviceIoControl;
// The path must be absolute. // The path must be absolute.
if !path.is_absolute() { if !path.is_absolute() {
@ -988,7 +989,7 @@ pub(crate) fn is_windows_store_shim(path: &Path) -> bool {
std::ptr::null_mut(), std::ptr::null_mut(),
OPEN_EXISTING, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT,
std::ptr::null_mut(), 0,
) )
}; };