Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
44 lines (37 loc) · 1.93 KB
/
Copy pathsetup.py
File metadata and controls
44 lines (37 loc) · 1.93 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
import os
from pathlib import Path
import shutil
import setuptools
from setuptools.command.build_py import build_py
class BuildPyWithSkills(build_py):
"""Bundle consumer skills and their references from the canonical sources."""
def run(self):
super().run()
root = Path(__file__).resolve().parent
build_root = Path(self.build_lib).resolve()
destination = build_root / 'ok' / 'agent_resources'
if destination.exists():
# This directory is generated by this command. Rebuild it so skills
# removed from the consumer catalog cannot survive incremental builds.
if destination.is_symlink() or not destination.resolve().is_relative_to(build_root):
raise ValueError('Bundled agent resources must stay inside the build directory')
shutil.rmtree(destination)
# Retain the repository layout so relative skill links still resolve.
shutil.copytree(root / '.agents/skills', destination / '.agents/skills',
dirs_exist_ok=True, ignore=shutil.ignore_patterns('__pycache__', '*.pyc'))
for relative in ('docs/mcp.md', 'docs/agent-setup.md', 'docs/feature-crops.md',
'examples/mcp_observe.py'):
target = destination / relative
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(root / relative, target)
os.environ["PYTHONIOENCODING"] = "utf-8"
VERSION_NUM = os.environ.get('OK_SCRIPT_BUILD_VERSION')
if VERSION_NUM:
print(f'building explicit version {VERSION_NUM}')
else:
from get_pypi_latest_version import GetPyPiLatestVersion
obtainer = GetPyPiLatestVersion()
latest_version = obtainer("ok-script")
VERSION_NUM = obtainer.version_add_one(latest_version, add_patch=True)
print(f'latest_version is {latest_version} new version is {VERSION_NUM}')
setuptools.setup(version=VERSION_NUM, cmdclass={'build_py': BuildPyWithSkills})