mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
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:
parent
7117359ca9
commit
2c214e7585
5 changed files with 1508 additions and 1495 deletions
File diff suppressed because it is too large
Load diff
|
@ -33,6 +33,7 @@ HEADERS = {
|
||||||
}
|
}
|
||||||
VERSIONS_FILE = SELF_DIR / "download-metadata.json"
|
VERSIONS_FILE = SELF_DIR / "download-metadata.json"
|
||||||
FLAVOR_PREFERENCES = [
|
FLAVOR_PREFERENCES = [
|
||||||
|
"install_only",
|
||||||
"shared-pgo",
|
"shared-pgo",
|
||||||
"shared-noopt",
|
"shared-noopt",
|
||||||
"shared-noopt",
|
"shared-noopt",
|
||||||
|
@ -44,7 +45,6 @@ FLAVOR_PREFERENCES = [
|
||||||
HIDDEN_FLAVORS = [
|
HIDDEN_FLAVORS = [
|
||||||
"debug",
|
"debug",
|
||||||
"noopt",
|
"noopt",
|
||||||
"install_only",
|
|
||||||
]
|
]
|
||||||
SPECIAL_TRIPLES = {
|
SPECIAL_TRIPLES = {
|
||||||
"macos": "x86_64-apple-darwin",
|
"macos": "x86_64-apple-darwin",
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -463,12 +463,17 @@ impl ManagedPythonDownload {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the top-level directory.
|
// Extract the top-level directory.
|
||||||
let extracted = match uv_extract::strip_component(temp_dir.path()) {
|
let mut extracted = match uv_extract::strip_component(temp_dir.path()) {
|
||||||
Ok(top_level) => top_level,
|
Ok(top_level) => top_level,
|
||||||
Err(uv_extract::Error::NonSingularArchive(_)) => temp_dir.into_path(),
|
Err(uv_extract::Error::NonSingularArchive(_)) => temp_dir.into_path(),
|
||||||
Err(err) => return Err(Error::ExtractError(filename.to_string(), err)),
|
Err(err) => return Err(Error::ExtractError(filename.to_string(), err)),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If the distribution is a `full` archive, the Python installation is in the `install` directory.
|
||||||
|
if extracted.join("install").is_dir() {
|
||||||
|
extracted = extracted.join("install");
|
||||||
|
}
|
||||||
|
|
||||||
// Persist it to the target
|
// Persist it to the target
|
||||||
debug!("Moving {} to {}", extracted.display(), path.user_display());
|
debug!("Moving {} to {}", extracted.display(), path.user_display());
|
||||||
rename_with_retry(extracted, &path)
|
rename_with_retry(extracted, &path)
|
||||||
|
|
|
@ -252,14 +252,23 @@ impl ManagedPythonInstallation {
|
||||||
/// The path to this toolchain's Python executable.
|
/// The path to this toolchain's Python executable.
|
||||||
pub fn executable(&self) -> PathBuf {
|
pub fn executable(&self) -> PathBuf {
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
self.path.join("install").join("python.exe")
|
self.python_dir().join("python.exe")
|
||||||
} else if cfg!(unix) {
|
} else if cfg!(unix) {
|
||||||
self.path.join("install").join("bin").join("python3")
|
self.python_dir().join("bin").join("python3")
|
||||||
} else {
|
} else {
|
||||||
unimplemented!("Only Windows and Unix systems are supported.")
|
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.
|
/// The [`PythonVersion`] of the toolchain.
|
||||||
pub fn version(&self) -> PythonVersion {
|
pub fn version(&self) -> PythonVersion {
|
||||||
self.key.version()
|
self.key.version()
|
||||||
|
@ -307,10 +316,9 @@ impl ManagedPythonInstallation {
|
||||||
pub fn ensure_externally_managed(&self) -> Result<(), Error> {
|
pub fn ensure_externally_managed(&self) -> Result<(), Error> {
|
||||||
// Construct the path to the `stdlib` directory.
|
// Construct the path to the `stdlib` directory.
|
||||||
let stdlib = if cfg!(windows) {
|
let stdlib = if cfg!(windows) {
|
||||||
self.path.join("install").join("Lib")
|
self.python_dir().join("Lib")
|
||||||
} else {
|
} else {
|
||||||
self.path
|
self.python_dir()
|
||||||
.join("install")
|
|
||||||
.join("lib")
|
.join("lib")
|
||||||
.join(format!("python{}", self.key.version().python_version()))
|
.join(format!("python{}", self.key.version().python_version()))
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue