Skip to content

Commit e01cb82

Browse files
committed
Add Windows ARM64 support
- objectbox-clib: win_arm64 wheel with the ARM64 library (objectbox-c 5.x) - Windows: select the library by the interpreter's architecture (sysconfig.get_platform()), e.g. x64 Python (emulated) on Windows ARM64 needs the x64 library - GitHub Actions: test on Windows ARM64 (windows-11-arm, Python 3.12)
1 parent 152315c commit e01cb82

9 files changed

Lines changed: 30 additions & 13 deletions

File tree

‎.github/workflows/test.yaml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ jobs:
1616
python: "3.7" # Prevent "The version '3.7' with architecture 'arm64' was not found for macOS 14.4.1"
1717
- os: "ubuntu"
1818
python: "3.7" # Python 3.7 is not available in ubuntu-latest i.e. version 24.04
19-
runs-on: ${{ matrix.os }}-latest
19+
include:
20+
- os: "windows-arm64"
21+
runner: "windows-11-arm" # Python for Windows ARM64 is available from 3.11
22+
python: "3.12"
23+
runs-on: ${{ matrix.runner || format('{0}-latest', matrix.os) }}
2024

2125
steps:
2226
- uses: actions/checkout@v7

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ Two pip packages are built from this repository:
4646

4747
## CI
4848

