From cbe251151a2d0faa9e36887235c177ff74f0e3b5 Mon Sep 17 00:00:00 2001 From: Philip Date: Thu, 22 Sep 2022 10:34:51 +0000 Subject: [PATCH] Add support for python linux-arm build via qemu --- .github/workflows/release-pypi.yml | 7 +++++++ build-wheel-linux-arm.sh | 9 +++++++++ release-pypi-linux-arm.sh | 10 ++++++++++ 3 files changed, 26 insertions(+) create mode 100644 build-wheel-linux-arm.sh create mode 100644 release-pypi-linux-arm.sh diff --git a/.github/workflows/release-pypi.yml b/.github/workflows/release-pypi.yml index c9f6e91b3..bf47f9480 100644 --- a/.github/workflows/release-pypi.yml +++ b/.github/workflows/release-pypi.yml @@ -20,6 +20,13 @@ jobs: -e TWINE_USERNAME=__token__ \ -e TWINE_PASSWORD=${{ secrets.PYPI_TOKEN }} \ ubuntu:18.04 /bin/bash /opt/OpenCC/release-pypi-linux.sh + + - name: Build package and upload from docker (Linux ARM) + if: runner.os == 'Linux' + run: bash release-pypi-linux-arm.sh + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - name: Build package and upload (macOS) if: runner.os == 'macOS' diff --git a/build-wheel-linux-arm.sh b/build-wheel-linux-arm.sh new file mode 100644 index 000000000..57ba84617 --- /dev/null +++ b/build-wheel-linux-arm.sh @@ -0,0 +1,9 @@ +apt update && apt install -y build-essential cmake + +# Build and package +pip install -y --no-cache-dir setuptools wheel cmake +python setup.py build_ext bdist_wheel \ + --plat-name manylinux_2_17_aarch64 + +# Cleanup +rm -rf build python/opencc/clib OpenCC.egg-info \ No newline at end of file diff --git a/release-pypi-linux-arm.sh b/release-pypi-linux-arm.sh new file mode 100644 index 000000000..b5eb9da89 --- /dev/null +++ b/release-pypi-linux-arm.sh @@ -0,0 +1,10 @@ +sudo apt-get install qemu binfmt-support qemu-user-static # Install the qemu packages +docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + +for VERSION in 3.7.14 3.8.14 3.9.14 3.10.7; do + docker run --rm -t --platform linux/arm64/v8 -v $PWD:/opencc python:$VERSION sh -c "cd opencc && sh build-wheel-linux-arm.sh" +done + +# Upload to PyPI +python -m pip install twine +python -m twine upload dist/*