Skip to content

Commit cf2d82f

Browse files
authored
Replace pip with uv in payjoin-ffi/python (#1073)
2 parents d144298 + 3bbb35c commit cf2d82f

File tree

9 files changed

+352
-44
lines changed

9 files changed

+352
-44
lines changed

.github/workflows/python.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,26 @@ jobs:
2727
- name: "Install Rust 1.85.0"
2828
uses: dtolnay/rust-toolchain@1.85.0
2929

30-
- name: "Install Python"
31-
uses: actions/setup-python@v4
32-
with:
33-
python-version: 3.12
34-
3530
- name: "Use cache"
3631
uses: Swatinem/rust-cache@v2
3732

33+
- name: Install a specific version of uv
34+
uses: astral-sh/setup-uv@v6
35+
with:
36+
version: "0.8.2"
37+
enable-cache: true
38+
39+
- name: "uv sync"
40+
run: uv sync --all-extras
41+
3842
- name: "Generate payjoin-ffi.py and binaries"
3943
run: bash ./scripts/generate_bindings.sh
4044

4145
- name: "Build wheel"
42-
run: python -m build --wheel
46+
run: uv build --wheel
4347

4448
- name: "Install wheel"
45-
run: pip install ./dist/*.whl
49+
run: uv run pip install ./dist/*.whl
4650

4751
- name: "Run tests"
48-
run: python -m unittest -v
52+
run: uv run python -m unittest --verbose

payjoin-ffi/python/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ __pycache__/
88
*.swp
99
*.whl
1010
build/
11-
venv
11+
.venv
1212

1313
# Auto-generated shared libraries
1414
*.dylib

payjoin-ffi/python/README.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,51 @@ Grab the latest release with a simple:
88

99
```shell
1010
pip install payjoin
11+
12+
# Or, for uv:
13+
uv add payjoin
1114
```
1215

1316
## Running Tests
1417

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

17-
1820
```shell
19-
git clone https://github.com/payjoin/rust-payjoin.git
20-
cd rust-payjoin/payjoin-ffi/python
21+
# Ensure you have uv installed:
22+
# https://docs.astral.sh/uv/getting-started/installation/
2123

22-
# Setup a python virtual environment
23-
python -m venv venv
24-
source venv/bin/activate
24+
# Setup virtual environment/install all packages (including developer packages)
25+
uv sync --all-extras
2526

26-
PYBIN="./venv/bin/" bash ./scripts/generate_bindings.sh
27+
bash ./scripts/generate_bindings.sh
2728

2829
# Build the wheel
29-
python -m build --wheel
30+
uv build --wheel
3031

31-
# Force reinstall payjoin
32-
pip install ./dist/payjoin-<version>.whl --force-reinstall
32+
# Force reinstall payjoin with <version>
33+
uv pip install ./dist/payjoin-*.whl --force-reinstall
3334

3435
# Run all tests
35-
python -m unittest --verbose
36+
uv run python -m unittest --verbose
3637
```
3738

38-
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.
39-
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.
40-
4139
## Building the Package
4240

4341
```shell
44-
# Setup a python virtual environment
45-
python -m venv venv
46-
source venv/bin/activate
42+
# Setup virtual environment/install packages for release
43+
uv sync --all-extras
4744

48-
PYBIN="./venv/bin/" bash ./scripts/generate_bindings.sh
45+
bash ./scripts/generate_bindings.sh
4946

5047
# Build the wheel
51-
python -m build --wheel
48+
uv build --wheel
5249

50+
# Force reinstall payjoin with <version>
51+
uv pip install ./dist/payjoin-*.whl --force-reinstall
52+
53+
# Example:
54+
# uv pip install ./dist/payjoin-0.24.0-cp313-cp313-linux_x86_64.whl
55+
56+
# Run all tests
57+
uv run python -m unittest --verbose
5358
```

payjoin-ffi/python/pyproject.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ build-backend = "setuptools.build_meta"
66
name = "payjoin"
77
description = "The Python language bindings for the Payjoin Dev Kit"
88
readme = "README.md"
9-
requires-python = ">=3.8"
9+
requires-python = ">=3.9"
1010
license = "MIT"
1111
dynamic = ["version"]
12+
dependencies = [
13+
"build==1.3.0",
14+
"semantic-version==2.9.0",
15+
"setuptools==78.1.1",
16+
"typing-extensions==4.0.1",
17+
"wheel==0.38.4",
18+
"httpx==0.28.1",
19+
]
1220

1321
[tool.setuptools]
1422
packages = ["payjoin"]
@@ -19,3 +27,9 @@ include-package-data = true
1927
pythonpath = [
2028
"."
2129
]
30+
31+
[dependency-groups]
32+
dev = [
33+
"toml==0.10.2",
34+
"yapf==0.43.0",
35+
]

payjoin-ffi/python/requirements-dev.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

payjoin-ffi/python/requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

payjoin-ffi/python/scripts/generate_bindings.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@ echo "Running on $OS"
88
# Install Rust targets if on macOS
99
if [[ "$OS" == "Darwin" ]]; then
1010
LIBNAME=libpayjoin_ffi.dylib
11-
python3 --version
12-
pip install -r requirements.txt -r requirements-dev.txt
1311
elif [[ "$OS" == "Linux" ]]; then
1412
LIBNAME=libpayjoin_ffi.so
15-
PYBIN=$(dirname $(which python))
16-
PYBIN="$PYBIN"
17-
${PYBIN}/python --version
18-
${PYBIN}/pip install -r requirements.txt -r requirements-dev.txt
1913
else
2014
echo "Unsupported os: $OS"
2115
exit 1
2216
fi
2317

18+
uv run python --version
19+
2420
cd ../
2521
# This is a test script the actual release should not include the test utils feature
2622
cargo build --features _test-utils --profile dev

payjoin-ffi/python/setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
## Install the package
1717
```shell
1818
pip install payjoin
19+
20+
# Or, if using uv
21+
uv add payjoin
1922
```
2023
21-
## Usage
24+
## Usage
2225
```python
2326
import payjoin as payjoin
2427
"""

0 commit comments

Comments
 (0)