Skip to content

Comments

disfavor aarch64 windows in its own house#13724

Merged
Gankra merged 3 commits intomainfrom
gankra/deprio-arm64-windows
Jun 30, 2025
Merged

disfavor aarch64 windows in its own house#13724
Gankra merged 3 commits intomainfrom
gankra/deprio-arm64-windows

Conversation

@Gankra
Copy link
Contributor

@Gankra Gankra commented May 29, 2025

and prefer emulated x64 windows in its stead.

This is preparatory work for shipping support for uv downloading and installing aarch64 (arm64) windows Pythons. We've had builds for this platform ready for a while, but have held back on shipping them due to a fundamental problem:

The Python packaging ecosystem does not have strong support for aarch64 windows, e.g., not many projects build aarch64 wheels yet. The net effect of this is that, if we handed you an aarch64 python interpreter on windows, you would have to build a lot more sdists, and there's a high chance you will simply fail to build that sdist and be sad.

Yes unfortunately, in this case a non-native Python interpreter simply works better than the native one... in terms of working at all, today. Of course, if the native interpreter works for your project, it should presumably have better performance and platform compatibility.

We do not want to stand in the way of progress, as ideally this situation is a temporary state of affairs as the ecosystem grows to support aarch64 windows. To enable progress, on aarch64 Windows builds of uv:

  • We will still use a native python interpreter, e.g., if it's at the front of your PATH or the only installed version.
  • If we are choosing between equally good interpreters that differ in architecture, x64 will be preferred.
  • We will emit a diagnostic on installation, and show the python request to pass to uv to force aarch64 windows to be used.
  • Will be shipping aarch64 Windows Python downloads
  • Will probably add some kind of global override setting/env-var to disable this behaviour.
  • Will be shipping this behaviour in astral-sh/setup-uv

We're coordinating with Microsoft, GitHub (for the setup-python action), and the CPython team (for the python.org installers), to ensure we're aligned on this default and the timing of toggling to prefer native distributions in the future.

See discussion in


This is an alternative to

which uses sorting rather than filtering, as discussed in

