-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_app.sh
executable file
·128 lines (113 loc) · 3.51 KB
/
build_app.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# -*- coding: utf-8 -*-
# SPDX-FileCopyrightText: 2024 Cezar M. Tigaret <cezar.tigaret@gmail.com>
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-License-Identifier: LGPL-2.1-or-later
function show_help ()
{
echo -e "\n*** ***"
echo -e "* Bash script for building a Scipyen executable (frozen Scipyen app *\n"
echo -e "* including its virtual python environment) using PyInstaller. *\n"
echo -e "*** ***\n"
echo -e "(C) 2023 Cezar M. Tigaret "
echo -e "<cezar tigaret at gmail com> , <tigaretc at cardiff ac uk>"
echo -e "\nInstructions:"
echo -e "============\n"
echo -e "In a terminal, cd to the directory containing the local clone of \n"
echo -e "Scipyen's git repository and run 'sh build_app.sh'.\n"
echo -e "\n"
echo -e "By default, the frozen app will be built as a directory inside ${HOME}\scipyen_app\dist \n"
echo -e " but this can be changed using the option below\n"
echo -e "\n"
echo -e "Options:"
echo -e "========\n"
echo -e "--install_dir=DIR\tSpecify the top directory where the frozen Scipyen will be built (default is ${HOME}\scipyen_app)\n"
echo -e "\n"
echo -e "Prerequisites:\n"
echo -e "============== \n"
echo -e "A python virtual environment for scipyen must have been built; \n"
echo -e "\tthis will include installing an activation script for the environmment \n"
}
if [ -z ${VIRTUAL_ENV} ]; then
if [ -a $HOME/.scipyenrc ] ; then
source $HOME/.scipyenrc && scipyact
else
echo "Cannot activate a python virtual environment for Scipyen"
exit 1
fi
fi
destination=${HOME}/scipyen_app
debug=0
for i in "$@" ; do
# echo $i
case $i in
--install_dir=*)
destination="${i#*=}"
shift
;;
--debug)
debug=1
shift
;;
-h|-?|--help)
show_help
exit 0
shift
;;
-*|--*)
echo -e "Unknown option $i"
show_help
shift
exit 0
;;
*)
;;
esac
done
if [ -d ${destination} ] ; then
mkdir -p $destination
fi
workdir=${destination}/build
distdir=${destination}/dist
echo $0: $"debug: "$debug
export PYTHONHASHSEED=1
if [[ $debug -gt 0 ]] ; then
pyinstaller --distpath ${distdir} --workpath ${workdir} --clean --noconfirm ./scipyen.spec -- --debug
else
pyinstaller --distpath ${distdir} --workpath ${workdir} --clean --noconfirm ./scipyen.spec
fi
if [[ $? -ne 0 ]] ; then
echo -e "Compilation of frozen Scipyen application failed"
exit 1
fi
# echo -e "Creating a desktop file for Scipyen_app\n"
#
# # tmpfiledir=$(mktemp -d)
# # tmpfile=${tmpfiledir}/cezartigaret-Scipyen.desktop
# # tmpfile=${tmpfiledir}/Scipyen_app.desktop
# desktopfile=${workdir}/Scipyen_app.desktop
#
# # cat<<END > ${tmpfile}
# cat<<END > ${desktopfile}
# [Desktop Entry]
# Type=Application
# Name[en_GB]=Scipyen app
# Name=Scipyen app
# Comment[en_GB]=Scientific Python Environment for Neurophysiology - PyInstaller frozen application
# Comment=Scientific Python Environment for Neurophysiology - PyInstaller frozen application
# GenericName[en_GB]=Scipyen application
# GenericName=Scipyen application
# Icon=pythonbackend
# Categories=Science;Utilities;
# Exec=${distdir}/Scipyen_app
# MimeType=
# Path=
# StartupNotify=true
# Terminal=true
# TerminalOptions=\s
# X-DBUS-ServiceName=
# X-DBUS-StartupType=
# X-KDE-SubstituteUID=false
# X-KDE-Username=
# END
#