From 538922217ad655fd6b08871a52862fe20f5fe0ec Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 6 Aug 2024 22:48:00 -0400 Subject: [PATCH] Ensure python-to-pythonX.Y symlink exists in downloaded Pythons --- crates/uv-python/src/downloads.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/uv-python/src/downloads.rs b/crates/uv-python/src/downloads.rs index ff4287a26cfc..59dd6259853e 100644 --- a/crates/uv-python/src/downloads.rs +++ b/crates/uv-python/src/downloads.rs @@ -495,6 +495,21 @@ impl ManagedPythonDownload { extracted = extracted.join("install"); } + // If the distribution is missing a `python`-to-`pythonX.Y` symlink, add it. PEP 394 permits + // it, and python-build-standalone releases after `20240726` include it, but releases prior + // to that date do not. + #[cfg(unix)] + { + match std::os::unix::fs::symlink( + format!("python{}.{}", self.key.major, self.key.minor), + extracted.join("bin").join("python"), + ) { + Ok(()) => {} + Err(err) if err.kind() == io::ErrorKind::AlreadyExists => {} + Err(err) => return Err(err.into()), + } + } + // Persist it to the target debug!("Moving {} to {}", extracted.display(), path.user_display()); rename_with_retry(extracted, &path)