From 877311843a5039eb6b2c3768d822b4d0877c198a Mon Sep 17 00:00:00 2001 From: Yuki Kishimoto Date: Thu, 19 Sep 2024 11:40:12 -0400 Subject: [PATCH] ci: adj. python scripts and actions Signed-off-by: Yuki Kishimoto --- .github/workflows/publish-python.yaml | 22 +++++-------------- .github/workflows/publish-sdk-python.yaml | 20 +++++------------ .../scripts/generate-linux-x86_64.sh | 13 +++++------ .../scripts/generate-linux-x86_64.sh | 11 +++++----- .../scripts/generate-windows.sh | 3 +-- 5 files changed, 24 insertions(+), 45 deletions(-) diff --git a/.github/workflows/publish-python.yaml b/.github/workflows/publish-python.yaml index 306f61fb8..e584e90d6 100644 --- a/.github/workflows/publish-python.yaml +++ b/.github/workflows/publish-python.yaml @@ -15,36 +15,30 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python: - - cp39-cp39 - - cp310-cp310 - - cp311-cp311 - - cp312-cp312 + python: ["3.9", "3.10", "3.11", "3.12"] defaults: run: working-directory: bindings/nostr-ffi/bindings-python container: image: quay.io/pypa/manylinux_2_28_x86_64 - env: - PLAT: manylinux_2_28_x86_64 - PYBIN: "/opt/python/${{ matrix.python }}/bin" steps: - name: "Checkout" uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 + - name: "Setup Python" + uses: actions/setup-python@v4 with: - toolchain: stable + python-version: ${{ matrix.python }} - name: "Generate nostr.py and binaries" run: bash ./scripts/generate-linux-x86_64.sh - name: "Build wheel" - run: ${PYBIN}/python setup.py bdist_wheel --plat-name manylinux_2_28_x86_64 --verbose + run: python setup.py bdist_wheel --plat-name manylinux_2_28_x86_64 --verbose - uses: actions/upload-artifact@v3 with: - name: nostr_sdk-manylinux_2_28_x86_64-${{ matrix.python }} + name: nostr_protocol-manylinux_2_28_x86_64-${{ matrix.python }} path: /home/runner/work/nostr/nostr/bindings/nostr-ffi/bindings-python/dist/*.whl build-linux-aarch64: @@ -60,10 +54,6 @@ jobs: - name: "Checkout" uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - name: "Setup Python" uses: actions/setup-python@v4 with: diff --git a/.github/workflows/publish-sdk-python.yaml b/.github/workflows/publish-sdk-python.yaml index 7313ab36c..79af84622 100644 --- a/.github/workflows/publish-sdk-python.yaml +++ b/.github/workflows/publish-sdk-python.yaml @@ -15,32 +15,26 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python: - - cp39-cp39 - - cp310-cp310 - - cp311-cp311 - - cp312-cp312 + python: ["3.9", "3.10", "3.11", "3.12"] defaults: run: working-directory: bindings/nostr-sdk-ffi/bindings-python container: image: quay.io/pypa/manylinux_2_28_x86_64 - env: - PLAT: manylinux_2_28_x86_64 - PYBIN: "/opt/python/${{ matrix.python }}/bin" steps: - name: "Checkout" uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 + - name: "Setup Python" + uses: actions/setup-python@v4 with: - toolchain: stable + python-version: ${{ matrix.python }} - name: "Generate nostr_sdk.py and binaries" run: bash ./scripts/generate-linux-x86_64.sh - name: "Build wheel" - run: ${PYBIN}/python setup.py bdist_wheel --plat-name manylinux_2_28_x86_64 --verbose + run: python setup.py bdist_wheel --plat-name manylinux_2_28_x86_64 --verbose - uses: actions/upload-artifact@v3 with: @@ -60,10 +54,6 @@ jobs: - name: "Checkout" uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - name: "Setup Python" uses: actions/setup-python@v4 with: diff --git a/bindings/nostr-ffi/bindings-python/scripts/generate-linux-x86_64.sh b/bindings/nostr-ffi/bindings-python/scripts/generate-linux-x86_64.sh index d82d4139f..1e6f6c8bb 100644 --- a/bindings/nostr-ffi/bindings-python/scripts/generate-linux-x86_64.sh +++ b/bindings/nostr-ffi/bindings-python/scripts/generate-linux-x86_64.sh @@ -1,18 +1,17 @@ #!/usr/bin/env bash set -euo pipefail -${PYBIN}/python --version -${PYBIN}/pip install -r requirements.txt - -cd ../ +python --version +pip install -r requirements.txt echo "Generating native binaries..." -cargo build --release +rustup target add x86_64-unknown-linux-gnu +cargo build --release --target x86_64-unknown-linux-gnu echo "Generating nostr.py..." -cargo run -p uniffi-bindgen generate --library ../../target/release/libnostr_ffi.so --language python --no-format -o bindings-python/src/nostr/ +cargo run -p uniffi-bindgen generate --library ../../target/x86_64-unknown-linux-gnu/release/libnostr_ffi.so --language python --no-format -o bindings-python/src/nostr/ echo "Copying linux libnostr_ffi.so..." -cp ../../target/release/libnostr_ffi.so bindings-python/src/nostr/ +cp ../../target/x86_64-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-x86_64.sh b/bindings/nostr-sdk-ffi/bindings-python/scripts/generate-linux-x86_64.sh index 23e6e083b..f54efc88b 100644 --- a/bindings/nostr-sdk-ffi/bindings-python/scripts/generate-linux-x86_64.sh +++ b/bindings/nostr-sdk-ffi/bindings-python/scripts/generate-linux-x86_64.sh @@ -1,17 +1,18 @@ #!/usr/bin/env bash set -euo pipefail -${PYBIN}/python --version -${PYBIN}/pip install -r requirements.txt +python --version +pip install -r requirements.txt echo "Generating native binaries..." -cargo build --release +rustup target add x86_64-unknown-linux-gnu +cargo build --release --target x86_64-unknown-linux-gnu echo "Generating nostr_sdk.py..." cd ../ -cargo run -p uniffi-bindgen generate --library ../../target/release/libnostr_sdk_ffi.so --language python --no-format -o bindings-python/src/nostr-sdk/ +cargo run -p uniffi-bindgen generate --library ../../target/x86_64-unknown-linux-gnu/release/libnostr_sdk_ffi.so --language python --no-format -o bindings-python/src/nostr-sdk/ echo "Copying linux libnostr_sdk_ffi.so..." -cp ../../target/release/libnostr_sdk_ffi.so bindings-python/src/nostr-sdk/ +cp ../../target/x86_64-unknown-linux-gnu/release/libnostr_sdk_ffi.so bindings-python/src/nostr-sdk/ echo "All done!" diff --git a/bindings/nostr-sdk-ffi/bindings-python/scripts/generate-windows.sh b/bindings/nostr-sdk-ffi/bindings-python/scripts/generate-windows.sh index 219b1afbf..b9e136fb5 100644 --- a/bindings/nostr-sdk-ffi/bindings-python/scripts/generate-windows.sh +++ b/bindings/nostr-sdk-ffi/bindings-python/scripts/generate-windows.sh @@ -6,8 +6,7 @@ pip install --user -r requirements.txt echo "Generating native binaries..." rustup target add x86_64-pc-windows-msvc -# TODO: enable all features -cargo build --release --target x86_64-pc-windows-msvc --features lmdb +cargo build --release --target x86_64-pc-windows-msvc echo "Generating nostr_sdk.py..." cd ../