Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cibuildwheel to build Python wheels on different platforms #216

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/build-python-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build Python Wheels

on: [push, pull_request]

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-11]

steps:
- uses: actions/checkout@v4

- name: Generate Python bindings
run: bash ./scripts/uniffi_bindgen_generate_python.sh

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_MACOS: "x86_64 arm64 universal2"
CIBW_ARCHS_LINUX: "auto aarch64"
CIBW_BUILD_VERBOSITY: 1
with:
package-dir: ./bindings/python

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
3 changes: 3 additions & 0 deletions bindings/python/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include ./src/ldk_node/libldk_node.dylib
include ./src/ldk_node/libldk_node.so
include ./src/ldk_node/libldk_node.dll
1 change: 1 addition & 0 deletions bindings/python/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ where = src
ldk_node =
*.so
*.dylib
*.dll
13 changes: 12 additions & 1 deletion scripts/uniffi_bindgen_generate_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@ BINDINGS_DIR="./bindings/python/src/ldk_node"
UNIFFI_BINDGEN_BIN="cargo run --manifest-path bindings/uniffi-bindgen/Cargo.toml"

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
DYNAMIC_LIB_PATH="./target/release-smaller/libldk_node.so"
else
elif [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
DYNAMIC_LIB_PATH="./target/release-smaller/libldk_node.dylib"
elif [[ "$OSTYPE" == "msys"* ]]; then
# Windows
DYNAMIC_LIB_PATH="./target/release-smaller/libldk_node.dll"
elif [[ "$OSTYPE" == "cygwin"* ]]; then
# Windows
DYNAMIC_LIB_PATH="./target/release-smaller/libldk_node.dll"
else
echo "Unsupported platform!: $OSTYPE"
exit -1
fi

cargo build --profile release-smaller --features uniffi || exit 1
Expand Down