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
20 changes: 12 additions & 8 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,26 @@ jobs:
- name: "Install Rust 1.85.0"
uses: dtolnay/rust-toolchain@1.85.0

- name: "Install Python"
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: "Use cache"
uses: Swatinem/rust-cache@v2

- name: Install a specific version of uv
uses: astral-sh/setup-uv@v6
with:
version: "0.8.2"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is simply the current version of uv, I figured we shouldn't just arbitrarily pull latest?

enable-cache: true

- name: "uv sync"
run: uv sync --all-extras
Copy link
Collaborator Author

@thebrandonlucas thebrandonlucas Sep 25, 2025

Choose a reason for hiding this comment

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

This command includes all "optional" (i.e. dev) dependencies and is the replacement for pip install but also updates the .venv and lockfile


- name: "Generate payjoin-ffi.py and binaries"
run: bash ./scripts/generate_bindings.sh

- name: "Build wheel"
run: python -m build --wheel
run: uv build --wheel
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Running just uv build would have built both the source and binary (wheel) distribution, which is redundant so we only build the binary here.


- name: "Install wheel"
run: pip install ./dist/*.whl
run: uv run pip install ./dist/*.whl

- name: "Run tests"
run: python -m unittest -v
run: uv run python -m unittest --verbose
2 changes: 1 addition & 1 deletion payjoin-ffi/python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ __pycache__/
*.swp
*.whl
build/
venv
.venv
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

uv's virtualenv lives in .venv


# Auto-generated shared libraries
*.dylib
Expand Down
43 changes: 24 additions & 19 deletions payjoin-ffi/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,51 @@ Grab the latest release with a simple:

```shell
pip install payjoin

# Or, for uv:
uv add payjoin
```

## Running Tests

Follow these steps to clone the repository and run the tests.


```shell
git clone https://github.com/payjoin/rust-payjoin.git
cd rust-payjoin/payjoin-ffi/python
Comment on lines -19 to -20
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This seemed redundant

# Ensure you have uv installed:
# https://docs.astral.sh/uv/getting-started/installation/
Comment on lines +21 to +22
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are, of course, other deps required (gcc compiler, for ex.) but these will be abstracted away in uv2nix in the next PR

Copy link
Collaborator

Choose a reason for hiding this comment

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

in a separate followup PR it'd make sense to add python and these toolchain bits to the devshell

not sure it should be gcc though, since rustc uses llvm clang might be the more appropriate option


# Setup a python virtual environment
python -m venv venv
source venv/bin/activate
# Setup virtual environment/install all packages (including developer packages)
uv sync --all-extras

PYBIN="./venv/bin/" bash ./scripts/generate_bindings.sh
bash ./scripts/generate_bindings.sh

# Build the wheel
python -m build --wheel
uv build --wheel

# Force reinstall payjoin
pip install ./dist/payjoin-<version>.whl --force-reinstall
# Force reinstall payjoin with <version>
uv pip install ./dist/payjoin-*.whl --force-reinstall

# Run all tests
python -m unittest --verbose
uv run python -m unittest --verbose
```

Note that you'll need Docker to run the integration tests. If you get a "Failed to start container" error, ensure the Docker engine is running on your machine.
You can [filter which tests](https://docs.python.org/3/library/unittest.html#command-line-interface) to run by passing a file or test name as argument.

## Building the Package

```shell
# Setup a python virtual environment
python -m venv venv
source venv/bin/activate
# Setup virtual environment/install packages for release
uv sync --all-extras

PYBIN="./venv/bin/" bash ./scripts/generate_bindings.sh
bash ./scripts/generate_bindings.sh

# Build the wheel
python -m build --wheel
uv build --wheel

# Force reinstall payjoin with <version>
uv pip install ./dist/payjoin-*.whl --force-reinstall

# Example:
# uv pip install ./dist/payjoin-0.24.0-cp313-cp313-linux_x86_64.whl

# Run all tests
uv run python -m unittest --verbose
```
16 changes: 15 additions & 1 deletion payjoin-ffi/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ build-backend = "setuptools.build_meta"
name = "payjoin"
description = "The Python language bindings for the Payjoin Dev Kit"
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
license = "MIT"
dynamic = ["version"]
dependencies = [
"build==1.3.0",
"semantic-version==2.9.0",
"setuptools==78.1.1",
"typing-extensions==4.0.1",
"wheel==0.38.4",
"httpx==0.28.1",
]

[tool.setuptools]
packages = ["payjoin"]
Expand All @@ -19,3 +27,9 @@ include-package-data = true
pythonpath = [
"."
]

[dependency-groups]
dev = [
"toml==0.10.2",
"yapf==0.43.0",
]
3 changes: 0 additions & 3 deletions payjoin-ffi/python/requirements-dev.txt

This file was deleted.

5 changes: 0 additions & 5 deletions payjoin-ffi/python/requirements.txt

This file was deleted.

8 changes: 2 additions & 6 deletions payjoin-ffi/python/scripts/generate_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ 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
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

uv run python --version

cd ../
# This is a test script the actual release should not include the test utils feature
cargo build --features _test-utils --profile dev
Expand Down
5 changes: 4 additions & 1 deletion payjoin-ffi/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
## Install the package
```shell
pip install payjoin

# Or, if using uv
uv add payjoin
```

## Usage
## Usage
```python
import payjoin as payjoin
"""
Expand Down
Loading