Skip to content

Commit 13e7e4e

Browse files
authored
Support Windows on ARM64 (#268)
* Support Windows on ARM64 * Update workflow * Fix type annotations * Updated the docs for gcc requirements * Fix platform for Windows
1 parent 0b66b4f commit 13e7e4e

File tree

8 files changed

+27
-25
lines changed

8 files changed

+27
-25
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,14 @@ jobs:
7979
python setup.py bdist_wheel --plat-name win-amd64
8080
- run: |
8181
git clean -fdx wasmtime build
82-
python ci/download-wasmtime.py musl x86_64
82+
python ci/download-wasmtime.py win32 arm64
8383
python ci/build-rust.py
84-
python setup.py bdist_wheel --plat-name musllinux_1_2_x86_64
85-
86-
# Build an "any" wheel with:
87-
#
88-
# * MinGW
89-
#
90-
# because at this time I don't know what the `--plat-name` tags supported on
91-
# PyPI are for these platforms. Our hope is that any platform not matching
92-
# the above `--plat-name` arguments will install this `any` wheel instead,
93-
# and then when the wheel runs it'll dynamically select from the available
94-
# shared libraries.
84+
python setup.py bdist_wheel --plat-name win-arm64
9585
- run: |
9686
git clean -fdx wasmtime build
97-
python ci/download-wasmtime.py win32 x86_64
87+
python ci/download-wasmtime.py musl x86_64
9888
python ci/build-rust.py
99-
python setup.py bdist_wheel
89+
python setup.py bdist_wheel --plat-name musllinux_1_2_x86_64
10090
10191
- uses: actions/upload-artifact@v4
10292
with:

CONTRIBUTING.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ Otherwise if you have a local checkout of Wasmtime you can symlink its
2424
`libwasmtime.so` (or equivalent) to `wasmtime/linux-x86_64/_libwasmtime.so` (or
2525
equivalent).
2626

27-
Next the bindings generation requires compiling some Rust code to WebAssembly,
28-
which can be done with:
27+
Next the bindings generation requires compiling some Rust code to WebAssembly.
28+
This requires the `wasip1` Rust target be installed (`rustup target add wasm32-wasip1`)
29+
as well as `wasm-tools` (`cargo install wasm-tools`), and then run:
2930

3031
```sh
3132
$ python ci/build-rust.py
@@ -39,6 +40,12 @@ $ pip install -e ".[testing]"
3940

4041
## Testing
4142

43+
On Windows, the below will require `gcc` to be installed locally and on the PATH.
44+
The easiest way to do this is via an installer such as `https://github.com/msys2/msys2-installer/releases/download/2024-12-08/msys2-x86_64-20241208.exe`,
45+
and then in the MSYS2 terminal run the command `pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain` to install GCC. Put `C:\msys64\ucrt64\bin` (or
46+
wherever you installed GCC to) on the end of the PATH (if earlier on the PATH its
47+
version of Python may get picked up before the desired version).
48+
4249
After you've completed the set up steps, you can run the tests locally with
4350
`pytest`:
4451

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ To install `wasmtime-py`, run this command in your terminal:
2727
$ pip install wasmtime
2828
```
2929

30-
The package currently supports 64-bit builds of Python 3.9+ on x86\_64 Windows,
31-
macOS, and Linux, as well as on arm64 macOS and Linux.
30+
The package currently supports 64-bit builds of Python 3.9+ on Windows,
31+
macOS, and Linux, for x86\_64 and arm64 architectures.
3232

3333
## Versioning
3434

ci/download-wasmtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def main(platform, arch):
2121

2222
if arch == 'AMD64':
2323
arch = 'x86_64'
24-
if arch == 'arm64':
24+
if arch == 'arm64' or arch == 'ARM64':
2525
arch = 'aarch64'
2626
dirname = '{}-{}'.format(platform, arch)
2727
if platform == 'linux' or platform == 'musl':

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
'pytest',
4343
'pycparser',
4444
'pytest-mypy',
45-
'componentize-py',
45+
# componentize-py only support x86_64 builds on Windows
46+
# platform.machine() on Windows returns 'AMD64' for x86_64
47+
"componentize-py; platform_system != 'Windows' or platform_machine == 'AMD64'",
4648
],
4749
},
4850
classifiers=[

tests/bindgen/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import sys
22
import pytest
3+
import platform
34

4-
# componentize-py requires Python 3.10
5-
if sys.version_info < (3, 10):
5+
is_win_arm64 = platform.system() == 'Windows' and platform.machine() == 'ARM64'
6+
7+
# componentize-py requires Python 3.10, and doesn't support Windows on ARM64
8+
if sys.version_info < (3, 10) or is_win_arm64:
69
pytest.skip("skipping componentize-py tests", allow_module_level=True)

wasmtime/_ffi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
machine = platform.machine()
2121
if machine == 'AMD64':
2222
machine = 'x86_64'
23-
if machine == 'arm64':
23+
if machine == 'arm64' or machine == 'ARM64':
2424
machine = 'aarch64'
2525
if machine != 'x86_64' and machine != 'aarch64':
2626
raise RuntimeError("unsupported architecture for wasmtime: {}".format(machine))

wasmtime/_func.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ def extract_val(val: Val) -> Any:
185185
return val
186186

187187

188-
@ffi.wasmtime_func_callback_t # type: ignore
189-
def trampoline(idx, caller, params, nparams, results, nresults):
188+
@ffi.wasmtime_func_callback_t
189+
def trampoline(idx, caller, params, nparams, results, nresults): # type: ignore
190190
caller = Caller(caller)
191191
try:
192192
func, result_tys, access_caller = FUNCTIONS.get(idx or 0)

0 commit comments

Comments
 (0)