Skip to content

Commit

Permalink
ci: adj. python scripts and actions
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
  • Loading branch information
yukibtc committed Sep 19, 2024
1 parent ddd3d1d commit 8773118
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 45 deletions.
22 changes: 6 additions & 16 deletions .github/workflows/publish-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
20 changes: 5 additions & 15 deletions .github/workflows/publish-sdk-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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!"
Original file line number Diff line number Diff line change
@@ -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!"
Original file line number Diff line number Diff line change
Expand Up @@ -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 ../
Expand Down

0 comments on commit 8773118

Please sign in to comment.