diff --git a/.github/workflows/publish-python.yaml b/.github/workflows/publish-python.yaml index 805fc04..204b9b7 100644 --- a/.github/workflows/publish-python.yaml +++ b/.github/workflows/publish-python.yaml @@ -54,7 +54,7 @@ jobs: build-macos-universal-wheel: name: "Build macOS universal wheel" - runs-on: macos-12 + runs-on: macos-13 defaults: run: working-directory: bdk-python @@ -85,7 +85,7 @@ jobs: ARCHFLAGS: "-arch x86_64 -arch arm64" # Specifying the plat-name argument is necessary to build a wheel with the correct name, # see issue #350 for more information - run: python3 setup.py bdist_wheel --plat-name macosx_12_0_universal2 --verbose + run: python3 setup.py bdist_wheel --plat-name macosx_13_0_universal2 --verbose - uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/test-python.yaml b/.github/workflows/test-python.yaml index d2b90fe..06bea89 100644 --- a/.github/workflows/test-python.yaml +++ b/.github/workflows/test-python.yaml @@ -16,7 +16,7 @@ on: # tries to load glibc and fails because it requires a more recent version. jobs: - build-manylinux2014-x86_64-wheel: + build-manylinux2014-x86_64-wheels: name: "Build and test Manylinux 2014 x86_64 wheels" runs-on: ubuntu-20.04 defaults: @@ -42,14 +42,14 @@ jobs: with: toolchain: stable - - name: "Set default Rust version to 1.67.0" - run: rustup default 1.67.0 - - - name: "Install requirements" - run: ${PYBIN}/pip install -r requirements.txt +# - name: "Set default Rust version to 1.67.0" +# run: rustup default 1.67.0 +# +# - name: "Install requirements" +# run: ${PYBIN}/pip install -r requirements.txt - name: "Generate bdk.py and binaries" - run: bash generate.sh + run: bash ./scripts/generate-linux.sh - name: "Build wheel" # Specifying the plat-name argument is necessary to build a wheel with the correct name, @@ -68,22 +68,20 @@ jobs: name: bdkpython-manylinux2014-x86_64-${{ matrix.python }} path: /home/runner/work/bdk-ffi/bdk-ffi/bdk-python/dist/*.whl - build-macos-universal-wheel: - name: "Build and test macOS wheels" - runs-on: macos-12 + build-macos-arm64-wheels: + name: "Build and test macOS arm64 wheels" + runs-on: macos-13 defaults: run: working-directory: bdk-python strategy: matrix: python: - # 3.8 returns an error for the macos-12 image when we try to install the wheel: - # bdkpython-0.28.0.dev0-cp38-cp38-macosx_12_0_universal2.whl is not a supported wheel on this platform. - # - "3.8" + - "3.8" - "3.9" - "3.10" steps: - - name: Checkout + - name: "Checkout" uses: actions/checkout@v2 with: submodules: true @@ -92,16 +90,53 @@ jobs: python-version: ${{ matrix.python }} - name: "Generate bdk.py and binaries" - run: | - python3 --version - rustup target add aarch64-apple-darwin - pip3 install --user -r requirements.txt - bash generate.sh + run: bash ./scripts/generate-macos-arm64.sh - name: "Build wheel" - env: - ARCHFLAGS: "-arch x86_64 -arch arm64" - run: python3 setup.py bdist_wheel --plat-name macosx_12_0_universal2 --verbose + # Specifying the plat-name argument is necessary to build a wheel with the correct name, + # see issue #350 for more information + run: python3 setup.py bdist_wheel --plat-name macosx_11_0_arm64 --verbose + + # You can't install the arm64 wheel on the CI, so we skip these steps and simply test that the wheel builds + # - name: "Install wheel and run tests" + # run: | + # pip3 install ./dist/*.whl + # python3 -m unittest tests/test_bdk.py --verbose + + - name: "Upload artifact test" + uses: actions/upload-artifact@v2 + with: + name: bdkpython-macos-arm64-${{ matrix.python }} + path: /Users/runner/work/bdk-ffi/bdk-ffi/bdk-python/dist/*.whl + + build-macos-x86_64-wheels: + name: "Build and test macOS x86_64 wheels" + runs-on: macos-13 + defaults: + run: + working-directory: bdk-python + strategy: + matrix: + python: + - "3.8" + - "3.9" + - "3.10" + steps: + - name: "Checkout" + uses: actions/checkout@v2 + with: + submodules: true + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + + - name: "Generate bdk.py and binaries" + run: bash ./scripts/generate-macos-x86_64.sh + + - name: "Build wheel" + # Specifying the plat-name argument is necessary to build a wheel with the correct name, + # see issue #350 for more information + run: python3 setup.py bdist_wheel --plat-name macosx_11_0_x86_64 --verbose - name: "Install wheel" run: pip3 install ./dist/*.whl @@ -109,7 +144,13 @@ jobs: - name: "Run tests" run: python3 -m unittest tests/test_bdk.py --verbose - build-windows-wheel: + - name: "Upload artifact test" + uses: actions/upload-artifact@v2 + with: + name: bdkpython-macos-x86_64-${{ matrix.python }} + path: /Users/runner/work/bdk-ffi/bdk-ffi/bdk-python/dist/*.whl + + build-windows-wheels: name: "Build and test Windows wheels" runs-on: windows-2022 defaults: @@ -131,14 +172,17 @@ jobs: python-version: ${{ matrix.python }} - name: "Generate bdk.py" - run: | - python --version - pip install --user -r requirements.txt - bash generate.sh + run: bash ./scripts/generate-windows.sh - name: "Build wheel" run: python setup.py bdist_wheel --verbose + - name: "Upload artifact test" + uses: actions/upload-artifact@v2 + with: + name: bdkpython-windows-${{ matrix.python }} + path: D:\a\bdk-ffi\bdk-ffi\bdk-python\dist\*.whl + # TODO: On Windows the pip install ./dist/*.whl step fails with the following error: # Run pip install ./dist/*.whl # WARNING: Requirement './dist/*.whl' looks like a filename, but the file does not exist diff --git a/bdk-python/MANIFEST.in b/bdk-python/MANIFEST.in index b3702f7..261ee57 100644 --- a/bdk-python/MANIFEST.in +++ b/bdk-python/MANIFEST.in @@ -1,2 +1,3 @@ include ./src/bdkpython/libbdkffi.dylib include ./src/bdkpython/libbdkffi.so +include ./src/bdkpython/bdkffi.dll diff --git a/bdk-python/generate.sh b/bdk-python/generate.sh deleted file mode 100644 index 19fb7ac..0000000 --- a/bdk-python/generate.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -OS=$(uname -s) - -echo "Generating bdk.py..." -cd ../bdk-ffi/ -cargo run --bin uniffi-bindgen generate src/bdk.udl --language python --out-dir ../bdk-python/src/bdkpython/ --no-format - -echo "Generating native binaries..." -cargo build --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 -cd ../bdk-python/ - -echo "All done!" diff --git a/bdk-python/scripts/generate-linux.sh b/bdk-python/scripts/generate-linux.sh new file mode 100644 index 0000000..1e4eebe --- /dev/null +++ b/bdk-python/scripts/generate-linux.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -euo pipefail +${PYBIN}/python --version +${PYBIN}/pip install -r requirements.txt + +echo "Generating bdk.py..." +cd ../bdk-ffi/ +cargo run --bin uniffi-bindgen generate src/bdk.udl --language python --out-dir ../bdk-python/src/bdkpython/ --no-format + +echo "Generating native binaries..." +rustup default 1.67.0 +cargo build --profile release-smaller + +echo "Copying linux libbdkffi.so..." +cp ../target/release-smaller/libbdkffi.so ../bdk-python/src/bdkpython/libbdkffi.so + +echo "All done!" diff --git a/bdk-python/scripts/generate-macos-arm64.sh b/bdk-python/scripts/generate-macos-arm64.sh new file mode 100644 index 0000000..87a8c35 --- /dev/null +++ b/bdk-python/scripts/generate-macos-arm64.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -euo pipefail +python3 --version +pip install --user -r requirements.txt + +echo "Generating bdk.py..." +cd ../bdk-ffi/ +cargo run --bin uniffi-bindgen generate src/bdk.udl --language python --out-dir ../bdk-python/src/bdkpython/ --no-format + +echo "Generating native binaries..." +rustup default 1.67.0 +rustup target add aarch64-apple-darwin +cargo build --profile release-smaller --target aarch64-apple-darwin + +echo "Copying libraries libbdkffi.dylib..." +cp ../target/aarch64-apple-darwin/release-smaller/libbdkffi.dylib ../bdk-python/src/bdkpython/libbdkffi.dylib + +echo "All done!" diff --git a/bdk-python/scripts/generate-macos-x86_64.sh b/bdk-python/scripts/generate-macos-x86_64.sh new file mode 100644 index 0000000..07788da --- /dev/null +++ b/bdk-python/scripts/generate-macos-x86_64.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -euo pipefail +python3 --version +pip install --user -r requirements.txt + +echo "Generating bdk.py..." +cd ../bdk-ffi/ +cargo run --bin uniffi-bindgen generate src/bdk.udl --language python --out-dir ../bdk-python/src/bdkpython/ --no-format + +echo "Generating native binaries..." +rustup target add x86_64-apple-darwin +cargo build --profile release-smaller --target x86_64-apple-darwin + +echo "Copying libraries libbdkffi.dylib..." +cp ../target/x86_64-apple-darwin/release-smaller/libbdkffi.dylib ../bdk-python/src/bdkpython/libbdkffi.dylib + +echo "All done!" diff --git a/bdk-python/scripts/generate-windows.sh b/bdk-python/scripts/generate-windows.sh new file mode 100644 index 0000000..32f181a --- /dev/null +++ b/bdk-python/scripts/generate-windows.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -euo pipefail +python3 --version +pip install --user -r requirements.txt + +echo "Generating bdk.py..." +cd ../bdk-ffi/ +cargo run --bin uniffi-bindgen generate src/bdk.udl --language python --out-dir ../bdk-python/src/bdkpython/ --no-format + +echo "Generating native binaries..." +rustup default 1.67.0 +rustup target add x86_64-pc-windows-msvc +cargo build --profile release-smaller --target x86_64-pc-windows-msvc + +echo "Copying libraries bdkffi.dll..." +cp ../target/x86_64-pc-windows-msvc/release-smaller/bdkffi.dll ../bdk-python/src/bdkpython/bdkffi.dll + +echo "Printing the content of the bdkpython directory..." +ls -la ../bdk-python/src/bdkpython/ + +echo "All done!"