Skip to content

Commit 2a083e3

Browse files
authored
Merge pull request #28836 from HinTak/windows-arm64-support
ENH: Provide Windows 11 ARM64 wheels (#22530)
2 parents de784cd + d054ef3 commit 2a083e3

11 files changed

Lines changed: 72 additions & 7 deletions

File tree

‎.github/workflows/wheels.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,15 @@ jobs:
9191
- [macos-14, macosx_arm64, accelerate] # always use accelerate
9292
- [windows-2019, win_amd64, ""]
9393
- [windows-2019, win32, ""]
94+
- [windows-11-arm, win_arm64, ""]
9495
python: ["cp311", "cp312", "cp313", "cp313t", "pp311"]
9596
exclude:
9697
# Don't build PyPy 32-bit windows
9798
- buildplat: [windows-2019, win32, ""]
9899
python: "pp311"
100+
# Don't build PyPy arm64 windows
101+
- buildplat: [windows-11-arm, win_arm64, ""]
102+
python: "pp311"
99103
# No PyPy on musllinux images
100104
- buildplat: [ ubuntu-22.04, musllinux_x86_64, "" ]
101105
python: "pp311"
@@ -121,6 +125,12 @@ jobs:
121125
with:
122126
architecture: 'x86'
123127

128+
- name: Setup MSVC arm64
129+
if: ${{ matrix.buildplat[1] == 'win_arm64' }}
130+
uses: bus1/cabuild/action/msdevshell@e22aba57d6e74891d059d66501b6b5aed8123c4d # v1
131+
with:
132+
architecture: 'arm64'
133+
124134
- name: pkg-config-for-win
125135
run: |
126136
choco install -y --no-progress --stoponfirstfailure --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite
@@ -181,6 +191,7 @@ jobs:
181191
path: ./wheelhouse/*.whl
182192

183193
- uses: mamba-org/setup-micromamba@0dea6379afdaffa5d528b3d1dabc45da37f443fc
194+
if: ${{ matrix.buildplat[1] != 'win_arm64' }} # unsupported platform at the moment
184195
with:
185196
# for installation of anaconda-client, required for upload to
186197
# anaconda.org

‎.github/workflows/windows.yml‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,17 @@ jobs:
9696
run: |
9797
spin test -- --timeout=600 --durations=10
9898
99-
msvc_32bit_python_no_openblas:
100-
name: MSVC, 32-bit Python, no BLAS
101-
runs-on: windows-2019
99+
msvc_python_no_openblas:
100+
name: MSVC, ${{ matrix.architecture }} Python , no BLAS
101+
runs-on: ${{ matrix.os }}
102+
strategy:
103+
fail-fast: false
104+
matrix:
105+
include:
106+
- os: windows-2019
107+
architecture: x86
108+
- os: windows-11-arm
109+
architecture: arm64
102110
# To enable this job on a fork, comment out:
103111
if: github.repository == 'numpy/numpy'
104112
steps:
@@ -109,16 +117,16 @@ jobs:
109117
fetch-tags: true
110118
persist-credentials: false
111119

112-
- name: Setup Python (32-bit)
120+
- name: Setup Python
113121
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
114122
with:
115123
python-version: '3.11'
116-
architecture: 'x86'
124+
architecture: ${{ matrix.architecture }}
117125

118-
- name: Setup MSVC (32-bit)
126+
- name: Setup MSVC
119127
uses: bus1/cabuild/action/msdevshell@e22aba57d6e74891d059d66501b6b5aed8123c4d # v1
120128
with:
121-
architecture: 'x86'
129+
architecture: ${{ matrix.architecture }}
122130

123131
- name: Build and install
124132
run: |

‎numpy/_core/tests/test_array_interface.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pytest
33
import numpy as np
44
from numpy.testing import extbuild, IS_WASM, IS_EDITABLE
5+
import sysconfig
56

67

78
@pytest.fixture
@@ -123,6 +124,8 @@ def get_module(tmp_path):
123124
pass
124125

125126
# if it does not exist, build and load it
127+
if sysconfig.get_platform() == "win-arm64":
128+
pytest.skip("Meson unable to find MSVC linker on win-arm64")
126129
return extbuild.build_and_import_extension('array_interface_testing',
127130
functions,
128131
prologue=prologue,

‎numpy/_core/tests/test_cython.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import subprocess
44
import sys
55
import pytest
6+
import sysconfig
67

78
import numpy as np
89
from numpy.testing import assert_array_equal, IS_WASM, IS_EDITABLE
@@ -53,6 +54,8 @@ def install_temp(tmpdir_factory):
5354
subprocess.check_call(["meson", "--version"])
5455
except FileNotFoundError:
5556
pytest.skip("No usable 'meson' found")
57+
if sysconfig.get_platform() == "win-arm64":
58+
pytest.skip("Meson unable to find MSVC linker on win-arm64")
5659
if sys.platform == "win32":
5760
subprocess.check_call(["meson", "setup",
5861
"--buildtype=release",
@@ -341,6 +344,7 @@ def test_npystring_allocators_other_dtype(install_temp):
341344
assert checks.npystring_allocators_other_types(arr1, arr2) == 0
342345

343346

347+
@pytest.mark.skipif(sysconfig.get_platform() == 'win-arm64', reason='no checks module on win-arm64')
344348
def test_npy_uintp_type_enum():
345349
import checks
346350
assert checks.check_npy_uintp_type_enum()

‎numpy/_core/tests/test_limited_api.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def install_temp(tmpdir_factory):
5252
subprocess.check_call(["meson", "--version"])
5353
except FileNotFoundError:
5454
pytest.skip("No usable 'meson' found")
55+
if sysconfig.get_platform() == "win-arm64":
56+
pytest.skip("Meson unable to find MSVC linker on win-arm64")
5557
if sys.platform == "win32":
5658
subprocess.check_call(["meson", "setup",
5759
"--werror",

‎numpy/_core/tests/test_mem_policy.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import sys
55
import threading
6+
import sysconfig
67

78
import pytest
89

@@ -220,6 +221,8 @@ def get_module(tmp_path):
220221
except ImportError:
221222
pass
222223
# if it does not exist, build and load it
224+
if sysconfig.get_platform() == "win-arm64":
225+
pytest.skip("Meson unable to find MSVC linker on win-arm64")
223226
return extbuild.build_and_import_extension('mem_policy',
224227
functions,
225228
prologue=prologue,

‎numpy/distutils/mingw32ccompiler.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def generate_def(dll, dfile):
262262
def find_dll(dll_name):
263263

264264
arch = {'AMD64' : 'amd64',
265+
'ARM64' : 'arm64',
265266
'Intel' : 'x86'}[get_build_architecture()]
266267

267268
def _find_dll_in_winsxs(dll_name):
@@ -351,6 +352,8 @@ def build_import_library():
351352
arch = get_build_architecture()
352353
if arch == 'AMD64':
353354
return _build_import_library_amd64()
355+
if arch == 'ARM64':
356+
return _build_import_library_arm64()
354357
elif arch == 'Intel':
355358
return _build_import_library_x86()
356359
else:
@@ -412,6 +415,26 @@ def _build_import_library_amd64():
412415
cmd = ['dlltool', '-d', def_file, '-l', out_file]
413416
subprocess.check_call(cmd)
414417

418+
def _build_import_library_arm64():
419+
out_exists, out_file = _check_for_import_lib()
420+
if out_exists:
421+
log.debug('Skip building import library: "%s" exists', out_file)
422+
return
423+
424+
# get the runtime dll for which we are building import library
425+
dll_file = find_python_dll()
426+
log.info('Building import library (arch=ARM64): "%s" (from %s)' %
427+
(out_file, dll_file))
428+
429+
# generate symbol list from this library
430+
def_name = "python%d%d.def" % tuple(sys.version_info[:2])
431+
def_file = os.path.join(sys.prefix, 'libs', def_name)
432+
generate_def(dll_file, def_file)
433+
434+
# generate import library from this symbol list
435+
cmd = ['dlltool', '-d', def_file, '-l', out_file]
436+
subprocess.check_call(cmd)
437+
415438
def _build_import_library_x86():
416439
""" Build the import libraries for Mingw32-gcc on Windows
417440
"""

‎numpy/distutils/tests/test_mingw32ccompiler.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
import sys
44
import pytest
55
import os
6+
import sysconfig
67

78
from numpy.distutils import mingw32ccompiler
89

910

1011
@pytest.mark.skipif(sys.platform != 'win32', reason='win32 only test')
1112
@pytest.mark.skipif(not os.path.exists(os.path.join(sys.prefix, 'libs')),
1213
reason="test requires mingw library layout")
14+
@pytest.mark.skipif(sysconfig.get_platform() == 'win-arm64', reason='mingw GNU objdump does not understand arm64 binary format yet')
1315
def test_build_import():
1416
'''Test the mingw32ccompiler.build_import_library, which builds a
1517
`python.a` from the MSVC `python.lib`

‎numpy/random/tests/test_extending.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
)
5555
@pytest.mark.skipif(IS_WASM, reason="Can't start subprocess")
5656
@pytest.mark.skipif(cython is None, reason="requires cython")
57+
@pytest.mark.skipif(sysconfig.get_platform() == 'win-arm64', reason='Meson unable to find MSVC linker on win-arm64')
5758
@pytest.mark.slow
5859
def test_cython(tmp_path):
5960
import glob

‎pyproject.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ select = "*-win32"
188188
config-settings = "setup-args=--vsenv setup-args=-Dallow-noblas=true build-dir=build"
189189
repair-wheel-command = ""
190190

191+
[[tool.cibuildwheel.overrides]]
192+
select = "*-win_arm64"
193+
config-settings = "setup-args=--vsenv setup-args=-Dallow-noblas=true build-dir=build"
194+
repair-wheel-command = ""
195+
191196
[[tool.cibuildwheel.overrides]]
192197
select = "*pyodide*"
193198
before-test = "pip install -r {project}/requirements/emscripten_test_requirements.txt"

0 commit comments

Comments
 (0)