forked from mkesicki/excel_validator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·86 lines (76 loc) · 2.14 KB
/
build.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
#!/bin/bash
green='\e[0;32m'
yellow='\e[33m'
bold='\e[1m'
endColor='\e[0m'
usage() {
echo -e "
${green}excel_validator compiler v1.1:
==================================${endColor}
$0 option
${yellow}Available options:
-b --build - build executable
-c --clean - delete prepared files without executable
-r --remove - delete all build files with executable
-h --help - show this${endColor}
"
}
prepare_env() {
echo -e "${green}[*] PREPARING PYTHON2 VIRTUAL ENVIRONMENT${endColor}"
if [ ! -d env ] ; then
if [ -f /usr/bin/virtualenv ] ; then
virtualenv env
else
if [ -f /usr/bin/virtualenv2 ] ; then
virtualenv2 env
else
echo "${yellow}[!] NO VIRTUALENV DETECTED, PLEASE INSTALL IT!"
exit 1
fi
fi
fi
source env/bin/activate
pip install -r requirements.txt
pip install pyinstaller
source env/bin/activate
}
clean() {
echo -e "${green}[*] CLEANING BUILD ENVIRONMENT${endColor}"
rm -rf env build excel_validator.spec
}
if [ $# -le 0 ] ; then
usage
exit 1
fi
for val in $@ ; do
if [[ ("$val" == "--help") || "$val" == "-h" ]] ; then
usage
exit 0
fi
if [[ ("$val" == "--build") || "$val" == "-b" ]] ; then
prepare_env
echo -e "${green}[*] BUILDING EXECUTABLE${endColor}"
pyinstaller --clean --onefile -p validator \
--hidden-import=validator.BaseValidator \
--hidden-import=validator.ChoiceValidator \
--hidden-import=validator.ConditionalValidator \
--hidden-import=validator.CountryValidator \
--hidden-import=validator.DateTimeValidator \
--hidden-import=validator.EmailValidator \
--hidden-import=validator.ExcelDateValidator \
--hidden-import=validator.LengthValidator \
--hidden-import=validator.NotBlankValidator \
--hidden-import=validator.RegexValidator \
--hidden-import=validator.TypeValidator \
excel_validator.py
fi
if [[ ("$val" == "--clean") || "$val" == "-c" ]] ; then
clean
fi
if [[ ("$val" == "--remove") || "$val" == "-r" ]] ; then
clean
echo -e "${green}[*] REMOVING BUILD FILES${endColor}"
rm -rf dist
fi
done
echo -e "${green}${bold}[*] DONE${endColor}"