From 5608c809c7f5ffa18a35113ce49fe1acf65f1f0f Mon Sep 17 00:00:00 2001 From: Emanuele Giaquinta Date: Tue, 16 Jan 2024 08:51:55 +0200 Subject: [PATCH] Build linux aarch64 and armv7 wheels Signed-off-by: Emanuele Giaquinta --- .github/workflows/release.yml | 54 +++++++++++++++++++++++++++++++++++ tests/requirements.txt | 5 ++-- tests/test_datetime.py | 29 +++++++++++++++++-- 3 files changed, 82 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a73cf728..36ec0368 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,6 +46,59 @@ jobs: path: target/wheels retention-days: 1 + build-linux-cross: + name: Build Linux wheel + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + target: [ + { + platform: 'linux/arm64', + target: 'aarch64-unknown-linux-gnu', + maturin_args: '', + }, + { + platform: 'linux/arm/v7', + target: 'armv7-unknown-linux-gnueabihf', + maturin_args: '--no-default-features', + }, + ] + env: + CC: "gcc" + CFLAGS: "-O2" + LDFLAGS: "-O2 -flto -Wl,--as-needed" + CARGO_UNSTABLE_SPARSE_REGISTRY: "true" + + steps: + - uses: actions/checkout@v4 + - uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target.target }} + rust-toolchain: ${{ env.RUST_TOOLCHAIN }} + manylinux: auto + args: --release --strip -i python${{ matrix.python-version }} ${{ matrix.target.maturin_args }} + - uses: docker/setup-qemu-action@v3 + - run: | + docker run \ + --rm \ + -v "$GITHUB_WORKSPACE":/work \ + -w /work \ + --platform ${{ matrix.target.platform }} \ + python:${{ matrix.python-version }}-bookworm \ + bash -e -c ' + python3 -m venv .venv + .venv/bin/pip install -U pip wheel + .venv/bin/pip install -r tests/requirements.txt + .venv/bin/pip install ormsgpack --no-index -f target/wheels + .venv/bin/pytest + ' + - uses: actions/upload-artifact@v3 + with: + name: wheels + path: target/wheels + retention-days: 1 + build-windows: name: Build Windows wheel runs-on: windows-latest @@ -157,6 +210,7 @@ jobs: TWINE_USERNAME: ${{secrets.TWINE_USERNAME}} needs: [ build-linux-x86_64, + build-linux-cross, build-windows, build-macos-x86_64, build-macos-universal, diff --git a/tests/requirements.txt b/tests/requirements.txt index 56ac4f4a..74398fe8 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,7 +1,6 @@ arrow -numpy -pendulum -psutil;sys_platform!="windows" +numpy;platform_machine!="armv7l" +pendulum;platform_machine!="armv7l" pytest pytz xxhash==1.4.3;sys_platform!="windows" and python_version<"3.9" # creates non-compact ASCII for test_str_ascii diff --git a/tests/test_datetime.py b/tests/test_datetime.py index 3dce72d8..340625cb 100644 --- a/tests/test_datetime.py +++ b/tests/test_datetime.py @@ -4,13 +4,21 @@ import sys import msgpack -import pendulum import pytest import pytz from dateutil import tz import ormsgpack +try: + import pendulum +except ImportError: + pendulum_timezone = None + pendulum_UTC = None +else: + pendulum_timezone = pendulum.timezone + pendulum_UTC = pendulum.UTC + if sys.version_info >= (3, 9): import zoneinfo @@ -22,7 +30,14 @@ TIMEZONE_PARAMS = ( - pytest.param(pendulum.timezone, id="pendulum"), + pytest.param( + pendulum_timezone, + id="pendulum", + marks=pytest.mark.skipif( + pendulum_timezone is None, + reason="pendulum not available", + ), + ), pytest.param(pytz.timezone, id="pytz"), pytest.param(tz.gettz, id="dateutil"), pytest.param( @@ -106,7 +121,14 @@ def test_datetime_tz_assume(): "timezone", ( pytest.param(datetime.timezone.utc, id="datetime"), - pytest.param(pendulum.UTC, id="pendulum"), + pytest.param( + pendulum_UTC, + id="pendulum", + marks=pytest.mark.skipif( + pendulum_UTC is None, + reason="pendulum not available", + ), + ), pytest.param(pytz.UTC, id="pytz"), pytest.param(tz.UTC, id="dateutil"), pytest.param( @@ -335,6 +357,7 @@ def test_datetime_utc_z_with_tz(): } +@pytest.mark.skipif(pendulum_timezone is None, reason="pendulum not available") def test_datetime_roundtrip(): """ datetime.datetime parsed by pendulum