Skip to content

fix(python): use native ARM64 precompiled Python on Windows ARM#8961

Merged
jdx merged 2 commits intojdx:mainfrom
JohanLorenzo:fix/python-windows-arm64
Apr 8, 2026
Merged

fix(python): use native ARM64 precompiled Python on Windows ARM#8961
jdx merged 2 commits intojdx:mainfrom
JohanLorenzo:fix/python-windows-arm64

Conversation

@JohanLorenzo
Copy link
Copy Markdown
Contributor

Hello there! 👋

First and foremost, thank you for creating and actively developing mise! 😃 I discovered it through this HackerNews post and I've used it for a personal project since then. By the way, I'm genuinely impressed by how many releases you ship every now and then 👍

Today, I wanted to run my python project on Windows ARM64, and this happened:

 DEBUG using lockfile URL for platform windows-arm64: https://github.com/astral-sh/python-build-standalone/releases/download/20260324/cpython-3.13.12+20260324-x86_64-pc-windows-msvc-install_only_stripped.tar.gz
  INFO  python@3.13.12       [2/4] download cpython-3.13.12+20260324-x86_64-pc-windows-msvc-install_only_stripped.tar.gz

I saw the resulting failure when trying to load an ARM64 DLL from the downloaded x86_64 Python:

  >>> import ctypes; ctypes.CDLL(r"C:\PATH\TO\ARM64\DLL\engine.dll")
  OSError: [WinError 193] %1 is not a valid Win32 application

This fix change the downloaded python into:

  DEBUG GET https://mise-versions.jdx.dev/tools/python-precompiled-aarch64-pc-windows-msvc.gz
  INFO  python@3.13.12       [2/4] download cpython-3.13.12+20260324-aarch64-pc-windows-msvc-install_only_stripped.tar.gz

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 8, 2026

Greptile Summary

This PR fixes a bug where mise was always downloading x86_64 Python on Windows, even when running on ARM64 hardware. The fix changes the condition in resolve_python_arch from cfg!(windows) (which always forced x86_64) to os == "windows" && arch != "aarch64", allowing Windows ARM64 to correctly use the native aarch64 precompiled Python. The function is also extracted for testability, with good unit test coverage added.

Confidence Score: 5/5

This PR is safe to merge — it is a targeted, well-tested bug fix with no regressions expected.

The change is minimal and focused: one condition tweak (cfg!(windows)os == "windows" && arch != "aarch64") with clear intent. The extracted helper is unit-tested across all relevant OS/arch combinations. No existing behavior changes for non-ARM64 Windows, Linux, or macOS.

No files require special attention.

Vulnerabilities

No security concerns identified.

Important Files Changed

Filename Overview
src/plugins/core/python.rs Extracts resolve_python_arch to fix ARM64 Windows Python download and adds unit tests covering all major OS/arch combinations.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[python_arch settings] --> B{precompiled_arch\noverride set?}
    B -- yes --> C[return override]
    B -- no --> D[settings.arch]
    D --> E[resolve_python_arch os arch]
    E --> F{normalize arch}
    F -- x64 --> G[x86_64]
    F -- arm64 --> H[aarch64]
    F -- other --> I[other]
    G & H & I --> J{os == windows?}
    J -- yes, arch != aarch64 --> K[return x86_64]
    J -- yes, arch == aarch64 --> L[return aarch64\nnative ARM64 ✅]
    J -- no, os == linux\n&& arch == x86_64 --> M{CPU feature flags}
    M --> N[x86_64 / x86_64_v2\n/ x86_64_v3 / x86_64_v4]
    J -- no, other --> O[return arch as-is]
Loading

Reviews (2): Last reviewed commit: "fix(python): use native ARM64 precompile..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the Python architecture resolution logic into a standalone function, resolve_python_arch, and introduces unit tests to verify its behavior across different operating systems. A review comment suggests simplifying the conditional logic for Windows architecture detection to improve code clarity.

other => other,
};
if cfg!(windows) {
if os == "windows" && arch != "aarch64" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The condition os == "windows" && arch != "aarch64" is slightly redundant because resolve_python_arch is called with arch already mapped to aarch64 if it was arm64. While correct, it could be simplified to os == "windows" && arch == "x86_64" for clarity, assuming x86_64 is the only non-aarch64 architecture expected on Windows.

@JohanLorenzo JohanLorenzo force-pushed the fix/python-windows-arm64 branch from 1e5d158 to 7ca6334 Compare April 8, 2026 13:19
@jdx jdx merged commit 3099630 into jdx:main Apr 8, 2026
34 checks passed
@JohanLorenzo JohanLorenzo deleted the fix/python-windows-arm64 branch April 9, 2026 04:48
mise-en-dev added a commit that referenced this pull request Apr 9, 2026
### 🐛 Bug Fixes

- **(python)** use native ARM64 precompiled Python on Windows ARM by
@JohanLorenzo in [#8961](#8961)

### New Contributors

- @JohanLorenzo made their first contribution in
[#8961](#8961)
jdx pushed a commit to jdx/hk that referenced this pull request Apr 11, 2026
Hi there! 👋 

Thank you so much for quickly accepting and releasing
jdx/mise#8961. I truly appreciate it and I got
to use it already 🙂

I'm converting a personal project from pre-commit to hk and I stumbled
upon an issue with `git lfs`. git-lfs hooks (`post-checkout`,
`post-merge`, `pre-push`) need the arguments that git passes to the hook
script. Without this PR, `git lfs post-checkout` fails with "This should
be run through Git's post-checkout hook."

   ## Summary

- Adds a `{{ hook_args }}` template variable that forwards git hook
arguments to step commands
- The generated hook scripts now pass `$*` via `HK_HOOK_ARGS` env var
instead of positional args
- All hook handlers (generic, pre-commit, pre-push, commit-msg,
prepare-commit-msg) read `HK_HOOK_ARGS` and insert it into the template
context


With this change, users can configure git-lfs integration in `hk.pkl`:
   ```pkl
   hooks {
       ["post-checkout"] {
           steps {
["git-lfs"] { check = "git lfs post-checkout {{ hook_args }}" }
           }
       }
       ["post-merge"] {
           steps {
["git-lfs"] { check = "git lfs post-merge {{ hook_args }}" }
           }
       }
       ["pre-push"] {
           steps {
["git-lfs"] { check = "git lfs pre-push {{ hook_args }}" }
           }
       }
   }
   ```

Let me know what you think!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants