Overview
Building UNS for production involves two main steps:- Compile the Python backend into a standalone binary
- Package the Electron app with electron-builder
Build times vary by platform. Expect 2-5 minutes for a full build on modern hardware.
Build Architecture
The production build structure:Building the Python Engine
The Python backend must be compiled before building the Electron app.Run PyInstaller
Compile the FastAPI app into a standalone binary:Flags explained:
--onefile- Bundles everything into a single executable--windowed- Suppresses console window (important for desktop apps)--name engine- Names the output binary “engine” (or “engine.exe”)
backend/dist/engineTroubleshooting PyInstaller
ModuleNotFoundError in the binary
ModuleNotFoundError in the binary
PyInstaller may miss some imports. Add them manually to
engine.spec:engine.spec
Binary is too large (>100MB)
Binary is too large (>100MB)
This is normal for Python apps. The binary includes:
- Python runtime
- All pip packages (FastAPI, Uvicorn, ebooklib, etc.)
- Standard library modules
--exclude-module for unused packages:macOS Gatekeeper blocks the binary
macOS Gatekeeper blocks the binary
Sign the binary with an Apple Developer certificate or instruct users to:
- Right-click the app → Open
- Go to System Preferences → Security & Privacy
- Click Open Anyway
Building the Electron App
Once the Python engine is compiled, build the full desktop app.Build the Frontend
From the project root:This runs:
cd frontend && npm install- Ensures dependencies are installednpm run build- Builds React app with Vite
frontend/dist/ (HTML, CSS, JS)Package with Electron Builder
Build the platform-specific installer:Output directory:
dist_electron/Platform-Specific Builds
macOS
Requirements:- macOS 10.13+ (to build)
- Xcode Command Line Tools
dmg- Disk image installer (recommended)pkg- macOS installer packagezip- Zipped app bundle
dist_electron/UNS-1.1.0.dmgdist_electron/mac/UNS.app(unpacked)
package.json
Windows
Requirements:- Windows 7+ (to build)
- Node.js with build tools
nsis- NSIS installer (default)portable- Portable executablezip- Zipped app
dist_electron/UNS Setup 1.1.0.exedist_electron/win-unpacked/(unpacked)
package.json
Linux
Requirements:- Linux (any distro)
- Build essentials installed
AppImage- Universal Linux package (recommended)snap- Snap packagedeb- Debian/Ubuntu packagerpm- RedHat/Fedora package
dist_electron/UNS-1.1.0.AppImagedist_electron/linux-unpacked/(unpacked)
electron-builder Configuration
The build configuration is inpackage.json:
package.json
files- What gets packaged in the ASAR archiveextraResources- Files placed outside ASAR (like the Python engine)asar: true- Compresses app files for faster loading
Accessing the Engine Path
The engine location differs between development and production:main.js
| Environment | Path |
|---|---|
| Development | <project>/backend/dist/engine |
| Production (macOS) | UNS.app/Contents/Resources/bin/engine |
| Production (Windows) | resources/bin/engine.exe |
| Production (Linux) | resources/bin/engine |
Common Build Issues
Engine binary not found in production
Engine binary not found in production
Check the Ensure
extraResources config in package.json:backend/dist/engine exists before building.App crashes immediately after launch
App crashes immediately after launch
-
Check if the Python engine starts correctly:
- Open the app
- Check Activity Monitor (macOS) or Task Manager (Windows)
- Look for a process named “engine”
-
Enable logging in
main.js: -
Run the app from terminal to see logs:
Build fails with 'Cannot find module'
Build fails with 'Cannot find module'
Ensure all dependencies are installed:
macOS: 'UNS is damaged and can't be opened'
macOS: 'UNS is damaged and can't be opened'
This happens when the app isn’t code-signed. Users must:
- Right-click → Open
- Click “Open” in the security dialog
Windows: SmartScreen warning
Windows: SmartScreen warning
Unsigned Windows apps trigger SmartScreen. Users should:
- Click “More info”
- Click “Run anyway”
Testing the Build
Before distributing, test the packaged app:Test Basic Functionality
- Launch the app
- Check if the UI loads
- Navigate to Library, Download, History pages
- Verify the Python engine is running (check Activity Monitor/Task Manager)
Test a Full Scrape
- Add a provider (or use a pre-installed one)
- Search for a novel
- Start a download
- Verify chapters are being scraped
- Check if the EPUB is generated in the output folder
Next Steps
Development Setup
Return to setup guide for development mode
Project Structure
Learn about the codebase organization
