Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 13 additions & 59 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this change do?

Copy link
Collaborator Author

@benalleng benalleng Aug 21, 2025

Choose a reason for hiding this comment

The 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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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
10 changes: 4 additions & 6 deletions payjoin-ffi/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ cd rust-payjoin/payjoin-ffi/python
python -m venv venv
source venv/bin/activate

# Generate the bindings (use the script appropriate for your platform)
PYBIN="./venv/bin/" bash ./scripts/generate_<platform>.sh
PYBIN="./venv/bin/" bash ./scripts/generate_bindings.sh

# Build the wheel
python setup.py bdist_wheel --verbose
python -m build --wheel

# Force reinstall payjoin
pip install ./dist/payjoin-<version>.whl --force-reinstall
Expand All @@ -46,10 +45,9 @@ You can [filter which tests](https://docs.python.org/3/library/unittest.html#com
python -m venv venv
source venv/bin/activate

# Generate the bindings (use the script appropriate for your platform)
PYBIN="./venv/bin/" bash ./scripts/generate_<platform>.sh
PYBIN="./venv/bin/" bash ./scripts/generate_bindings.sh

# Build the wheel
python setup.py --verbose bdist_wheel
python -m build --wheel

```
18 changes: 16 additions & 2 deletions payjoin-ffi/python/pyproject.toml
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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator Author

@benalleng benalleng Aug 21, 2025

Choose a reason for hiding this comment

The 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 python -m build --wheel


[tool.pytest.ini_options]
pythonpath = [
"."
]
]
1 change: 1 addition & 0 deletions payjoin-ffi/python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 0 additions & 10 deletions payjoin-ffi/python/scripts/bindgen_generate.sh

This file was deleted.

54 changes: 54 additions & 0 deletions payjoin-ffi/python/scripts/generate_bindings.sh
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!"
22 changes: 0 additions & 22 deletions payjoin-ffi/python/scripts/generate_linux.sh

This file was deleted.

32 changes: 0 additions & 32 deletions payjoin-ffi/python/scripts/generate_macos.sh

This file was deleted.

Loading