From d05bb45c74d2f377f01a59579d184b7ed4dfe433 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 2 Jul 2024 09:21:15 -0400 Subject: [PATCH] Omit pythonX.Y segment in stdlib on managed Windows (#4727) ## Summary Windows omits this segment, IIRC. Closes https://github.com/astral-sh/uv/issues/4724. --- crates/uv-toolchain/src/managed.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/uv-toolchain/src/managed.rs b/crates/uv-toolchain/src/managed.rs index e245a319e..b923a3275 100644 --- a/crates/uv-toolchain/src/managed.rs +++ b/crates/uv-toolchain/src/managed.rs @@ -278,14 +278,16 @@ impl InstalledToolchain { /// Ensure the toolchain is marked as externally managed with the /// standard `EXTERNALLY-MANAGED` file. pub fn ensure_externally_managed(&self) -> Result<(), Error> { - let lib = if cfg!(windows) { "Lib" } else { "lib" }; - let file = self - .path - .join("install") - .join(lib) - // Note the Python version must not include the patch. - .join(format!("python{}", self.key.version().python_version())) - .join("EXTERNALLY-MANAGED"); + // Construct the path to the `stdlib` directory. + let stdlib = if cfg!(windows) { + self.path.join("install").join("Lib") + } else { + self.path + .join("install") + .join("lib") + .join(format!("python{}", self.key.version().python_version())) + }; + let file = stdlib.join("EXTERNALLY-MANAGED"); fs_err::write(file, EXTERNALLY_MANAGED)?; Ok(()) }