pyinstaller-config
npx machina-cli add skill a5c-ai/babysitter/pyinstaller-config --openclawFiles (1)
SKILL.md
997 B
PyInstaller Config
Configure PyInstaller for Python binary builds.
Generated Patterns
# myapp.spec
block_cipher = None
a = Analysis(
['src/myapp/__main__.py'],
pathex=[],
binaries=[],
datas=[('src/myapp/data', 'data')],
hiddenimports=['click', 'rich'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz, a.scripts, a.binaries, a.zipfiles, a.datas, [],
name='myapp',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
)
Target Processes
- cli-binary-distribution
- package-manager-publishing
Source
git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/cli-mcp-development/skills/pyinstaller-config/SKILL.mdView on GitHub Overview
This skill helps you configure PyInstaller binary builds using .spec files. It covers data file inclusion, hidden imports, and bundling options to produce portable executables. The example shows a typical myapp.spec with Analysis, PYZ, and EXE blocks.
How This Skill Works
The skill provides a template-like .spec structure that PyInstaller uses to analyze code, collect dependencies, and assemble a standalone executable. It configures data files, hidden imports, and runtime options (e.g., upx, console) within Analysis, PYZ, and EXE blocks as shown in the example.
When to Use It
- Packaging a Python CLI app with data files for distribution
- Building a Windows/Linux binary with UPX and console I/O
- Including dynamic imports via hiddenimports for modules loaded at runtime
- Excluding or customizing modules to slim the bundle
- Preparing a binary distribution for cli-binary-distribution or package-manager-publishing
Quick Start
- Step 1: Create a myapp.spec file with the provided patterns (Analysis, PYZ, EXE)
- Step 2: Update paths, datas, and hiddenimports to fit your project
- Step 3: Run: pyinstaller myapp.spec to build the executable
Best Practices
- Keep the spec file under version control alongside source code
- Specify data files with datas=[('src/...', 'dest')] to ensure runtime access
- List dynamic imports in hiddenimports to avoid missing modules
- Set block_cipher=None unless you need encryption for bundles
- Test builds in target environments to catch OS-specific issues
Example Use Cases
- myapp.spec showcasing Analysis with ['src/myapp/__main__.py'] and datas for data folders
- Including hiddenimports like ['click', 'rich'] to satisfy runtime imports
- Using upx=True and console=True for a CLI desktop executable
- Bundling a data directory via datas=[('src/myapp/data', 'data')]
- Defining the final EXE with name, debug, and stripping options
Frequently Asked Questions
Add this skill to your agents