49-
GitHub Actions (`.github/workflows/test.yaml`) runs `make depend && make test` on Linux/Windows/macOS for Python 3.7–3.12, so code must stay compatible with Python 3.7. GitLab CI (`.gitlab-ci.yml`) builds the wheels with `make depend test build` on Linux x64, then tests the built `objectbox` wheel (installed in place of the source packages, which are deleted; the platform's `objectbox-clib` wheel is picked via `--find-links dist`) on Linux x64 (Python 3.7–3.12 Docker images), Linux armv7hf and aarch64, macOS (arm64 runner; the macOS library is universal) and Windows x64.
49+
GitHub Actions (`.github/workflows/test.yaml`) runs `make depend && make test` on Linux/Windows/macOS for Python 3.7–3.12 (plus Windows ARM64 with Python 3.12), so code must stay compatible with Python 3.7. GitLab CI (`.gitlab-ci.yml`) builds the wheels with `make depend test build` on Linux x64, then tests the built `objectbox` wheel (installed in place of the source packages, which are deleted; the platform's `objectbox-clib` wheel is picked via `--find-links dist`) on Linux x64 (Python 3.7–3.12 Docker images), Linux armv7hf and aarch64, macOS (arm64 runner; the macOS library is universal) and Windows x64.

‎CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ ObjectBox Python ChangeLog
55
--------------------
66

77
* Update to ObjectBox C library 5.3.2 (was 4.0.0), see https://github.com/objectbox/objectbox-c/blob/main/CHANGELOG.md;
8+
* New platform: Windows ARM64 (64-bit ARM, e.g. Snapdragon-based devices)
89
* Log callback (`log_callback`): the log level values passed to the callback changed (see `LogLevel`, now also `Trace`);
910
code comparing against `LogLevel` members is not affected.
1011
* The ObjectBox C library is now a separate package, `objectbox-clib`, which is installed automatically as a dependency.
1112
There is a wheel for each platform, so only the library for your platform is downloaded (was: libraries for all platforms):
12-
Linux x86_64, aarch64 and armv7l (glibc 2.28+), macOS 11+ (universal) and Windows x64.
13+
Linux x86_64, aarch64 and armv7l (glibc 2.28+), macOS 11+ (universal) and Windows x64 and ARM64 (new).
1314
**Breaking:** Linux ARMv6hf (e.g. Raspberry Pi Zero/1) is no longer supported, as PyPI does not support wheels for it.
1415
* Linux: support 32-bit Python on a 64-bit kernel, e.g. Raspberry Pi OS 32-bit on a Raspberry Pi 4/5
1516
(64-bit kernel by default); this failed to load the library before.

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Feature Highlights
3535
* Linux ARMv8 (e.g. Raspberry PI 4, 5, etc.)
3636
* MacOS x86-64 and arm64 (Intel 64-bit and Apple Silicon)
3737
* Windows x86-64 (64-bit)
38+
* Windows ARM64
3839

3940
Code Example: CRUD (Create, Read, Update, Delete)
4041
-------------------------------------------------

‎download-c-lib.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
# windows
3131
"AMD64/objectbox.dll": "windows-x64.zip",
32+
"ARM64/objectbox.dll": "windows-arm64.zip",
3233
}
3334

3435
def url_for(rel_path: str) -> str:

‎objectbox/c.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import os
1818
import platform
1919
import sys
20+
import sysconfig
2021
from objectbox.version import Version
2122
from typing import *
2223
import numpy as np
@@ -47,6 +48,11 @@ def lib_dir_name() -> str:
4748
"""Returns the name of the library directory (inside objectbox_clib/lib) for the current platform."""
4849
if platform.system() == 'Darwin':
4950
return 'macos-universal'
51+
if platform.system() == 'Windows':
52+
# Use the architecture the Python interpreter was built for (derived from sys.version), e.g. "win-arm64";
53+
# the library must match the Python process, which may differ from the OS (e.g. x64 Python on Windows ARM64).
54+
windows_dirs = {'win-amd64': 'AMD64', 'win-arm64': 'ARM64'}
55+
return windows_dirs.get(sysconfig.get_platform(), platform.machine())
5056
machine = platform.machine()
5157
# platform.machine() reports the kernel's architecture, but the library must match the (Python) process.
5258
# These differ for a 32-bit Python on a 64-bit kernel, e.g. Raspberry Pi OS 32-bit on a Raspberry Pi 4/5

‎objectbox_clib/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pip install objectbox
99
```
1010

1111
There is a wheel for each supported platform, so only the library for your platform is installed:
12-
Linux x86_64, aarch64 and armv7l (glibc 2.28+), macOS 11+ (Intel and Apple Silicon) and Windows x64.
12+
Linux x86_64, aarch64 and armv7l (glibc 2.28+), macOS 11+ (Intel and Apple Silicon) and Windows (x64 and ARM64).
1313

1414
The version of this package is the version of the ObjectBox C library it contains.
1515

‎setup-clib.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"manylinux_2_28_armv7l": "armv7l",
3030
"macosx_11_0_universal2": "macos-universal",
3131
"win_amd64": "AMD64",
32+
"win_arm64": "ARM64",
3233
}
3334

3435

‎tests/test_clib_package.py‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,20 @@ def test_clib_platform_wheel():
4040
"Only the library for this platform shall be installed"
4141

4242

43-
@pytest.mark.parametrize("system, machine, maxsize, expected", [
44-
("Linux", "x86_64", 2 ** 63 - 1, "x86_64"),
45-
("Linux", "aarch64", 2 ** 63 - 1, "aarch64"),
46-
("Linux", "aarch64", 2 ** 31 - 1, "armv7l"), # 32-bit Python on a 64-bit kernel (e.g. Raspberry Pi OS 32-bit)
47-
("Linux", "armv7l", 2 ** 31 - 1, "armv7l"),
48-
("Windows", "AMD64", 2 ** 63 - 1, "AMD64"),
49-
("Darwin", "arm64", 2 ** 63 - 1, "macos-universal"),
50-
("Darwin", "x86_64", 2 ** 63 - 1, "macos-universal"),
43+
@pytest.mark.parametrize("system, machine, maxsize, sys_platform, expected", [
44+
("Linux", "x86_64", 2 ** 63 - 1, "linux-x86_64", "x86_64"),
45+
("Linux", "aarch64", 2 ** 63 - 1, "linux-aarch64", "aarch64"),
46+
("Linux", "aarch64", 2 ** 31 - 1, "linux-aarch64", "armv7l"), # 32-bit Python on a 64-bit kernel (e.g. Raspberry Pi OS 32-bit)
47+
("Linux", "armv7l", 2 ** 31 - 1, "linux-armv7l", "armv7l"),
48+
("Windows", "AMD64", 2 ** 63 - 1, "win-amd64", "AMD64"),
49+
("Windows", "ARM64", 2 ** 63 - 1, "win-arm64", "ARM64"),
50+
("Windows", "ARM64", 2 ** 63 - 1, "win-amd64", "AMD64"), # x64 Python (emulated) on Windows ARM64
51+
("Darwin", "arm64", 2 ** 63 - 1, "macosx-11.0-arm64", "macos-universal"),
52+
("Darwin", "x86_64", 2 ** 63 - 1, "macosx-11.0-x86_64", "macos-universal"),
5153
])
52-
def test_lib_dir_name(monkeypatch, system, machine, maxsize, expected):
54+
def test_lib_dir_name(monkeypatch, system, machine, maxsize, sys_platform, expected):
5355
monkeypatch.setattr(c.platform, "system", lambda: system)
5456
monkeypatch.setattr(c.platform, "machine", lambda: machine)
5557
monkeypatch.setattr(c.sys, "maxsize", maxsize)
58+
monkeypatch.setattr(c.sysconfig, "get_platform", lambda: sys_platform)
5659
assert c.lib_dir_name() == expected

0 commit comments

Comments
 (0)