Skip to content

Commit de9340f

Browse files
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 <noreply@anthropic.com>
1 parent 5e3ffd5 commit de9340f

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

bindings/python/hatch_build.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1+
import os
2+
13
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
4+
from hatchling.metadata.plugin.interface import MetadataHookInterface
5+
6+
7+
class CustomMetadataHook(MetadataHookInterface):
8+
# Hatchling refuses a `readme` path outside the project directory, so we read the
9+
# repository README ourselves and hand it over as literal text instead.
10+
def update(self, metadata):
11+
readme_path = os.path.join(self.root, os.pardir, os.pardir, "README.md")
12+
with open(readme_path, encoding="utf-8") as f:
13+
metadata["readme"] = {"content-type": "text/markdown", "text": f.read()}
214

315

416
class CustomBuildHook(BuildHookInterface):

bindings/python/pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ authors = [
99
{ name="Elias Rohrer", email="dev@tnull.de" },
1010
]
1111
description = "A ready-to-go Lightning node library built using LDK and BDK."
12-
readme = "../../README.md"
12+
dynamic = ["readme"]
1313
requires-python = ">=3.8"
1414
classifiers = [
1515
"Topic :: Software Development :: Libraries",
@@ -27,6 +27,8 @@ classifiers = [
2727
[dependency-groups]
2828
dev = ["requests"]
2929

30+
[tool.hatch.metadata.hooks.custom]
31+
3032
[tool.hatch.build.targets.wheel]
3133
packages = ["src/ldk_node"]
3234

0 commit comments

Comments
 (0)