Skip to content

Commit

Permalink
Merge pull request #71 from Geode-solutions/feat/build_script
Browse files Browse the repository at this point in the history
Feat/build script
  • Loading branch information
JulienChampagnol authored Nov 7, 2024
2 parents a0d6dc9 + d183f46 commit 99beda9
Show file tree
Hide file tree
Showing 26 changed files with 110 additions and 94 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CICD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
cat package.json
rm -rf node_modules package-lock.json
npm install
npm run build_microservices
npm run package
shell: bash
env:
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ logs
# Other
/build
/dist-electron
/electron-server/dist_back
/electron-server/dist_viewer
/electron-server/venv_back
/electron-server/venv_viewer
/electron-server/back/dist
/electron-server/viewer/dist
/electron-server/back/venv
/electron-server/viewer/venv
/release
/uploads
vease-back*
Expand Down
9 changes: 9 additions & 0 deletions electron-server/back/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
echo "Building back microservice"
$back_path=".\electron-server\back"
$dist_path="$back_path\dist"
$venv_path="$back_path\venv"
. "$venv_path\Scripts\activate"
$site_packages_path="$venv_path\Lib\site-packages"
pip install pyinstaller
pyinstaller --onefile --collect-data opengeodeweb_back --collect-data vease_back "$site_packages_path\vease_back\app.py" --distpath $dist_path -n vease-back --clean
Copy-Item $dist_path\vease-back.exe .\
9 changes: 9 additions & 0 deletions electron-server/back/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
back_path=./electron-server/back
dist_path=$back_path/dist
venv_path=$back_path/venv
source $venv_path/bin/activate
site_packages_path=$venv_path/lib/python3.10/site-packages
pip install pyinstaller
pyinstaller --onefile --collect-data opengeodeweb_back $site_packages_path/vease_back/app.py --distpath $dist_path -n vease-back --clean
cp $dist_path/vease-back ./
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile electron-server/requirements_back.in
# pip-compile '.\electron-server\back\requirements.in'
#
asgiref==3.8.1
# via
Expand All @@ -26,7 +26,9 @@ click==8.1.7
# opengeodeweb-back
# vease-back
colorama==0.4.6
# via vease-back
# via
# click
# vease-back
flask[async]==3.0.3
# via
# flask-cors
Expand Down Expand Up @@ -167,11 +169,10 @@ rpds-py==0.20.0
# vease-back
typing-extensions==4.12.2
# via
# asgiref
# opengeodeweb-back
# vease-back
vease-back==1.0.0
# via -r electron-server/requirements_back.in
# via -r .\electron-server\back\requirements.in
werkzeug==3.0.4
# via
# flask
Expand Down
9 changes: 9 additions & 0 deletions electron-server/compile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$microservice_name=$args[0]
echo "Compiling $args requirements"
$microservice_path=".\electron-server\$microservice_name"
$venv_path="$microservice_path\venv"
python -m venv $venv_path
Remove-Item -Recurse -Force "$microservice_path\requirements.txt" -ErrorAction:SilentlyContinue
. "$venv_path\Scripts\activate"
pip install pip-tools
pip-compile "$microservice_path\requirements.in"
11 changes: 11 additions & 0 deletions electron-server/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e
microservice_name=$1
echo "Compiling $microservice_name requirements"
microservice_path="./electron-server/$microservice_name"
venv_path=$microservice_path/venv
python3 -m venv $venv_path
rm -rf $microservice_path/requirements.txt
source $venv_path/bin/activate
pip install pip-tools
pip-compile $microservice_path/requirements.in
3 changes: 0 additions & 3 deletions electron-server/compile_back.ps1

This file was deleted.

5 changes: 0 additions & 5 deletions electron-server/compile_back.sh

This file was deleted.

3 changes: 0 additions & 3 deletions electron-server/compile_viewer.ps1

This file was deleted.

5 changes: 0 additions & 5 deletions electron-server/compile_viewer.sh

This file was deleted.

11 changes: 11 additions & 0 deletions electron-server/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$microservice_name=$args[0]
echo "Installing $args requirements"
$microservice_path=".\electron-server\$microservice_name"
$venv_path="$microservice_path\venv"
echo "Installing in $venv_path"
Remove-Item -Recurse -Force $venv_path -ErrorAction:SilentlyContinue
Remove-Item -Recurse -Force "$microservice_path\dist\" -ErrorAction:SilentlyContinue
Remove-Item -Recurse -Force "$microservice_path\build\" -ErrorAction:SilentlyContinue
python -m venv $venv_path
. "$venv_path\Scripts\activate"
pip install -r "$microservice_path\requirements.txt"
10 changes: 10 additions & 0 deletions electron-server/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e
microservice_name=$1
echo "Installing $microservice_name requirements"
microservice_path="./electron-server/$microservice_name"
venv_path=$microservice_path/venv
rm -rf $venv_path $microservice_path/dist $microservice_path/build
python3 -m venv $venv_path
source $venv_path/bin/activate
pip install -r $microservice_path/requirements.txt
13 changes: 0 additions & 13 deletions electron-server/install_back.ps1

