Add PyPy finder (#5337)

## Summary

This PR adds PyPy finder and adds PyPy to uv managed Python versions.

## Test Plan

```console
$ cargo run -- python install
```
This commit is contained in:
Jo 2024-07-24 03:58:04 +08:00 committed by GitHub
parent 96b24345eb
commit 7ddf67a72b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 2948 additions and 23 deletions

File diff suppressed because it is too large Load diff

View file

@ -314,15 +314,23 @@ impl ManagedPythonInstallation {
/// standard `EXTERNALLY-MANAGED` file.
pub fn ensure_externally_managed(&self) -> Result<(), Error> {
// Construct the path to the `stdlib` directory.
let stdlib = if cfg!(windows) {
let stdlib = if matches!(self.key.os, Os(target_lexicon::OperatingSystem::Windows)) {
self.python_dir().join("Lib")
} else {
self.python_dir()
.join("lib")
.join(format!("python{}", self.key.version().python_version()))
let python = if matches!(
self.key.implementation,
LenientImplementationName::Known(ImplementationName::PyPy)
) {
format!("pypy{}", self.key.version().python_version())
} else {
format!("python{}", self.key.version().python_version())
};
self.python_dir().join("lib").join(python)
};
let file = stdlib.join("EXTERNALLY-MANAGED");
fs_err::write(file, EXTERNALLY_MANAGED)?;
Ok(())
}
}