Skip to content

Commit

Permalink
ci: add support to aarch64 python wheels
Browse files Browse the repository at this point in the history
Closes #181
  • Loading branch information
yukibtc committed Nov 13, 2023
1 parent 0b068fa commit ba6cfad
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 26 deletions.
55 changes: 42 additions & 13 deletions .github/workflows/publish-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,44 @@ jobs:
name: nostr_protocol-manylinux2014-x86_64-${{ matrix.python }}
path: /home/runner/work/nostr/nostr/bindings/nostr-ffi/bindings-python/dist/*.whl

build-manylinux_2_31-aarch64-wheels:
name: "Build manylinux_2_31 aarch64 wheel"
runs-on: ubuntu-20.04
strategy:
matrix:
python: ["3.8", "3.9", "3.10"]
defaults:
run:
working-directory: bindings/nostr-ffi/bindings-python
steps:
- name: "Checkout"
uses: actions/checkout@v3

- uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: "Setup Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install gcc-aarch64-linux-gnu
run: |
sudo apt-get update -y
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: "Generate nostr.py and binaries"
run: bash ./scripts/generate-linux-aarch64.sh

- name: "Build wheel"
run: python3 setup.py bdist_wheel --plat-name manylinux_2_31_aarch64 --verbose

- uses: actions/upload-artifact@v3
with:
name: nostr_protocol-manylinux_2_31_aarch64-${{ matrix.python }}
path: /home/runner/work/nostr/nostr/bindings/nostr-ffi/bindings-python/dist/*.whl

build-macos-arm64-wheels:
name: "Build macOS arm64 wheel"
runs-on: macos-13
Expand All @@ -54,10 +92,7 @@ jobs:
working-directory: bindings/nostr-ffi/bindings-python
strategy:
matrix:
python:
- "3.8"
- "3.9"
- "3.10"
python: ["3.8", "3.9", "3.10"]
steps:
- name: "Checkout"
uses: actions/checkout@v3
Expand Down Expand Up @@ -91,10 +126,7 @@ jobs:
working-directory: bindings/nostr-ffi/bindings-python
strategy:
matrix:
python:
- "3.8"
- "3.9"
- "3.10"
python: ["3.8", "3.9", "3.10"]
steps:
- name: "Checkout"
uses: actions/checkout@v3
Expand Down Expand Up @@ -127,10 +159,7 @@ jobs:
working-directory: bindings/nostr-ffi/bindings-python
strategy:
matrix:
python:
- "3.8"
- "3.9"
- "3.10"
python: ["3.8", "3.9", "3.10"]
steps:
- name: "Checkout"
uses: actions/checkout@v3
Expand Down Expand Up @@ -158,7 +187,7 @@ jobs:
defaults:
run:
working-directory: bindings/nostr-ffi/bindings-python
needs: [build-manylinux2014-x86_64-wheels, build-macos-arm64-wheels, build-macos-x86_64-wheels, build-windows-wheels]
needs: [build-manylinux2014-x86_64-wheels, build-manylinux_2_31-aarch64-wheels, build-macos-arm64-wheels, build-macos-x86_64-wheels, build-windows-wheels]
steps:
- name: "Checkout"
uses: actions/checkout@v3
Expand Down
55 changes: 42 additions & 13 deletions .github/workflows/publish-sdk-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,44 @@ jobs:
name: nostr_sdk-manylinux2014-x86_64-${{ matrix.python }}
path: /home/runner/work/nostr/nostr/bindings/nostr-sdk-ffi/bindings-python/dist/*.whl

build-manylinux_2_31-aarch64-wheels:
name: "Build manylinux_2_31 aarch64 wheel"
runs-on: ubuntu-20.04
strategy:
matrix:
python: ["3.8", "3.9", "3.10"]
defaults:
run:
working-directory: bindings/nostr-sdk-ffi/bindings-python
steps:
- name: "Checkout"
uses: actions/checkout@v3

- uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: "Setup Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install gcc-aarch64-linux-gnu
run: |
sudo apt-get update -y
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: "Generate nostr_sdk.py and binaries"
run: bash ./scripts/generate-linux-aarch64.sh

- name: "Build wheel"
run: python3 setup.py bdist_wheel --plat-name manylinux_2_31_aarch64 --verbose

- uses: actions/upload-artifact@v3
with:
name: nostr_sdk-manylinux_2_31_aarch64-${{ matrix.python }}
path: /home/runner/work/nostr/nostr/bindings/nostr-sdk-ffi/bindings-python/dist/*.whl

build-macos-arm64-wheels:
name: "Build macOS arm64 wheel"
runs-on: macos-13
Expand All @@ -54,10 +92,7 @@ jobs:
working-directory: bindings/nostr-sdk-ffi/bindings-python
strategy:
matrix:
python:
- "3.8"
- "3.9"
- "3.10"
python: ["3.8", "3.9", "3.10"]
steps:
- name: "Checkout"
uses: actions/checkout@v3
Expand Down Expand Up @@ -91,10 +126,7 @@ jobs:
working-directory: bindings/nostr-sdk-ffi/bindings-python
strategy:
matrix:
python:
- "3.8"
- "3.9"
- "3.10"
python: ["3.8", "3.9", "3.10"]
steps:
- name: "Checkout"
uses: actions/checkout@v3
Expand Down Expand Up @@ -127,10 +159,7 @@ jobs:
working-directory: bindings/nostr-sdk-ffi/bindings-python
strategy:
matrix:
python:
- "3.8"
- "3.9"
- "3.10"
python: ["3.8", "3.9", "3.10"]
steps:
- name: "Checkout"
uses: actions/checkout@v3
Expand Down Expand Up @@ -158,7 +187,7 @@ jobs:
defaults:
run:
working-directory: bindings/nostr-sdk-ffi/bindings-python
needs: [build-manylinux2014-x86_64-wheels, build-macos-arm64-wheels, build-macos-x86_64-wheels, build-windows-wheels]
needs: [build-manylinux2014-x86_64-wheels, build-manylinux_2_31-aarch64-wheels, build-macos-arm64-wheels, build-macos-x86_64-wheels, build-windows-wheels]
steps:
- name: "Checkout"
uses: actions/checkout@v3
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -euo pipefail
python --version
pip install -r requirements.txt

echo "Generating nostr.py..."
cd ../
cargo run -p uniffi-bindgen generate src/nostr.udl --language python --no-format -o bindings-python/src/nostr/

echo "Generating native binaries..."
rustup target add aarch64-unknown-linux-gnu
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc cargo build --release --target aarch64-unknown-linux-gnu

echo "Copying linux libnostr_ffi.so..."
cp ../../target/aarch64-unknown-linux-gnu/release/libnostr_ffi.so bindings-python/src/nostr/

echo "All done!"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -euo pipefail
python --version
pip install -r requirements.txt

echo "Generating nostr_sdk.py..."
cd ../
cargo run -p uniffi-bindgen generate src/nostr_sdk.udl --language python --no-format -o bindings-python/src/nostr_sdk/

echo "Generating native binaries..."
rustup target add aarch64-unknown-linux-gnu
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc cargo build --release --target aarch64-unknown-linux-gnu

echo "Copying linux libnostr_sdk_ffi.so..."
cp ../../target/aarch64-unknown-linux-gnu/release/libnostr_sdk_ffi.so bindings-python/src/nostr_sdk/

echo "All done!"

0 comments on commit ba6cfad

Please sign in to comment.