Skip to content

Commit 3ff4b3f

Browse files
committed
fix: add windows manifest to uv binaries
1 parent c29304a commit 3ff4b3f

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 7 additions & 0 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ dotenvy = { version = "0.15.7" }
107107
dunce = { version = "1.0.5" }
108108
either = { version = "1.13.0" }
109109
encoding_rs_io = { version = "0.1.7" }
110+
embed-manifest = { version = "1.5.0" }
110111
etcetera = { version = "0.11.0" }
111112
fastrand = { version = "2.3.0" }
112113
flate2 = { version = "1.0.33", default-features = false, features = ["zlib-rs"] }

crates/uv/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ arrayvec = { workspace = true }
121121
self-replace = { workspace = true }
122122
windows = { workspace = true }
123123

124+
[build-dependencies]
125+
uv-version = { workspace = true }
126+
127+
embed-manifest = { workspace = true }
128+
124129
[dev-dependencies]
125130
uv-publish = { workspace = true, features = ["test"] }
126131

crates/uv/build.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! This embeds a "manifest" - a special XML document - into the uv binary on Windows builds.
2+
//! It includes reasonable defaults for Windows binaries:
3+
//! - "System" codepage to retain backwards compatibility with previous uv releases.
4+
//! We can set to the utf-8 codepage in a future breaking release which lets us use the
5+
//! *A versions of Windows API functions without utf-16 conversion.
6+
//! - long path awareness allows paths longer than 260 characters in Windows operations.
7+
//! - Windows 10+ support to avoid legacy compat layers from being potentially applied by not
8+
//! specifying any. We don't declare `Windows7..=Windows10` as toolchain support for Windows 7
9+
//! is tier 3, and it's better to let Windows apply the appropriate compatibility layer.
10+
//! - Other settings such as execution level are standard defaults.
11+
//! See <https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests>
12+
use embed_manifest::manifest::{ActiveCodePage, ExecutionLevel, Setting, SupportedOS};
13+
use embed_manifest::{embed_manifest, empty_manifest};
14+
15+
fn main() {
16+
if std::env::var_os("CARGO_CFG_WINDOWS").is_some() {
17+
let [major, minor, patch] = uv_version::version()
18+
.splitn(3, '.')
19+
.map(str::parse)
20+
.collect::<Result<Vec<u16>, _>>()
21+
.ok()
22+
.and_then(|v| v.try_into().ok())
23+
.expect("uv version must be in x.y.z format");
24+
let manifest = empty_manifest()
25+
.name("uv")
26+
.version(major, minor, patch, 0)
27+
.active_code_page(ActiveCodePage::System)
28+
// Includes Windows 10 and 11, and Windows Server 2016, 2019 and 2022
29+
.supported_os(SupportedOS::Windows10..=SupportedOS::Windows10)
30+
.requested_execution_level(ExecutionLevel::AsInvoker)
31+
.long_path_aware(Setting::Enabled);
32+
embed_manifest(manifest).expect("unable to embed manifest");
33+
println!("cargo:rerun-if-changed=build.rs");
34+
}
35+
}

0 commit comments

Comments
 (0)