Skip to content
Open
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
12 changes: 3 additions & 9 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,15 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Generate Python bindings
run: ./scripts/uniffi_bindgen_generate_python.sh

- name: Start bitcoind and electrs
run: docker compose up -d

- name: Install testing prerequisites
run: |
pip3 install requests
- name: Run Python unit tests
env:
BITCOIN_CLI_BIN: "docker exec ldk-node-bitcoin-1 bitcoin-cli"
Expand All @@ -40,4 +34,4 @@ jobs:
ESPLORA_ENDPOINT: "http://127.0.0.1:3002"
run: |
cd $LDK_NODE_PYTHON_DIR
python3 -m unittest discover -s src/ldk_node
uv run --group dev python -m unittest discover -s src/ldk_node
7 changes: 7 additions & 0 deletions bindings/python/hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from hatchling.builders.hooks.plugin.interface import BuildHookInterface


class CustomBuildHook(BuildHookInterface):
def initialize(self, version, build_data):
build_data["pure_python"] = False
build_data["infer_tag"] = True
16 changes: 14 additions & 2 deletions bindings/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "ldk_node"
version = "0.7.0"
authors = [
{ name="Elias Rohrer", email="dev@tnull.de" },
]
description = "A ready-to-go Lightning node library built using LDK and BDK."
readme = "README.md"
requires-python = ">=3.6"
readme = "../../README.md"
requires-python = ">=3.8"
classifiers = [
"Topic :: Software Development :: Libraries",
"Topic :: Security :: Cryptography",
Expand All @@ -19,3 +23,11 @@ classifiers = [
"Homepage" = "https://lightningdevkit.org/"
"Github" = "https://github.com/lightningdevkit/ldk-node"
"Bug Tracker" = "https://github.com/lightningdevkit/ldk-node/issues"

[dependency-groups]
dev = ["requests"]

[tool.hatch.build.targets.wheel]
packages = ["src/ldk_node"]

[tool.hatch.build.hooks.custom]
13 changes: 0 additions & 13 deletions bindings/python/setup.cfg

This file was deleted.

31 changes: 31 additions & 0 deletions scripts/python_build_wheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Build a Python wheel for the current platform.
#
# This script compiles the Rust library, generates Python bindings via UniFFI,
# and builds a platform-specific wheel using uv + hatchling.
#
# Run this on each target platform (Linux, macOS) to collect wheels, then use
# scripts/python_publish_package.sh to publish them.

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

cd "$REPO_ROOT"

# Generate bindings and compile the native library
echo "Generating Python bindings..."
./scripts/uniffi_bindgen_generate_python.sh

# Build the wheel
echo "Building wheel..."
cd bindings/python
uv build --wheel

echo ""
echo "Wheel built successfully:"
ls -1 dist/*.whl
echo ""
echo "Collect wheels from all target platforms into dist/, then run:"
echo " ./scripts/python_publish_package.sh"
3 changes: 0 additions & 3 deletions scripts/python_create_package.sh

This file was deleted.

26 changes: 26 additions & 0 deletions scripts/python_publish_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# Publish Python wheels to PyPI (or TestPyPI).
#
# Usage:
# ./scripts/python_publish_package.sh # publish to PyPI
# ./scripts/python_publish_package.sh --index testpypi # publish to TestPyPI
#
# Before running, collect wheels from all target platforms into bindings/python/dist/.

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
DIST_DIR="$REPO_ROOT/bindings/python/dist"

if [ ! -d "$DIST_DIR" ] || [ -z "$(ls -A "$DIST_DIR"/*.whl 2>/dev/null)" ]; then
echo "Error: No wheels found in $DIST_DIR"
echo "Run ./scripts/python_build_wheel.sh on each target platform first."
exit 1
fi

echo "Wheels to publish:"
ls -1 "$DIST_DIR"/*.whl
echo ""

uv publish "$@" "$DIST_DIR"/*.whl
Loading