diff --git a/bindings/python/hatch_build.py b/bindings/python/hatch_build.py index bd5f54d244..86f2a988d0 100644 --- a/bindings/python/hatch_build.py +++ b/bindings/python/hatch_build.py @@ -1,4 +1,17 @@ +import os + from hatchling.builders.hooks.plugin.interface import BuildHookInterface +from hatchling.metadata.plugin.interface import MetadataHookInterface + + +class CustomMetadataHook(MetadataHookInterface): + def update(self, metadata): + readme_path = os.path.join(self.root, "README.md") + if not os.path.isfile(readme_path): + readme_path = os.path.normpath(os.path.join(self.root, "..", "..", "README.md")) + + with open(readme_path, encoding="utf-8") as readme_file: + metadata["readme"] = {"content-type": "text/markdown", "text": readme_file.read()} class CustomBuildHook(BuildHookInterface): diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml index b77801d457..87d5469abd 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", @@ -30,4 +30,9 @@ dev = ["requests"] [tool.hatch.build.targets.wheel] packages = ["src/ldk_node"] +[tool.hatch.build.targets.sdist.force-include] +"../../README.md" = "README.md" + +[tool.hatch.metadata.hooks.custom] + [tool.hatch.build.hooks.custom]