diff --git a/.github/workflows/publish-python.yaml b/.github/workflows/publish-python.yaml index 6c81bbf21..6a2db85a8 100644 --- a/.github/workflows/publish-python.yaml +++ b/.github/workflows/publish-python.yaml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/publish-sdk-python.yaml b/.github/workflows/publish-sdk-python.yaml index 5545d6949..59ab0e785 100644 --- a/.github/workflows/publish-sdk-python.yaml +++ b/.github/workflows/publish-sdk-python.yaml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/bindings/nostr-ffi/bindings-python/scripts/generate-linux-aarch64.sh b/bindings/nostr-ffi/bindings-python/scripts/generate-linux-aarch64.sh new file mode 100755 index 000000000..45be20151 --- /dev/null +++ b/bindings/nostr-ffi/bindings-python/scripts/generate-linux-aarch64.sh @@ -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!" diff --git a/bindings/nostr-sdk-ffi/bindings-python/scripts/generate-linux-aarch64.sh b/bindings/nostr-sdk-ffi/bindings-python/scripts/generate-linux-aarch64.sh new file mode 100755 index 000000000..eec5699d5 --- /dev/null +++ b/bindings/nostr-sdk-ffi/bindings-python/scripts/generate-linux-aarch64.sh @@ -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!"