Fix Python build workflow to account for Linux/Windows

This commit is contained in:
thunderbiscuit 2023-02-28 14:24:51 -05:00
parent 90763d42a2
commit 488edf8bd2
No known key found for this signature in database
GPG Key ID: 88253696EB836462
6 changed files with 29 additions and 22 deletions

View File

@ -16,8 +16,8 @@ on:
jobs:
build-manylinux2014-x86_64-wheel:
name: 'Build Manylinux 2014 x86_64 wheel'
runs-on: ubuntu-latest
name: 'Build Manylinux 2014 x86_64 wheels'
runs-on: ubuntu-22.04
defaults:
run:
working-directory: bdk-python
@ -49,17 +49,15 @@ jobs:
- name: generate bindings
run: bash generate.sh
- name: build wheel
run: ${PYBIN}/pip wheel . --no-deps -w /tmp/wheelhouse
- name: repair wheel
run: auditwheel repair /tmp/wheelhouse/* --plat "$PLAT" -w /tmp/wheelhouse-repaired
run: ${PYBIN}/python setup.py bdist_wheel --verbose
- uses: actions/upload-artifact@v2
with:
name: bdkpython-manylinux2014-x86_64-${{ matrix.python }}
path: /tmp/wheelhouse-repaired/*.whl
path: ./dist/*.whl
build-macos-universal-wheel:
name: 'Build macOS universal wheel'
runs-on: macos-latest
name: 'Build macOS universal wheels'
runs-on: macos-12
defaults:
run:
working-directory: bdk-python
@ -81,20 +79,19 @@ jobs:
- run: python3 --version
- run: rustup target add aarch64-apple-darwin
- run: pip3 install --user -r requirements.txt
- run: pip3 install --user wheel
- run: bash generate.sh
- name: build wheel
env:
ARCHFLAGS: "-arch x86_64 -arch arm64"
run: python3 setup.py -v bdist_wheel
run: python3 setup.py bdist_wheel --verbose
- uses: actions/upload-artifact@v2
with:
name: bdkpython-macos-${{ matrix.python }}
path: /Users/runner/work/bdk-ffi/bdk-ffi/bdk-python/dist/*.whl
build-windows-wheel:
name: 'Build windows wheel'
runs-on: windows-latest
name: 'Build Windows wheels'
runs-on: windows-2022
defaults:
run:
working-directory: bdk-python
@ -116,10 +113,8 @@ jobs:
- run: python --version
- run: pip install --user -r requirements.txt
- run: bash generate.sh
shell: bash
- run: pip install --user wheel
- name: build wheel
run: python setup.py -v bdist_wheel
run: python setup.py bdist_wheel --verbose
- uses: actions/upload-artifact@v2
with:
name: bdkpython-win-${{ matrix.python }}

View File

@ -8,6 +8,7 @@ license = "MIT OR Apache-2.0"
[lib]
crate-type = ["lib", "staticlib", "cdylib"]
#crate-type = ["staticlib", "cdylib"]
#crate-type = ["cdylib"]
name = "bdkffi"
[[bin]]

View File

@ -1 +1,2 @@
include ./src/bdkpython/libbdkffi.dylib
include ./src/bdkpython/libbdkffi.so

View File

@ -13,8 +13,7 @@ pip install bdkpython
```shell
pip3 install --requirement requirements.txt
bash ./generate.sh
python3 setup.py --verbose bdist_wheel
pip3 install ./dist/bdkpython-<yourversion>-py3-none-any.whl
pip3 install ./dist/bdkpython-<yourversion>-py3-none-any.whl --force-reinstall
python -m unittest --verbose tests/test_bdk.py
```

View File

@ -1,17 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail
OS=$(uname -s)
echo "Generating bdk.py..."
cd ../bdk-ffi/
cargo run --features uniffi/cli --bin uniffi-bindgen generate src/bdk.udl --language python --out-dir ../bdk-python/src/bdkpython/ --no-format
cargo build --features uniffi/cli --profile release-smaller
echo "Generating native binaries..."
mv ../target/release-smaller/libbdkffi.dylib ../bdk-python/src/bdkpython/libbdkffi.dylib
cargo build --features uniffi/cli --profile release-smaller
case $OS in
"Darwin")
echo "Copying macOS libbdkffi.dylib..."
cp ../target/release-smaller/libbdkffi.dylib ../bdk-python/src/bdkpython/libbdkffi.dylib
;;
"Linux")
echo "Copying linux libbdkffi.so..."
cp ../target/release-smaller/libbdkffi.so ../bdk-python/src/bdkpython/libbdkffi.so
;;
esac
echo "Bundling bdkpython..."
# echo "Bundling bdkpython..."
cd ../bdk-python/
python3 setup.py --verbose bdist_wheel
# python setup.py --verbose bdist_wheel
echo "All done!"

View File

@ -1,3 +1,4 @@
semantic-version==2.9.0
setuptools-rust==1.1.2
typing_extensions==4.0.1
setuptools==67.4.0
wheel==0.38.4