ReMe/scripts/package_studio.py
jinliyl fd2894f939
Some checks failed
NPM Format / Website checks (push) Has been cancelled
GitHub Pages Check / test-and-build (push) Has been cancelled
Package Check / distributions (push) Has been cancelled
Deploy ReMe documentation / build (push) Has been cancelled
Windows Smoke / CLI smoke - py3.11 (push) Has been cancelled
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Tests ReMe / Unit Tests - py3.11 (push) Has been cancelled
Tests ReMe / Unit Tests - py3.12 (push) Has been cancelled
Tests ReMe / Unit Tests - py3.13 (push) Has been cancelled
Deploy ReMe documentation / deploy (push) Has been cancelled
fix: harden the 0.4.1.7 release configuration (#456)
* fix(packaging): harden the Studio release workflow

* chore(daily-paper): tune scheduled discovery defaults

* fix(docs): link the ReMe blog to GitHub Pages

* fix(docs): increase Chinese hero title spacing

* refactor(docs): share hero title line spacing

* fix(docs): keep desktop hero copy on two lines

* fix(docs): widen the home hero description

* style(docs): loosen hero title line height

* fix(docs): hide Markdown frontmatter in rendered pages

* docs(readme): simplify installation and remove standalone ReMe Studio instructions

- Remove references to separate ReMe Studio package and static build steps
- Clarify that `core` extra includes common integrations including Studio
- Update installation instructions to use `pip install -e ".[core]"`
- Remove detailed Studio usage and frontend development instructions
- Note that Studio is included with `core` and optional via `web` extra
- Simplify Quick Start guide by removing Studio usage step
- Remove mentions of serving Studio with HTTP service when using extras
- Update both English and Chinese README files accordingly

* docs(readme): streamline and clarify memory design and operations

- Remove redundant explanations about core extra installation
- Simplify memory processing flow description for clarity
- Clarify memory workspace directory default and customization
- Condense automatic memory flow to emphasize rebuildable metadata
- Refine search functionality explanation with RRF fusion details
- Shorten and clarify agent integration description, removing redundancy
- Update and simplify the operations command list, removing less common commands
- Revise community and support section for conciseness and clarity
- Maintain parallel updates in both English and Chinese README files

* test(bump_version): add tests for version bumping and consistency checks

- Add dynamic loading of bump_version and package_studio scripts for testing
- Test that studio package and dependencies have matching versions
- Implement fixtures to write temporary version files for testing
- Add test ensuring bump_version updates all relevant files and dependencies
- Add test to reject inconsistent version sources before writing
- Refactor tests to use common REPOSITORY path variable
- Include imports and setup for pytest in test file

feat(bump_version): create script to update ReMe and Studio versions

- Implement version reading from __init__.py and pyproject.toml files
- Validate current versions are consistent across files before updating
- Update version strings atomically to avoid partial writes
- Ensure exact pinning of studio dependency in main package extras
- Validate new version format against a safe pattern
- Provide CLI interface to bump versions from command line
- Raise errors if expected version declarations or pins are missing or duplicated

* fix(release): validate split package publishing

* fix(release): improve validation diagnostics

* fix(release): sync docs and workflow inputs

* fix(release): split PyPI publish jobs
2026-08-13 17:22:00 +08:00

65 lines
2.6 KiB
Python

"""Prepare the optional ReMe Studio Python distribution."""
from __future__ import annotations
import argparse
import shutil
from pathlib import Path
REPOSITORY_DIR = Path(__file__).resolve().parents[1]
WEBSITE_DIR = REPOSITORY_DIR / "website"
PACKAGE_DIR = REPOSITORY_DIR / "packages" / "reme_ai_studio"
STATIC_DIR = PACKAGE_DIR / "src" / "reme_ai_studio" / "static"
LICENSE_FILE = REPOSITORY_DIR / "LICENSE"
STATIC_GITIGNORE = "*\n!.gitignore\n"
_RAW_WEBSITE_URL = "https://raw.githubusercontent.com/agentscope-ai/ReMe/main/website"
_REPOSITORY_URL = "https://github.com/agentscope-ai/ReMe"
def build_readme() -> str:
"""Compose the PyPI description from the English and Chinese Studio docs."""
english = (WEBSITE_DIR / "README.md").read_text(encoding="utf-8")
chinese = (WEBSITE_DIR / "README_ZH.md").read_text(encoding="utf-8")
english = english.replace("English | [简体中文](./README_ZH.md)", "English | [简体中文](#简体中文)")
chinese = chinese.replace(
"# ReMe Studio\n\n[English](./README.md) | 简体中文",
"# 简体中文\n\n[English](#reme-studio) | 简体中文",
)
for relative, absolute in {
"./public/og.jpg": f"{_RAW_WEBSITE_URL}/public/og.jpg",
"../README.md": f"{_REPOSITORY_URL}#readme",
"../README_ZH.md": f"{_REPOSITORY_URL}/blob/main/README_ZH.md",
}.items():
english = english.replace(relative, absolute)
chinese = chinese.replace(relative, absolute)
return f"{english.rstrip()}\n\n---\n\n{chinese.rstrip()}\n"
def prepare_package(*, copy_static: bool = True) -> None:
"""Generate package metadata files and optionally stage the static build."""
(PACKAGE_DIR / "README.md").write_text(build_readme(), encoding="utf-8")
shutil.copyfile(LICENSE_FILE, PACKAGE_DIR / "LICENSE")
if not copy_static:
return
source = WEBSITE_DIR / "dist-static"
if not (source / "index.html").is_file():
raise FileNotFoundError(f"Studio static build is unavailable: {source}")
try:
shutil.rmtree(STATIC_DIR, ignore_errors=True)
shutil.copytree(source, STATIC_DIR)
finally:
STATIC_DIR.mkdir(parents=True, exist_ok=True)
(STATIC_DIR / ".gitignore").write_text(STATIC_GITIGNORE, encoding="utf-8")
def main() -> None:
"""Run the package preparation command."""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--readme-only", action="store_true", help="Generate only the PyPI README")
args = parser.parse_args()
prepare_package(copy_static=not args.readme_only)
if __name__ == "__main__":
main()