From de9340f8c842267dddab93460310946849378b3f Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Tue, 11 Aug 2026 19:25:01 +0200 Subject: [PATCH] Fix Python bindings build with recent `hatchling` releases `hatchling` validates that `project.readme` resolves inside the project directory, so our `readme = "../../README.md"` now aborts every build of the Python bindings with: ValueError: Readme path must be within the project directory: ../../README.md This breaks the `check-python` CI job as well as `python_build_wheel.sh`. Rather than duplicating the README into `bindings/python`, declare `readme` dynamic and read the repository README from a custom metadata hook, which hands it over as literal text and hence skips the path validation. The resulting wheel metadata is byte-identical to what we published before. This commit was written with AI assistance. Co-Authored-By: Claude Opus 5 --- bindings/python/hatch_build.py | 12 ++++++++++++ bindings/python/pyproject.toml | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bindings/python/hatch_build.py b/bindings/python/hatch_build.py index bd5f54d244..ce16b0d32e 100644 --- a/bindings/python/hatch_build.py +++ b/bindings/python/hatch_build.py @@ -1,4 +1,16 @@ +import os + from hatchling.builders.hooks.plugin.interface import BuildHookInterface +from hatchling.metadata.plugin.interface import MetadataHookInterface + + +class CustomMetadataHook(MetadataHookInterface): + # Hatchling refuses a `readme` path outside the project directory, so we read the + # repository README ourselves and hand it over as literal text instead. + def update(self, metadata): + readme_path = os.path.join(self.root, os.pardir, os.pardir, "README.md") + with open(readme_path, encoding="utf-8") as f: + metadata["readme"] = {"content-type": "text/markdown", "text": f.read()} class CustomBuildHook(BuildHookInterface): diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml index b77801d457..857ad77d70 100644 --- a/bindings/python/pyproject.toml +++ b/bindings/python/pyproject.toml @@ -9,7 +9,7 @@ authors = [ { name="Elias Rohrer", email="dev@tnull.de" }, ] description = "A ready-to-go Lightning node library built using LDK and BDK." -readme = "../../README.md" +dynamic = ["readme"] requires-python = ">=3.8" classifiers = [ "Topic :: Software Development :: Libraries", @@ -27,6 +27,8 @@ classifiers = [ [dependency-groups] dev = ["requests"] +[tool.hatch.metadata.hooks.custom] + [tool.hatch.build.targets.wheel] packages = ["src/ldk_node"]