P4CaseSyncDocumentation

Build a Standalone EXE

Package with the spec File

Run this command from the project directory that contains P4CaseSync.spec. The project imports modules dynamically, so the build needs the hidden imports declared in the spec file.

Terminal window
pyinstaller P4CaseSync.spec

The generated executable is at dist/P4文件名大小写同步工具.exe

What the spec File Does

P4CaseSync.spec is configured for:

  • Single-file packaging (--onefile)
  • No console window (--noconsole)
  • Hidden imports: LoginUI, MainUI, Core
  • Output filename: P4文件名大小写同步工具

To change settings such as filename or icon, edit P4CaseSync.spec:

  • Rename: Find the line name='P4文件名大小写同步工具'
  • Add an icon: Change icon=None to icon='icon.ico'
  • Show the console: Change console=False to console=True for debugging

The project uses InjectSysPath() to add module paths dynamically. PyInstaller cannot automatically identify modules under Source/UI and Source/Logic. The spec file explicitly declares these modules through hiddenimports to ensure packaging succeeds.

Packaging Options and Notes

Do not mix command-line packaging options with a spec file:

Terminal window
# ❌ 错误示例
pyinstaller -F -w P4CaseSync.spec # 会报错
# ✅ 正确用法
pyinstaller P4CaseSync.spec