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

View File

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

View File

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

View File

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

View File

@ -1,17 +1,27 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
OS=$(uname -s)
echo "Generating bdk.py..." echo "Generating bdk.py..."
cd ../bdk-ffi/ 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 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..." 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/ cd ../bdk-python/
python3 setup.py --verbose bdist_wheel # python setup.py --verbose bdist_wheel
echo "All done!" echo "All done!"

View File

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