Skip to content

Commit 5045786

Browse files
committed
fix: decouple release bundle from local knowledge base
1 parent ebe2ed0 commit 5045786

3 files changed

Lines changed: 41 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ uv run python scripts/build_binary_release.py --target macos-x64 --validate
135135
```
136136

137137
发布工作流定义在 [`.github/workflows/release.yml`](/Volumes/Work/code/PyRAG-kit/.github/workflows/release.yml),发布说明会从 [CHANGELOG.md](/Volumes/Work/code/PyRAG-kit/CHANGELOG.md) 的对应版本节自动提取。
138+
二进制包内默认只包含空的 `knowledge_base/` 占位目录,使用时请自行放入 Markdown 源文档后再构建知识快照。
138139

139140
---
140141

scripts/build_binary_release.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"config.toml.example",
2525
".env.example",
2626
]
27-
PACKAGE_DIRS = ["knowledge_base"]
2827
HIDDEN_IMPORTS = [
2928
"src.providers.google",
3029
"src.providers.openai",
@@ -107,12 +106,28 @@ def stage_bundle(target: str, version: str) -> Path:
107106
shutil.copytree(app_source, app_target)
108107
for relative_file in PACKAGE_FILES:
109108
shutil.copy2(PROJECT_ROOT / relative_file, bundle_root / relative_file)
110-
for relative_dir in PACKAGE_DIRS:
111-
shutil.copytree(PROJECT_ROOT / relative_dir, bundle_root / relative_dir)
109+
prepare_runtime_layout(bundle_root)
112110

113111
return bundle_root
114112

115113

114+
def prepare_runtime_layout(bundle_root: Path) -> None:
115+
knowledge_base_dir = bundle_root / "knowledge_base"
116+
data_kb_dir = bundle_root / "data" / "kb"
117+
data_logs_dir = bundle_root / "data" / "logs"
118+
119+
knowledge_base_dir.mkdir(parents=True, exist_ok=True)
120+
data_kb_dir.mkdir(parents=True, exist_ok=True)
121+
data_logs_dir.mkdir(parents=True, exist_ok=True)
122+
123+
placeholder = knowledge_base_dir / "README.md"
124+
placeholder.write_text(
125+
"# 知识库目录\n\n"
126+
"请将您的 Markdown 知识库文档放入当前目录,然后再执行知识库构建。\n",
127+
encoding="utf-8",
128+
)
129+
130+
116131
def archive_bundle(bundle_root: Path, target: str) -> Path:
117132
if target == "windows-x64":
118133
archive_path = bundle_root.parent / f"{bundle_root.name}.zip"

tests/test_release_scripts.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
from pathlib import Path
3+
4+
from scripts.build_binary_release import prepare_runtime_layout
5+
from scripts.extract_release_notes import extract_section
6+
7+
8+
def test_prepare_runtime_layout_creates_placeholder_directories(tmp_path):
9+
prepare_runtime_layout(tmp_path)
10+
11+
assert (tmp_path / "data" / "kb").is_dir()
12+
assert (tmp_path / "data" / "logs").is_dir()
13+
placeholder = tmp_path / "knowledge_base" / "README.md"
14+
assert placeholder.is_file()
15+
assert "Markdown" in placeholder.read_text(encoding="utf-8")
16+
17+
18+
def test_extract_section_returns_version_content():
19+
section = extract_section("1.3.0")
20+
21+
assert section.startswith("## [1.3.0]")
22+
assert "运行与配置" in section

0 commit comments

Comments
 (0)