Skip to content

Commit

Permalink
Ensure python-to-pythonX.Y symlink exists in downloaded Pythons (a…
Browse files Browse the repository at this point in the history
…stral-sh#5849)

## Summary

After installing:

```
❯ readlink "/Users/crmarsh/Library/Application Support/uv/python/cpython-3.12.4-macos-aarch64-none/bin/python"
python3.12

❯ readlink "/Users/crmarsh/Library/Application Support/uv/python/cpython-3.9.5-macos-aarch64-none/bin/python"
python3.9
```

Closes astral-sh#5838.
  • Loading branch information
charliermarsh authored Aug 7, 2024
1 parent e58c503 commit d0b16f9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/uv-python/src/downloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d0b16f9

Please sign in to comment.