Skip to content

Commit fec283e

Browse files
committed
Use CI to build Python wheels on different platforms
1 parent 78dd547 commit fec283e

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build Python Wheels
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build_wheels:
7+
name: Build wheels on ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [ubuntu-20.04, windows-2019, macos-11]
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Generate Python bindings
17+
run: bash ./scripts/uniffi_bindgen_generate_python.sh
18+
19+
- name: Build wheels
20+
uses: pypa/[email protected]
21+
env:
22+
CIBW_ARCHS_MACOS: "x86_64 arm64 universal2"
23+
CIBW_ARCHS_LINUX: "auto aarch64"
24+
CIBW_BUILD_VERBOSITY: 1
25+
with:
26+
package-dir: ./bindings/python
27+
28+
- uses: actions/upload-artifact@v3
29+
with:
30+
path: ./wheelhouse/*.whl

bindings/python/MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include ./src/ldk_node/libldk_node.dylib
2+
include ./src/ldk_node/libldk_node.so
3+
include ./src/ldk_node/libldk_node.dll

bindings/python/setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ where = src
1111
ldk_node =
1212
*.so
1313
*.dylib
14+
*.dll

scripts/uniffi_bindgen_generate_python.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@ BINDINGS_DIR="./bindings/python/src/ldk_node"
33
UNIFFI_BINDGEN_BIN="cargo run --manifest-path bindings/uniffi-bindgen/Cargo.toml"
44

55
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
6+
# Linux
67
DYNAMIC_LIB_PATH="./target/release-smaller/libldk_node.so"
7-
else
8+
elif [[ "$OSTYPE" == "darwin"* ]]; then
9+
# macOS
810
DYNAMIC_LIB_PATH="./target/release-smaller/libldk_node.dylib"
11+
elif [[ "$OSTYPE" == "msys"* ]]; then
12+
# Windows
13+
DYNAMIC_LIB_PATH="./target/release-smaller/libldk_node.dll"
14+
elif [[ "$OSTYPE" == "cygwin"* ]]; then
15+
# Windows
16+
DYNAMIC_LIB_PATH="./target/release-smaller/libldk_node.dll"
17+
else
18+
echo "Unsupported platform!: $OSTYPE"
19+
exit -1
920
fi
1021

1122
cargo build --profile release-smaller --features uniffi || exit 1

0 commit comments

Comments
 (0)