This file was deleted.

12 changes: 0 additions & 12 deletions electron-server/install_back.sh

This file was deleted.

13 changes: 0 additions & 13 deletions electron-server/install_viewer.ps1

This file was deleted.

12 changes: 0 additions & 12 deletions electron-server/install_viewer.sh

This file was deleted.

9 changes: 9 additions & 0 deletions electron-server/viewer/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
echo "Building viewer microservice"
$viewer_path=".\electron-server\viewer"
$dist_path="$viewer_path\dist"
$venv_path="$viewer_path\venv"
. "$venv_path\Scripts\activate"
$site_packages_path="$venv_path\Lib\site-packages"
pip install pyinstaller
pyinstaller --onefile --collect-data opengeodeweb_viewer --collect-all vtkmodules "$site_packages_path\vease_viewer\app.py" --distpath $dist_path -n vease-viewer --clean
Copy-Item $dist_path\vease-viewer.exe .\
9 changes: 9 additions & 0 deletions electron-server/viewer/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
viewer_path=./electron-server/viewer
dist_path=$viewer_path/dist
venv_path=$viewer_path/venv
source $venv_path/bin/activate
site_packages_path=$venv_path/lib/python3.10/site-packages
pip install pyinstaller
pyinstaller --onefile --collect-data opengeodeweb_viewer --collect-all vtkmodules $site_packages_path/vease_viewer/app.py --distpath $dist_path -n vease-viewer --clean
cp $dist_path/vease-viewer ./
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile electron-server/requirements_viewer.in
# pip-compile '.\electron-server\viewer\requirements.in'
#
aiohttp==3.9.3
# via
Expand All @@ -16,7 +16,6 @@ aiosignal==1.3.1
# vease-viewer
async-timeout==4.0.3
# via
# aiohttp
# opengeodeweb-viewer
# vease-viewer
attrs==23.2.0
Expand Down Expand Up @@ -72,12 +71,12 @@ multidict==6.0.5
# opengeodeweb-viewer
# vease-viewer
# yarl
numpy==2.1.2
numpy==2.1.3
# via
# contourpy
# matplotlib
# vease-viewer
opengeodeweb-viewer[gpu]==0.2.1
opengeodeweb-viewer[gpu]==0.3.0
# via vease-viewer
packaging==24.1
# via
Expand Down Expand Up @@ -115,8 +114,8 @@ six==1.16.0
# via
# python-dateutil
# vease-viewer
vease-viewer[gpu]==1.0.1
# via -r electron-server/requirements_viewer.in
vease-viewer[gpu]==1.0.2
# via -r .\electron-server\viewer\requirements.in
vtk==9.3.1
# via
# opengeodeweb-viewer
Expand Down
3 changes: 2 additions & 1 deletion electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ function executable_path(app_name, microservice_name) {
command = path.join(
app.getAppPath(),
"electron-server",
"venv_" + microservice_name
microservice_name,
"venv"
);
if (process.platform === "win32") {
command = path.join(command, "Scripts");
Expand Down
6 changes: 3 additions & 3 deletions node_scripts/run_script_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const { spawn } = require("node:child_process");

console.log("process.argv", process.argv);

var script_name = process.argv[2].replace("--script_name=", "");
var script_name = process.argv[2]
console.log("script_name", script_name);

var child;
if (process.platform === "win32") {
child = spawn("powershell.exe", [`./electron-server/${script_name}.ps1`]);
child = spawn("powershell.exe", [`./electron-server/${script_name}.ps1`, process.argv[3]]);
} else if (process.platform === "linux") {
child = spawn(`./electron-server/${script_name}.sh`, []);
child = spawn(`./electron-server/${script_name}.sh`, [process.argv[3]]);
}

child.stdout.on("data", function (data) {
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
"scripts": {
"dev": "npx [email protected] dev --no-fork",
"generate": "nuxt generate",
"compile_back": "node node_scripts/run_script_file.js --script_name=compile_back",
"compile_viewer": "node node_scripts/run_script_file.js --script_name=compile_viewer",
"install_back": "node node_scripts/run_script_file.js --script_name=install_back",
"install_viewer": "node node_scripts/run_script_file.js --script_name=install_viewer",
"compile_back": "node node_scripts/run_script_file.js compile back",
"compile_viewer": "node node_scripts/run_script_file.js compile viewer",
"install_back": "node node_scripts/run_script_file.js install back",
"install_viewer": "node node_scripts/run_script_file.js install viewer",
"build_back": "node node_scripts/run_script_file.js back/build",
"build_viewer": "node node_scripts/run_script_file.js viewer/build",
"build_microservices": "npm run build_back && npm run build_viewer",
"build": "nuxi build --prerender",
"test": "vitest",
"package": "npm run build && electron-builder build --publish=never",
Expand Down

0 comments on commit 99beda9

Please sign in to comment.