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
19 changes: 19 additions & 0 deletions bindings/python/hatch_build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
import os

from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from hatchling.metadata.plugin.interface import MetadataHookInterface


def readme_path(root):
local_readme_path = os.path.join(root, "README.md")
if os.path.isfile(local_readme_path):
return local_readme_path

return os.path.normpath(os.path.join(root, "..", "..", "README.md"))


class CustomMetadataHook(MetadataHookInterface):
def update(self, metadata):
with open(readme_path(self.root), encoding="utf-8") as readme_file:
metadata["readme"] = {"content-type": "text/markdown", "text": readme_file.read()}


class CustomBuildHook(BuildHookInterface):
def initialize(self, version, build_data):
build_data["pure_python"] = False
build_data["infer_tag"] = True
if self.target_name == "sdist":
build_data["force_include"][readme_path(self.root)] = "README.md"
4 changes: 3 additions & 1 deletion bindings/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -30,4 +30,6 @@ dev = ["requests"]
[tool.hatch.build.targets.wheel]
packages = ["src/ldk_node"]

[tool.hatch.metadata.hooks.custom]

[tool.hatch.build.hooks.custom]
Loading