Building PyCharter Package¶
Building the Package with UI¶
To build a package that includes pre-built UI static files (like Airflow):
1. Build the UI First¶
This creates ui/static/ with all the built files.
2. Build the Python Package¶
# Build source distribution
python -m build --sdist
# Build wheel
python -m build --wheel
# Or both
python -m build
The custom build commands in setup.py will:
- Check if ui/static/ exists
- Build the UI if needed (if node_modules exists)
- Include static files in the package
3. Verify Package Contents¶
Installation After Building¶
Users who install from the built package:
The static files are included in the package, so no build step is needed.
Development vs Production¶
Development (Source)¶
- UI source files in
ui/src/ - Run
pycharter ui devfor hot reload - No static files needed
Production (Package)¶
- Pre-built static files in
ui/static/ - Included in Python package
- Served via
pycharter ui serve - No npm/node required for end users
CI/CD Integration¶
For automated builds, add to your CI:
# Example GitHub Actions
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Build UI
run: |
cd ui
npm install
npm run build
- name: Build Python package
run: python -m build
Troubleshooting¶
"UI static files not found" after installation¶
Cause: Package was built without UI static files.
Solution:
1. Build UI: pycharter ui build
2. Rebuild package: python -m build
3. Reinstall: pip install --force-reinstall dist/pycharter-*.whl
Build fails with "npm not found"¶
Cause: Node.js not installed in build environment.
Solution: Install Node.js or build UI separately before packaging.