forked from lightningdevkit/ldk-node
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhatch_build.py
More file actions
28 lines (20 loc) · 1.02 KB
/
Copy pathhatch_build.py
File metadata and controls
28 lines (20 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import sysconfig
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):
platform_tag = sysconfig.get_platform().replace("-", "_").replace(".", "_")
build_data["pure_python"] = False
build_data["tag"] = f"py3-none-{platform_tag}"
if self.target_name == "sdist":
build_data["force_include"][readme_path(self.root)] = "README.md"