-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
49 lines (35 loc) · 1.66 KB
/
setup.py
File metadata and controls
49 lines (35 loc) · 1.66 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
"""Setuptools command customizations for CogniRelay packaging."""
from __future__ import annotations
import shutil
from pathlib import Path
from pathlib import PurePosixPath
from setuptools import setup
from setuptools.command.build_py import build_py as _build_py
from setuptools.command.sdist import sdist as _sdist
AGENT_ASSET_FILES = (
"README.md",
"hooks/README.md",
"hooks/cognirelay_retrieval_hook.py",
"hooks/cognirelay_continuity_save_hook.py",
"skills/cognirelay-continuity-authoring/SKILL.md",
)
def _is_egg_info_path(path: str) -> bool:
"""Return whether a source distribution path points inside egg-info metadata."""
return any(part.endswith(".egg-info") for part in PurePosixPath(path.replace("\\", "/")).parts)
class build_py(_build_py):
"""Copy the allowlisted agent assets into wheel build output only."""
def run(self) -> None:
super().run()
source_root = PurePosixPath("agent-assets")
target_root = PurePosixPath("cognirelay") / "agent_assets"
shutil.rmtree(Path(self.build_lib) / target_root, ignore_errors=True)
for relative in AGENT_ASSET_FILES:
source = source_root / relative
target = PurePosixPath(self.build_lib) / target_root / relative
self.mkpath(str(target.parent))
shutil.copy2(str(source), str(target))
class sdist(_sdist):
"""Build an sdist without setuptools' generated egg-info directory."""
def make_release_tree(self, base_dir: str, files: list[str]) -> None:
super().make_release_tree(base_dir, [path for path in files if not _is_egg_info_path(path)])
setup(cmdclass={"build_py": build_py, "sdist": sdist})