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"]