-
Notifications
You must be signed in to change notification settings - Fork 77
Optimize the workflow for python CI #989
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,20 +11,15 @@ env: | |
| RUSTUP_TOOLCHAIN: 1.85 | ||
|
|
||
| jobs: | ||
| build-wheels-and-test: | ||
| name: "Build and test Linux" | ||
| runs-on: ubuntu-latest | ||
| build-python-and-test: | ||
| name: "Build and test python" | ||
| runs-on: ${{ matrix.os }} | ||
| defaults: | ||
| run: | ||
| working-directory: payjoin-ffi/python | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - python: "3.9" | ||
| - python: "3.10" | ||
| - python: "3.11" | ||
| - python: "3.12" | ||
| - python: "3.13" | ||
| os: [ubuntu-latest, macos-latest] | ||
| steps: | ||
| - name: "Checkout" | ||
| uses: actions/checkout@v4 | ||
|
|
@@ -35,66 +30,25 @@ jobs: | |
| - name: "Install Python" | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: ${{ matrix.python }} | ||
|
|
||
| - name: "Install build dependencies" | ||
| run: | | ||
| sudo apt update | ||
| sudo apt install -y build-essential python3-dev | ||
| python-version: 3.12 | ||
|
|
||
| - name: "Use cache" | ||
benalleng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| uses: Swatinem/rust-cache@v2 | ||
|
|
||
| - name: "Generate payjoin-ffi.py and binaries" | ||
| run: | | ||
| PYBIN=$(dirname $(which python)) | ||
| PYBIN="$PYBIN" bash ./scripts/generate_linux.sh | ||
| run: bash ./scripts/generate_bindings.sh | ||
|
|
||
| - name: "Build wheel" | ||
| run: python setup.py bdist_wheel --verbose | ||
| run: python -m build --wheel | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this change do?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should in theory do nothing different, there were simply warnings that using setup.py directly was a deprecated method
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| - name: "Install wheel" | ||
| run: pip install ./dist/*.whl | ||
|
|
||
| - name: "Run tests" | ||
| run: python -m unittest -v | ||
|
|
||
| build-macos: | ||
| name: "Build and test macOS" | ||
| runs-on: macos-13 | ||
| defaults: | ||
| run: | ||
| working-directory: payjoin-ffi/python | ||
| strategy: | ||
| matrix: | ||
| python: | ||
| - "3.12" | ||
| steps: | ||
| - name: "Checkout" | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: true | ||
|
|
||
| - name: "Install Rust 1.85.0" | ||
| uses: dtolnay/rust-toolchain@1.85.0 | ||
|
|
||
| - name: "Install Python" | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: ${{ matrix.python }} | ||
|
|
||
| - name: "Use cache" | ||
| uses: Swatinem/rust-cache@v2 | ||
|
|
||
| - name: "Generate payjoin-ffi.py and binaries" | ||
| run: bash ./scripts/generate_macos.sh | ||
|
|
||
| - name: "Build wheel" | ||
| run: python3 setup.py bdist_wheel --verbose | ||
|
|
||
| - name: "Install wheel" | ||
| run: pip3 install ./dist/*.whl | ||
|
|
||
| - name: "Run tests" | ||
| # Skip integration test on macOS due to Docker issues | ||
| run: python3 -m unittest -v test/test_payjoin_unit_test.py | ||
| run: | | ||
| if [[ "${{ matrix.os }}" = "macos-latest" ]]; then | ||
| python -m unittest test/test_payjoin_unit_test.py -v | ||
| else | ||
| python -m unittest -v | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,21 @@ | ||
| [build-system] | ||
| requires = ["setuptools", "wheel", "setuptools-rust"] | ||
| requires = ["setuptools>=62", "wheel", "toml"] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [project] | ||
| name = "payjoin" | ||
| description = "The Python language bindings for the Payjoin Dev Kit" | ||
| readme = "README.md" | ||
| requires-python = ">=3.8" | ||
| license = "MIT" | ||
| dynamic = ["version"] | ||
|
|
||
| [tool.setuptools] | ||
| packages = ["payjoin"] | ||
| package-dir = { "payjoin" = "src/payjoin" } | ||
| include-package-data = true | ||
|
Comment on lines
+3
to
+16
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the gist of these update? Do they perhaps belong in a separate commit?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can split them up, this was due to the setup.py usage being deprecated vs calling |
||
|
|
||
| [tool.pytest.ini_options] | ||
| pythonpath = [ | ||
| "." | ||
| ] | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ semantic-version==2.9.0 | |
| typing_extensions==4.0.1 | ||
| setuptools==78.1.1 | ||
| wheel==0.38.4 | ||
| build==1.3.0 | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| OS=$(uname -s) | ||
|
|
||
| echo "Running on $OS" | ||
|
|
||
| # Install Rust targets if on macOS | ||
| if [[ "$OS" == "Darwin" ]]; then | ||
| LIBNAME=libpayjoin_ffi.dylib | ||
| python3 --version | ||
| pip install -r requirements.txt -r requirements-dev.txt | ||
| elif [[ "$OS" == "Linux" ]]; then | ||
| sudo apt update | ||
| sudo apt install -y build-essential python3-dev | ||
| LIBNAME=libpayjoin_ffi.so | ||
| PYBIN=$(dirname $(which python)) | ||
| PYBIN="$PYBIN" | ||
| ${PYBIN}/python --version | ||
| ${PYBIN}/pip install -r requirements.txt -r requirements-dev.txt | ||
| else | ||
| echo "Unsupported os: $OS" | ||
| exit 1 | ||
| fi | ||
|
|
||
| cd ../ | ||
| # This is a test script the actual release should not include the test utils feature | ||
| cargo build --features _test-utils --profile release | ||
| cargo run --features _test-utils --profile release --bin uniffi-bindgen generate --library target/release/$LIBNAME --language python --out-dir python/src/payjoin/ | ||
|
|
||
| if [[ "$OS" == "Darwin" ]]; then | ||
| echo "Generating native binaries..." | ||
| rustup target add aarch64-apple-darwin x86_64-apple-darwin | ||
| # This is a test script the actual release should not include the test utils feature | ||
| cargo build --profile release-smaller --target aarch64-apple-darwin --features _test-utils & | ||
| cargo build --profile release-smaller --target x86_64-apple-darwin --features _test-utils & | ||
| wait | ||
|
|
||
| echo "Building macos fat library" | ||
| lipo -create -output python/src/payjoin/$LIBNAME \ | ||
| target/aarch64-apple-darwin/release-smaller/$LIBNAME \ | ||
| target/x86_64-apple-darwin/release-smaller/$LIBNAME | ||
|
|
||
| else | ||
| echo "Generating native binaries..." | ||
| rustup target add x86_64-unknown-linux-gnu | ||
| # This is a test script the actual release should not include the test utils feature | ||
| cargo build --profile release-smaller --target x86_64-unknown-linux-gnu --features _test-utils | ||
|
|
||
| echo "Copying payjoin_ffi binary" | ||
| cp target/x86_64-unknown-linux-gnu/release-smaller/$LIBNAME python/src/payjoin/$LIBNAME | ||
| fi | ||
|
|
||
| echo "All done!" |
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.