@Gankra Gankra added the internal A refactor or improvement that is not user-facing label May 29, 2025
// Architectures are sorted in preferred order, with native architectures first
.then_with(|| self.arch.cmp(&other.arch).reverse())
.then_with(|| {
// For the time being, manually sort windows to make aarch64 windows disfavored
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not implement this in

impl Ord for Arch {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
if self.family == other.family {
return self.variant.cmp(&other.variant);
}
let native = Arch::from_env();
// Prefer native architectures
match (self.family == native.family, other.family == native.family) {
(true, true) => unreachable!(),
(true, false) => std::cmp::Ordering::Less,
(false, true) => std::cmp::Ordering::Greater,
(false, false) => {
// Both non-native, fallback to lexicographic order
self.family.to_string().cmp(&other.family.to_string())
}
}
}
}
instead under a Windows cfg? Do we need the self.os check here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this just looks a lot like the logic already in Arch::cmp and I think it'd be easier to reason about in a single location)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's because of the os check. Not that it's super useful now that I think about it harder, but it feels... wrong... that we would resolve a request for python-3.11-darwin-any to intel on arm64 windows.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... it does feel wrong... but like... not a real use-case today. I worry about this being brittle. I'll ponder this overnight.

It does suggest that long-term we need a dedicated Platform type to encapsulate both the OS and the Arch and implement Ord on that instead?

@codspeed-hq
Copy link

codspeed-hq bot commented May 29, 2025

CodSpeed Walltime Performance Report

Merging #13724 will not alter performance

Comparing gankra/deprio-arm64-windows (1777186) with main (d9b76b9)

Summary

✅ 12 untouched benchmarks

@konstin
Copy link
Member

konstin commented May 30, 2025

When applying this, we should make sure that we signal to the user clearly that we prefer x64_86 over aarch64 and how to revert that, both on automatic installation and on uv python list. (This is different from the Apple case where there was an explicit transition with a big announcement on the transparent emulation and users expected software from Intel Macs to keep working.)

@zanieb zanieb self-assigned this May 30, 2025
@Gankra
Copy link
Contributor Author

Gankra commented May 30, 2025

When applying this, we should make sure that we signal to the user clearly that we prefer x64_86 over aarch64 and how to revert that, both on automatic installation and on uv python list

As in uv should print messages whenever it detected it was doing this, or a public marketing campaign?

@Gankra
Copy link
Contributor Author

Gankra commented May 30, 2025

Also wanna note, we don't really need to land this until we go to update to a PBS that ships arm64 windows builds, so there's no rush to land this. I don't think we have any reports of users installing system intel and arm64 pythons on windows and getting mad uv isn't picking the intel one (but this PR would change that).

@konstin
Copy link
Member

konstin commented May 30, 2025

We should print a note when uv installs a managed Python interpreter that is not native and not explicitly requested as non-native by the user.

@Gankra
Copy link
Contributor Author

Gankra commented Jun 13, 2025

Pushed up a fixed impl with the requested diagnostic (zanie wanted a note, not a warning).

@zanieb
Copy link
Member

zanieb commented Jun 13, 2025

Can we add a test case for this? Like the macOS emulated one? We don't run the test suite on arm Windows though, so that's kind of annoying. Maybe better as a follow-up, though we could at least write a janky integration test with a bash assertion in CI? Like integration test | uv python on arm windows?

@Gankra
Copy link
Contributor Author

Gankra commented Jun 13, 2025

Can we add a test case for this? Like the macOS emulated one? We don't run the test suite on arm Windows though, so that's kind of annoying. Maybe better as a follow-up, though we could at least write a janky integration test with a bash assertion in CI? Like integration test | uv python on arm windows?

I was planning to explore testing more when we PR the PBS update that adds windows releases.

@zanieb
Copy link
Member

zanieb commented Jun 13, 2025

That makes sense, though I'd double check we have existing test coverage to ensure this doesn't "break" anything (we do have a couple CI jobs covering aarch64 windows)

@Gankra
Copy link
Contributor Author

Gankra commented Jun 30, 2025

Added a "aarch64 on aarch64 windows" smoketest to go with the "x64 on aarch64" one

@Gankra Gankra force-pushed the gankra/deprio-arm64-windows branch from 4ea8c94 to eb2eddf Compare June 30, 2025 19:31
@Gankra Gankra temporarily deployed to uv-test-registries June 30, 2025 19:33 — with GitHub Actions Inactive
@Gankra Gankra temporarily deployed to uv-test-publish June 30, 2025 19:33 — with GitHub Actions Inactive
@Gankra Gankra merged commit 317ce6e into main Jun 30, 2025
87 of 88 checks passed
@Gankra Gankra deleted the gankra/deprio-arm64-windows branch June 30, 2025 21:42
zanieb added a commit that referenced this pull request Aug 13, 2025
…#15027)

Addresses this outstanding item from a previous review
#13724 (comment)

I'm interested in this now for consolidating some logic in #12731
zanieb added a commit that referenced this pull request Aug 13, 2025
This allows `PythonDownloadRequest` which is used for parsing general
install key requests to have missing segments, which unblocks requests
like `windows-aarch64` or `cpython-linux` (whereas before those would
require `any-any-windows-aarch64` and `cpython-any-linux` respectively).
We still require strict ordering of segments.

Previously, we only allowed missing segments at the end of the key.

This uses a state machine for parsing, which is quite a bit more
complicated.

I'm a little hesitant about the possibility that this regresses error
messages and the complexity of the implementation, but `uv run -p
aarch64` seems valuable following #13724. The alternative to this would
probably be to make these explicit in various places? e.g., expose
`--python-arch`, `--python-libc`, and `--python-os`? Or make
`--python-platform` (which already exists) accept a subset of the keys?

There is a possibility of regressions here, e.g., if something matches
this parser it will not fallback to the `PythonRequest::ExecutableName`
case and we've made this parser more permissive, but I think that should
be quite rare?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants