forked from e1miran/Now-Playing-Serato
-
Notifications
You must be signed in to change notification settings - Fork 12
/
builder.sh
executable file
·133 lines (108 loc) · 2.6 KB
/
builder.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
129
130
131
132
133
#!/usr/bin/env bash
set -e
SYSTEM=$1
VERSION=$(git describe --tags)
UNAMESYS=$(uname -s)
if [[ -z "${SYSTEM}" ]]; then
case "${UNAMESYS}" in
Darwin)
SYSTEM=macosx
;;
MINGW*)
SYSTEM=windows
;;
*)
;;
esac
fi
case "${SYSTEM}" in
windows)
PYTHON=python
;;
macosx)
PYTHON=python3
;;
*)
PYTHON=python
;;
esac
DISTDIR=NowPlaying-"${VERSION}-${SYSTEM}"
PYTHONBIN=$(command -v "${PYTHON}")
echo "*****"
echo "* Building on ${SYSTEM} / ${UNAMESYS}"
echo "* Using ${PYTHONBIN}"
echo "****"
PYTHON_VERSION=$("${PYTHONBIN}" --version)
PYTHON_VERSION=${PYTHON_VERSION#* }
IFS="." read -ra PY_VERSION <<< "${PYTHON_VERSION}"
if [[ ${PY_VERSION[0]} -ne 3 && ${PY_VERSION[1]} -lt 10 ]]; then
echo "Building requires at least version Python 3.10."
exit 1
fi
case "${SYSTEM}" in
windows)
echo "*****"
echo "* Building a virtual environment"
echo "****"
rm -rf "${TMP}/build-venv" || true
"${PYTHONBIN}" -m venv "${TMP}/build-venv"
# shellcheck disable=SC1091
source "${TMP}/build-venv/scripts/activate"
;;
*)
echo "*****"
echo "* Building a virtual environment"
echo "****"
rm -rf /tmp/build-venv || true
"${PYTHONBIN}" -m venv /tmp/build-venv
# shellcheck disable=SC1091
source /tmp/build-venv/bin/activate
;;
esac
PYTHONBIN=$(command -v "${PYTHON}")
PYTHONBINDIR=$(dirname "${PYTHONBIN}")
rm -rf build dist || true
echo "*****"
echo "* Upgrading pip"
echo "****"
"${PYTHONBIN}" -m pip install --upgrade pip
echo "*****"
echo "* Installing dependencies"
echo "****"
"${PYTHONBIN}" -m pip install ".[dev,osspecials]"
echo "*****"
echo "* Setting up NLTK"
echo "****"
"${PYTHONBIN}" setupnltk.py
echo "*****"
echo "* Compiling Qt resources"
echo "****"
if [[ -x "${PYTHONBINDIR}/pyside6-rcc" ]]; then
"${PYTHONBINDIR}/pyside6-rcc" nowplaying/resources/settings.qrc > nowplaying/qtrc.py
else
rcc=$(command -v pyside6-rcc)
echo "Using ${rcc}"
pyside6-rcc nowplaying/resources/settings.qrc > nowplaying/qtrc.py
fi
echo "*****"
echo "* Making binary with PyInstaller "
echo "****"
if [[ -x "${PYTHONBINDIR}/pyinstaller" ]]; then
"${PYTHONBINDIR}/pyinstaller" NowPlaying.spec
else
rcc=$(command -v pyinstaller)
echo "Using ${rcc}"
pyinstaller NowPlaying.spec
fi
echo "*****"
echo "* Cleanup "
echo "****"
cp -p CHANGELOG* README* LICENSE.txt NOTICE.txt dist
mv dist "${DISTDIR}"
if [[ "${SYSTEM}" == "macosx" ]]; then
rm -rf "${DISTDIR}"/NowPlaying || true
rm -rf "${DISTDIR}"/NowPlayingBeam || true
fi
if [[ ${SYSTEM} != "windows" ]]; then
zip --symlinks -r "${DISTDIR}".zip "${DISTDIR}"
fi