Packaging & Distribution: Added Electron Builder + Updated paths to Python
Problem
Now that V1 of the frontend app has been developed, we would like to prepare the app for release thus we need to use tools to build, package, and distribute the desktop app. electron-builder is the tool I selected to accomplish this. The PR sets up the infrastructure for the packaging/release process by bundling Python and updating the paths accordingly.
Solution
In the packaged app, the CLI and python venv is copied and stored into the app's /resources directory using electron-builder. Output files generated from the CLI are stored in the app's /userData directory. Paths
Updated python paths where findPython() is used to set the path to python depending on if the app is packaged/ or local development:
For the packaged app, uses process.resourcesPath.
For local dev, uses local python venv.
Updated script paths where path for CLI is set depending on if the app is packaged/ or local development:
For the packaged app, uses process.resourcesPath.
For local dev, uses local cli directory.
Updated output paths
For the packaged app, uses /userData directory to store the output files.
For local dev, output files are stored in the root directory.
Createdset-up-python-env.sh script which installs python venv using poetry and copies this env to /python. This directory is a bundled version of Python that will be used by the bundled CLI in the desktop app. electron-builder copies /python and /cli and stores into app's /resources to be used in desktop app.
This script is executed when npm run dist is run.
Minor fixes include:
Added generated results file to .gitignore
Added app metadata to package.json
Added lxml and pyarrow as deps
Result
When npm run dist command is run, this builds and packages a ready-for-distribution Electron app for macOS, Windows and Linux.
Test Plan
To build and package desktop app:
cd frontend
npm install
npm run dist
In dist/mac, you should find the packaged desktop app. Double-click to run.
Packaging & Distribution: Added Electron Builder + Updated paths to Python
Problem
Now that V1 of the frontend app has been developed, we would like to prepare the app for release thus we need to use tools to build, package, and distribute the desktop app.
electron-builder
is the tool I selected to accomplish this. The PR sets up the infrastructure for the packaging/release process by bundling Python and updating the paths accordingly.Solution
In the packaged app, the CLI and python venv is copied and stored into the app's
/resources
directory usingelectron-builder
. Output files generated from the CLI are stored in the app's/userData
directory. PathsUpdated python paths where
findPython()
is used to set the path to python depending on if the app is packaged/ or local development:process.resourcesPath
.Updated script paths where path for CLI is set depending on if the app is packaged/ or local development:
process.resourcesPath
.Updated output paths
/userData
directory to store the output files.Created
set-up-python-env.sh
script which installs python venv using poetry and copies this env to/python
. This directory is a bundled version of Python that will be used by the bundled CLI in the desktop app.electron-builder
copies/python
and/cli
and stores into app's/resources
to be used in desktop app. This script is executed whennpm run dist
is run.Minor fixes include:
.gitignore
package.json
Result
When
npm run dist
command is run, this builds and packages a ready-for-distribution Electron app for macOS, Windows and Linux.Test Plan
To build and package desktop app:
In
dist/mac
, you should find the packaged desktop app. Double-click to run.