Skip to content

fix(build): include lazy CLI subcommands in PyInstaller hiddenimports#1510

Open
hzeng1998 wants to merge 1 commit intoMoonshotAI:mainfrom
hzeng1998:fix/pyinstaller-lazy-subcommands
Open

fix(build): include lazy CLI subcommands in PyInstaller hiddenimports#1510
hzeng1998 wants to merge 1 commit intoMoonshotAI:mainfrom
hzeng1998:fix/pyinstaller-lazy-subcommands

Conversation

@hzeng1998
Copy link
Copy Markdown

@hzeng1998 hzeng1998 commented Mar 19, 2026

Summary

This PR fixes packaged-binary runtime failures for lazy-loaded CLI subcommands.

After lazy-loading of CLI subcommands was introduced in 82425a0c, PyInstaller no longer collected those dynamically imported modules automatically.
As a result, bundled binaries could fail with ModuleNotFoundError when running subcommands like kimi web or kimi info.

Changes

  • Add lazy CLI subcommand modules to PyInstaller hiddenimports.
  • Derive the list from LazySubcommandGroup.lazy_subcommands so it stays in sync automatically.
  • Update test_pyinstaller_hiddenimports snapshot to cover the lazy CLI modules.

Affected Commands (packaged binary)

  • kimi info
  • kimi export
  • kimi mcp
  • kimi vis
  • kimi web

Verification

  • uv run pytest tests/utils/test_pyinstaller_utils.py -k hiddenimports -vv
  • uv run pyinstaller kimi.spec
  • dist/kimi web --help
  • dist/kimi info --help

Impact

  • Keeps lazy-loading startup optimizations intact.
  • Fixes packaged runtime import errors for lazy subcommands.
  • Low risk: packaging-time import manifest change only.

Copilot AI review requested due to automatic review settings March 19, 2026 09:27
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes PyInstaller-packaged binary runtime failures by ensuring modules for lazy-loaded CLI subcommands are included as hiddenimports, keeping packaging in sync with the lazy-subcommand registry.

Changes:

  • Derive PyInstaller hiddenimports for lazy CLI subcommands from LazySubcommandGroup.lazy_subcommands.
  • Extend the hiddenimports snapshot test to include the lazy CLI subcommand modules.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/kimi_cli/utils/pyinstaller.py Adds lazy CLI subcommand modules to PyInstaller hiddenimports, derived from the lazy-subcommand registry.
tests/utils/test_pyinstaller_utils.py Updates snapshot to assert lazy CLI subcommand modules are present in hiddenimports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants