-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
59 lines (49 loc) · 2.4 KB
/
Copy pathsetup.py
File metadata and controls
59 lines (49 loc) · 2.4 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
54
55
56
57
58
59
"""Wheel asset bundling (Event 177) — thin setuptools consumer.
The shipping/privacy contract lives in ``src/episteme/_packaging.py`` (pure,
importable without setuptools — the 3.12 CI lane has no bundled setuptools
and must still run the contract tests). This file only wires that contract
into ``build_py``: copy the governance trees into ``episteme/_assets/`` with
the privacy ignore bound to THIS repo root, so an sdist-staged build applies
identical exclusions.
"""
from __future__ import annotations
import shutil
import sys
from pathlib import Path
from setuptools import setup
from setuptools.command.build_py import build_py
REPO = Path(__file__).resolve().parent
sys.path.insert(0, str(REPO / "src"))
from episteme._packaging import ASSET_TREES, asset_ignore_for # noqa: E402
class build_py_with_assets(build_py): # noqa: N801 (setuptools naming)
def run(self) -> None:
super().run()
ignore = asset_ignore_for(REPO)
dest_root = Path(self.build_lib) / "episteme" / "_assets"
for tree in ASSET_TREES:
src = REPO / tree
if not src.is_dir():
# FAIL LOUDLY (review): an sdist-staged build has none of the
# asset trees, and skipping silently ships an asset-less
# wheel that breaks at runtime. Wheels are built in-tree
# (`pip wheel .` — the CI clean-install path); any other
# staging must die here, visibly.
raise RuntimeError(
f"asset tree '{tree}' missing at {src} — building outside "
f"the repo checkout (sdist staging?) is not a supported "
f"wheel path; build with `pip wheel .` from the checkout"
)
dest = dest_root / tree
if dest.exists():
shutil.rmtree(dest)
shutil.copytree(src, dest, ignore=ignore)
dest_root.mkdir(parents=True, exist_ok=True)
(dest_root / "README.txt").write_text(
"episteme governance assets, bundled at build time by setup.py.\n"
"Operator personal memory (core/memory/global live files), private\n"
"skills, and runtime state are excluded by construction — see\n"
"episteme/_packaging.py for the contract and its tests.\n",
encoding="utf-8",
)
if __name__ == "__main__":
setup(cmdclass={"build_py": build_py_with_assets})