mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Allow discovery of x86-64 managed Python builds on macOS
This commit is contained in:
parent
7ca43dd366
commit
85e01231d6
2 changed files with 74 additions and 2 deletions
|
@ -157,8 +157,10 @@ impl Arch {
|
|||
|
||||
// TODO: Implement `variant` support checks
|
||||
|
||||
// Windows ARM64 runs emulated x86_64 binaries transparently
|
||||
if cfg!(windows) && matches!(self.family, target_lexicon::Architecture::Aarch64(_)) {
|
||||
// macOS aarch64 and Windows ARM64 runs emulated x86_64 binaries transparently
|
||||
if (cfg!(windows) || cfg!(target_os = "macos"))
|
||||
&& matches!(self.family, target_lexicon::Architecture::Aarch64(_))
|
||||
{
|
||||
return other.family == target_lexicon::Architecture::X86_64;
|
||||
}
|
||||
|
||||
|
|
|
@ -1416,3 +1416,73 @@ fn python_install_cached() {
|
|||
Caused by: An offline Python installation was requested, but cpython-3.12.10[DATE]-[PLATFORM].tar.gz) is missing in python-cache
|
||||
");
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[test]
|
||||
fn python_install_emulated_macos() {
|
||||
let context: TestContext = TestContext::new_with_versions(&[])
|
||||
.with_filtered_exe_suffix()
|
||||
.with_managed_python_dirs();
|
||||
|
||||
// Before installation, `uv python list` should not show the x86_64 download
|
||||
uv_snapshot!(context.filters(), context.python_list().arg("3.13"), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
cpython-3.13.3-macos-aarch64-none <download available>
|
||||
|
||||
----- stderr -----
|
||||
");
|
||||
|
||||
// Install an x86_64 version (assuming an aarch64 host)
|
||||
uv_snapshot!(context.filters(), context.python_install().arg("cpython-3.13-macos-x86_64"), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Installed Python 3.13.3 in [TIME]
|
||||
+ cpython-3.13.3-macos-x86_64-none
|
||||
");
|
||||
|
||||
// It should be discoverable with `uv python find`
|
||||
uv_snapshot!(context.filters(), context.python_find().arg("3.13"), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
[TEMP_DIR]/managed/cpython-3.13.3-macos-x86_64-none/bin/python3.13
|
||||
|
||||
----- stderr -----
|
||||
");
|
||||
|
||||
// And included in `uv python list`
|
||||
uv_snapshot!(context.filters(), context.python_list().arg("3.13"), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
cpython-3.13.3-macos-x86_64-none managed/cpython-3.13.3-macos-x86_64-none/bin/python3.13
|
||||
cpython-3.13.3-macos-aarch64-none <download available>
|
||||
|
||||
----- stderr -----
|
||||
");
|
||||
|
||||
uv_snapshot!(context.filters(), context.python_install().arg("cpython-3.13-macos-aarch64"), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Installed Python 3.13.3 in [TIME]
|
||||
+ cpython-3.13.3-macos-aarch64-none
|
||||
");
|
||||
|
||||
// Once we've installed the native version, it should be preferred over x86_64
|
||||
uv_snapshot!(context.filters(), context.python_find().arg("3.13"), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
[TEMP_DIR]/managed/cpython-3.13.3-macos-x86_64-none/bin/python3.13
|
||||
|
||||
----- stderr -----
|
||||
");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue