mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-01 04:17:37 +00:00
Support iOS platform tags (#15640)
## Summary This implements the iOS part of https://github.com/astral-sh/uv/issues/8029 FYI: @freakboy3742 <!-- What's the purpose of the change? What does it do, and why? --> ## Test Plan Create a venv with uv and run `cargo run pip install --python-platform arm64-apple-ios pillow`. Then the iOS binary of pillow should be installed inside the venv.
This commit is contained in:
parent
50bfa8a689
commit
330e56e778
11 changed files with 599 additions and 41 deletions
|
|
@ -257,6 +257,30 @@ pub enum TargetTriple {
|
|||
/// A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12.
|
||||
#[cfg_attr(feature = "clap", value(name = "wasm32-pyodide2024"))]
|
||||
Wasm32Pyodide2024,
|
||||
|
||||
/// An ARM64 target for iOS device
|
||||
///
|
||||
/// By default, iOS 13.0 is used, but respects the `IPHONEOS_DEPLOYMENT_TARGET`
|
||||
/// environment variable if set.
|
||||
#[cfg_attr(feature = "clap", value(name = "arm64-apple-ios"))]
|
||||
#[serde(rename = "arm64-apple-ios")]
|
||||
Arm64Ios,
|
||||
|
||||
/// An ARM64 target for iOS simulator
|
||||
///
|
||||
/// By default, iOS 13.0 is used, but respects the `IPHONEOS_DEPLOYMENT_TARGET`
|
||||
/// environment variable if set.
|
||||
#[cfg_attr(feature = "clap", value(name = "arm64-apple-ios-simulator"))]
|
||||
#[serde(rename = "arm64-apple-ios-simulator")]
|
||||
Arm64IosSimulator,
|
||||
|
||||
/// An `x86_64` target for iOS simulator
|
||||
///
|
||||
/// By default, iOS 13.0 is used, but respects the `IPHONEOS_DEPLOYMENT_TARGET`
|
||||
/// environment variable if set.
|
||||
#[cfg_attr(feature = "clap", value(name = "x86_64-apple-ios-simulator"))]
|
||||
#[serde(rename = "x86_64-apple-ios-simulator")]
|
||||
X8664IosSimulator,
|
||||
}
|
||||
|
||||
impl TargetTriple {
|
||||
|
|
@ -510,6 +534,48 @@ impl TargetTriple {
|
|||
});
|
||||
Platform::new(Os::Android { api_level }, Arch::X86_64)
|
||||
}
|
||||
Self::Arm64Ios => {
|
||||
let (major, minor) = ios_deployment_target().map_or((13, 0), |(major, minor)| {
|
||||
debug!("Found iOS deployment target: {}.{}", major, minor);
|
||||
(major, minor)
|
||||
});
|
||||
Platform::new(
|
||||
Os::Ios {
|
||||
major,
|
||||
minor,
|
||||
simulator: false,
|
||||
},
|
||||
Arch::Aarch64,
|
||||
)
|
||||
}
|
||||
Self::Arm64IosSimulator => {
|
||||
let (major, minor) = ios_deployment_target().map_or((13, 0), |(major, minor)| {
|
||||
debug!("Found iOS deployment target: {}.{}", major, minor);
|
||||
(major, minor)
|
||||
});
|
||||
Platform::new(
|
||||
Os::Ios {
|
||||
major,
|
||||
minor,
|
||||
simulator: true,
|
||||
},
|
||||
Arch::Aarch64,
|
||||
)
|
||||
}
|
||||
Self::X8664IosSimulator => {
|
||||
let (major, minor) = ios_deployment_target().map_or((13, 0), |(major, minor)| {
|
||||
debug!("Found iOS deployment target: {}.{}", major, minor);
|
||||
(major, minor)
|
||||
});
|
||||
Platform::new(
|
||||
Os::Ios {
|
||||
major,
|
||||
minor,
|
||||
simulator: true,
|
||||
},
|
||||
Arch::X86_64,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -555,6 +621,9 @@ impl TargetTriple {
|
|||
Self::Aarch64LinuxAndroid => "aarch64",
|
||||
Self::X8664LinuxAndroid => "x86_64",
|
||||
Self::Wasm32Pyodide2024 => "wasm32",
|
||||
Self::Arm64Ios => "arm64",
|
||||
Self::Arm64IosSimulator => "arm64",
|
||||
Self::X8664IosSimulator => "x86_64",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -600,6 +669,9 @@ impl TargetTriple {
|
|||
Self::Aarch64LinuxAndroid => "Android",
|
||||
Self::X8664LinuxAndroid => "Android",
|
||||
Self::Wasm32Pyodide2024 => "Emscripten",
|
||||
Self::Arm64Ios => "iOS",
|
||||
Self::Arm64IosSimulator => "iOS",
|
||||
Self::X8664IosSimulator => "iOS",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -648,6 +720,9 @@ impl TargetTriple {
|
|||
// https://github.com/emscripten-core/emscripten/blob/4.0.8/system/lib/libc/emscripten_syscall_stubs.c#L63
|
||||
// It doesn't really seem to mean anything? But for completeness we include it here.
|
||||
Self::Wasm32Pyodide2024 => "#1",
|
||||
Self::Arm64Ios => "",
|
||||
Self::Arm64IosSimulator => "",
|
||||
Self::X8664IosSimulator => "",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -695,6 +770,9 @@ impl TargetTriple {
|
|||
// This is the Emscripten compiler version for Pyodide 2024.
|
||||
// See https://pyodide.org/en/stable/development/abi.html#pyodide-2024-0
|
||||
Self::Wasm32Pyodide2024 => "3.1.58",
|
||||
Self::Arm64Ios => "",
|
||||
Self::Arm64IosSimulator => "",
|
||||
Self::X8664IosSimulator => "",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -740,6 +818,9 @@ impl TargetTriple {
|
|||
Self::Aarch64LinuxAndroid => "posix",
|
||||
Self::X8664LinuxAndroid => "posix",
|
||||
Self::Wasm32Pyodide2024 => "posix",
|
||||
Self::Arm64Ios => "posix",
|
||||
Self::Arm64IosSimulator => "posix",
|
||||
Self::X8664IosSimulator => "posix",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -785,6 +866,9 @@ impl TargetTriple {
|
|||
Self::Aarch64LinuxAndroid => "android",
|
||||
Self::X8664LinuxAndroid => "android",
|
||||
Self::Wasm32Pyodide2024 => "emscripten",
|
||||
Self::Arm64Ios => "ios",
|
||||
Self::Arm64IosSimulator => "ios",
|
||||
Self::X8664IosSimulator => "ios",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -830,6 +914,9 @@ impl TargetTriple {
|
|||
Self::Aarch64LinuxAndroid => false,
|
||||
Self::X8664LinuxAndroid => false,
|
||||
Self::Wasm32Pyodide2024 => false,
|
||||
Self::Arm64Ios => false,
|
||||
Self::Arm64IosSimulator => false,
|
||||
Self::X8664IosSimulator => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -863,6 +950,20 @@ fn macos_deployment_target() -> Option<(u16, u16)> {
|
|||
Some((major, minor))
|
||||
}
|
||||
|
||||
/// Return the iOS deployment target as parsed from the environment.
|
||||
fn ios_deployment_target() -> Option<(u16, u16)> {
|
||||
let version = std::env::var(EnvVars::IPHONEOS_DEPLOYMENT_TARGET).ok()?;
|
||||
let mut parts = version.split('.');
|
||||
|
||||
// Parse the major version (e.g., `12` in `12.0`).
|
||||
let major = parts.next()?.parse::<u16>().ok()?;
|
||||
|
||||
// Parse the minor version (e.g., `0` in `12.0`), with a default of `0`.
|
||||
let minor = parts.next().unwrap_or("0").parse::<u16>().ok()?;
|
||||
|
||||
Some((major, minor))
|
||||
}
|
||||
|
||||
/// Return the Android API level as parsed from the environment.
|
||||
fn android_api_level() -> Option<u16> {
|
||||
let api_level_str = std::env::var(EnvVars::ANDROID_API_LEVEL).ok()?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue