Skip to content

Commit 6ebe82a

Browse files
committed
Add ARM64 Windows wheels to be tested and published
Fix Windows platform detection This architecture may become more common in the future, I'd rather support it now just in case.
1 parent 38978db commit 6ebe82a

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

.github/workflows/python-package.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ jobs:
118118
- os: "windows-latest"
119119
python-version: "3.10"
120120
architecture: "x86"
121+
- os: "windows-11-arm"
122+
python-version: "3.11"
123+
architecture: "arm64"
121124
fail-fast: false
122125

123126
steps:

build_sdl.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
from __future__ import annotations
55

6+
import functools
67
import io
78
import logging
89
import os
9-
import platform
1010
import re
1111
import shutil
1212
import subprocess
@@ -28,7 +28,18 @@
2828
logger = logging.getLogger(__name__)
2929

3030

31-
BIT_SIZE, LINKAGE = platform.architecture()
31+
RE_MACHINE = re.compile(r".*\((.+)\)\]")
32+
33+
34+
@functools.cache
35+
def python_machine() -> str:
36+
"""Return the Python machine architecture (e.g. 'i386', 'AMD64', 'ARM64')."""
37+
# Only needs to function correctly for Windows platforms.
38+
match = RE_MACHINE.match(sys.version)
39+
assert match, sys.version
40+
(machine,) = match.groups()
41+
return {"Intel": "i386"}.get(machine, machine)
42+
3243

3344
# Reject versions of SDL older than this, update the requirements in the readme if you change this.
3445
SDL_MIN_VERSION = (3, 2, 0)
@@ -386,10 +397,10 @@ def get_cdef() -> tuple[str, dict[str, str]]:
386397
# Bundle the Windows SDL DLL.
387398
if sys.platform == "win32" and SDL_BUNDLE_PATH is not None:
388399
include_dirs.append(str(SDL_INCLUDE))
389-
ARCH_MAPPING = {"32bit": "x86", "64bit": "x64"}
390-
SDL_LIB_DIR = Path(SDL_BUNDLE_PATH, "lib/", ARCH_MAPPING[BIT_SIZE])
400+
ARCH_MAPPING = {"i386": "x86", "AMD64": "x64", "ARM64": "arm64"}
401+
SDL_LIB_DIR = Path(SDL_BUNDLE_PATH, "lib/", ARCH_MAPPING[python_machine()])
391402
library_dirs.append(str(SDL_LIB_DIR))
392-
SDL_LIB_DEST = Path("tcod", ARCH_MAPPING[BIT_SIZE])
403+
SDL_LIB_DEST = Path("tcod", ARCH_MAPPING[python_machine()])
393404
SDL_LIB_DEST.mkdir(exist_ok=True)
394405
SDL_LIB_DEST_FILE = SDL_LIB_DEST / "SDL3.dll"
395406
SDL_LIB_FILE = SDL_LIB_DIR / "SDL3.dll"

0 commit comments

Comments
 (0)