Use install_only python archive (#4843)

## Summary

Resolves #4834

## Test Plan

```sh
# 3.12.3 is a `install_only` archive
$ cargo run -- python install --preview --force 3.12.3

# 3.9.4 has only `full` archive
$ cargo run -- python install --preview --force 3.9.4
```
This commit is contained in:
Jo 2024-07-07 10:43:55 +08:00 committed by GitHub
parent 7117359ca9
commit 2c214e7585
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 1508 additions and 1495 deletions

View file

@ -252,14 +252,23 @@ impl ManagedPythonInstallation {
/// The path to this toolchain's Python executable.
pub fn executable(&self) -> PathBuf {
if cfg!(windows) {
self.path.join("install").join("python.exe")
self.python_dir().join("python.exe")
} else if cfg!(unix) {
self.path.join("install").join("bin").join("python3")
self.python_dir().join("bin").join("python3")
} else {
unimplemented!("Only Windows and Unix systems are supported.")
}
}
fn python_dir(&self) -> PathBuf {
let install = self.path.join("install");
if install.is_dir() {
install
} else {
self.path.clone()
}
}
/// The [`PythonVersion`] of the toolchain.
pub fn version(&self) -> PythonVersion {
self.key.version()
@ -307,10 +316,9 @@ impl ManagedPythonInstallation {
pub fn ensure_externally_managed(&self) -> Result<(), Error> {
// Construct the path to the `stdlib` directory.
let stdlib = if cfg!(windows) {
self.path.join("install").join("Lib")
self.python_dir().join("Lib")
} else {
self.path
.join("install")
self.python_dir()
.join("lib")
.join(format!("python{}", self.key.version().python_version()))
};