-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
53 lines (42 loc) · 1.67 KB
/
Copy pathsetup.py
File metadata and controls
53 lines (42 loc) · 1.67 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""Setuptools build hooks for projecting OpenHCS MCP knowledge resources.
Dependency and package metadata comes exclusively from ``pyproject.toml``.
"""
import runpy
from pathlib import Path
from setuptools import setup
from setuptools.command.build_py import build_py as _build_py
from setuptools.command.sdist import sdist as _sdist
_KNOWLEDGE_BUILD_HELPERS = runpy.run_path(
str(Path(__file__).resolve().parent / "scripts/build_mcp_knowledge_assets.py")
)
KNOWLEDGE_MANIFEST_RELATIVE_PATH = _KNOWLEDGE_BUILD_HELPERS[
"KNOWLEDGE_MANIFEST_RELATIVE_PATH"
]
PACKAGED_KNOWLEDGE_ROOT_RELATIVE_PATH = _KNOWLEDGE_BUILD_HELPERS[
"PACKAGED_KNOWLEDGE_ROOT_RELATIVE_PATH"
]
project_knowledge_assets = _KNOWLEDGE_BUILD_HELPERS["project_knowledge_assets"]
class BuildPyWithMcpKnowledge(_build_py):
"""Project canonical MCP knowledge sources directly into wheel build output."""
def run(self):
super().run()
project_root = Path(__file__).resolve().parent
if (project_root / KNOWLEDGE_MANIFEST_RELATIVE_PATH).is_file():
project_knowledge_assets(
project_root,
Path(self.build_lib) / PACKAGED_KNOWLEDGE_ROOT_RELATIVE_PATH,
)
class SdistWithMcpKnowledge(_sdist):
"""Include projected MCP knowledge resources in source distributions."""
def make_release_tree(self, base_dir, files):
super().make_release_tree(base_dir, files)
project_knowledge_assets(
Path(__file__).resolve().parent,
Path(base_dir) / PACKAGED_KNOWLEDGE_ROOT_RELATIVE_PATH,
)
setup(
cmdclass={
"build_py": BuildPyWithMcpKnowledge,
"sdist": SdistWithMcpKnowledge,
}
)