Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

概述 / Overview

实现了 LangBot 的 PyPI 包发布支持,用户可通过 uvx langbotpip install langbot 一键安装运行,无需克隆仓库或手动编译前端。

Implemented PyPI package distribution for LangBot. Users can now install and run via uvx langbot or pip install langbot without cloning the repository or building the frontend manually.

核心变更 / Core Changes

  • 包结构 / Package Structure

    • Created langbot/ package with __main__.py entry point for console script execution
    • Added MANIFEST.in to bundle frontend, templates, and resources in distribution
    • Updated pyproject.toml with build system config and langbot console script entry point
  • 资源路径处理 / Resource Path Resolution

    • Implemented pkg/utils/paths.py to locate resources in both source and installed package environments
    • Updated all config loaders (JSON/YAML) and frontend serving to use path utility
    • Cached source install detection to minimize file I/O
  • CI/CD

    • Added .github/workflows/publish-to-pypi.yml to build frontend and publish to PyPI on release
    • Workflow builds frontend with Node.js, packages with pre-built assets, publishes via trusted publishing
  • 文档 / Documentation

    • Created docs/PYPI_INSTALLATION.md with installation and usage instructions
    • Updated README.md and README_EN.md to feature uvx/pip as recommended installation method

使用示例 / Usage Example

# Quick start with uvx (no installation)
uvx langbot

# Or install and run
pip install langbot
langbot --debug

行为差异 / Behavioral Changes

  • Creates data/ directory in current working directory (not tied to project root)
  • Non-interactive Python version check (exits immediately vs prompting for input)
  • Frontend pre-built and bundled (no manual npm build required)

统计 / Statistics

16 files changed: +496 lines, -12 lines

检查清单 / Checklist

PR 作者完成 / For PR author

  • 阅读仓库贡献指引了吗? / Have you read the contribution guide?
  • 与项目所有者沟通过了吗? / Have you communicated with the project maintainer?
  • 我确定已自行测试所作的更改,确保功能符合预期。 / I have tested the changes and ensured they work as expected.

项目维护者完成 / For project maintainer

  • 相关 issues 链接了吗? / Have you linked the related issues?
  • 配置项写好了吗?迁移写好了吗?生效了吗? / Have you written the configuration items? Have you written the migration? Has it taken effect?
  • 依赖加到 pyproject.toml 和 core/bootutils/deps.py 了吗 / Have you added the dependencies to pyproject.toml and core/bootutils/deps.py?
  • 文档编写了吗? / Have you written the documentation?

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: curl -LsSf REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

langbot目前只有docker和下载源码部署,在下载源码的方式中,用户需要下载release中编译好了前端的源码包,解压,再使用uv sync安装依赖,然后才能使用uv run main.py来启动;很不方便;

而uv推出了一个uvx工具,跟npx很像,能自动下载并启动python包;我们已经抢占了 langbot 这个包名,在pypi,请你帮我做好这些适配,把langbot目录做成一个可发行的python包,其中需要包含编译好的前端文件(每次发版的时候,通过github actions工作流编译并上传pypi);

请你在开始工作之前,认真阅读uv的文档;


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 6 commits November 7, 2025 13:58
- Created langbot/ package with __init__.py and __main__.py entry point
- Added paths utility to find frontend and resource files from package installation
- Updated config loading to use resource paths
- Updated frontend serving to use resource paths
- Added MANIFEST.in for package data inclusion
- Updated pyproject.toml with build system and entry points

Co-authored-by: RockChinQ <[email protected]>
- Created GitHub Actions workflow to build frontend and publish to PyPI
- Added license field to pyproject.toml to fix deprecation warning
- Updated .gitignore to exclude build artifacts
- Tested package building successfully

Co-authored-by: RockChinQ <[email protected]>
- Created PYPI_INSTALLATION.md with detailed installation and usage instructions
- Updated README.md to feature uvx/pip installation as recommended method
- Updated README_EN.md with same changes for English documentation

Co-authored-by: RockChinQ <[email protected]>
- Made package-data configuration more specific to langbot package only
- Improved path detection with caching to avoid repeated file I/O
- Removed sys.path searching which was incorrect for package data
- Removed interactive input() call for non-interactive environment compatibility
- Simplified error messages for version check

Co-authored-by: RockChinQ <[email protected]>
- Use specific exception types instead of bare except
- Fix misleading comments about directory levels
- Remove redundant existence check before makedirs with exist_ok=True
- Use context manager for file opening to ensure proper cleanup

Co-authored-by: RockChinQ <[email protected]>
- Removed redundant package-data configuration, relying on MANIFEST.in
- Added documentation about behavioral differences between package and source installation
- Clarified that include-package-data=true uses MANIFEST.in for data files

Co-authored-by: RockChinQ <[email protected]>
Copilot AI changed the title [WIP] Add langbot as a distributable Python package Add PyPI package support for uvx/pip installation Nov 7, 2025
Copilot AI requested a review from RockChinQ November 7, 2025 14:12
Copilot finished work on behalf of RockChinQ November 7, 2025 14:12
@codecov
Copy link

codecov bot commented Nov 7, 2025

@RockChinQ RockChinQ marked this pull request as ready for review November 7, 2025 17:14
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Nov 7, 2025
@RockChinQ RockChinQ marked this pull request as draft November 7, 2025 17:16
@dosubot dosubot bot added eh: Feature enhance: 新功能添加 / add new features m: Lifecycle 启动/关闭流程 / Bootstrap & application life cycle m: Tools 工具(ToolUse、内容函数)相关 / Function Calling or tools management labels Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eh: Feature enhance: 新功能添加 / add new features m: Lifecycle 启动/关闭流程 / Bootstrap & application life cycle m: Tools 工具(ToolUse、内容函数)相关 / Function Calling or tools management size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants