forked from openstenoproject/plover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·232 lines (203 loc) · 3.74 KB
/
bootstrap.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#!/bin/bash
. ./utils/functions.sh
# Mac OS X. {{{
osx_bootstrap()
{
url='https://www.python.org/ftp/python/3.5.3/python-3.5.3-macosx10.6.pkg'
md5='6f9ee2ad1fceb1a7c66c9ec565e57102'
dst='.cache/downloads/python35.pkg'
run mkdir -p "$(dirname "$dst")"
for retry in $(seq 3)
do
if ! [ -r "$dst" ] && ! run curl --show-error --silent -o "$dst" "$url"
then
err "python download failed"
rm -f "$dst"
continue
fi
if [ $opt_dry_run -ne 0 ] || [ "$(md5 -q "$dst")" = "$md5" ]
then
break
fi
err "python md5 did not match"
rm -f "$dst"
done
[ $opt_dry_run -ne 0 -o -r "$dst" ]
run sudo installer -pkg "$dst" -target /
pip_install --user wheel
}
osx_packages_install()
{
wheels_install --user "$@"
}
osx_python3_packages=(
certifi
)
# }}}
# Arch Linux. {{{
arch_bootstrap()
{
run sudo pacman --sync --refresh
}
arch_packages_install()
{
run sudo pacman --sync --needed "$@"
}
arch_python2_packages=(
base-devel
cython2
libusb
python2-appdirs
python2-babel
python2-dbus
python2-hidapi
python2-mock
python2-pip
python2-pyqt5
python2-pyserial
python2-pytest
python2-setuptools
python2-setuptools-scm
python2-six
python2-wheel
python2-xlib
wmctrl
)
arch_python3_packages=(
cython
libusb
python-appdirs
python-babel
python-dbus
python-hidapi
python-mock
python-pip
python-pyqt5
python-pyserial
python-pytest
python-setuptools
python-setuptools-scm
python-six
python-wheel
python-xlib
wmctrl
)
# }}}
# Ubuntu. {{{
ubuntu_bootstrap()
{
run sudo apt-add-repository -y ppa:benoit.pierre/plover
run sudo apt-get update -qq
}
ubuntu_packages_install()
{
run sudo apt-get install -qq "$@"
}
ubuntu_python2_packages=(
cython
libudev-dev
libusb-1.0-0-dev
pyqt5-dev-tools
python-appdirs
python-babel
python-dbus
python-dev
python-hid
python-mock
python-pip
python-pkg-resources
python-pyqt5
python-pytest
python-serial
python-setuptools
python-setuptools-pyqt
python-setuptools-scm
python-six
python-wheel
python-xlib
wmctrl
)
ubuntu_python3_packages=(
cython3
debhelper
devscripts
libudev-dev
libusb-1.0-0-dev
pyqt5-dev-tools
python3-appdirs
python3-babel
python3-dbus
python3-dev
python3-hid
python3-mock
python3-pip
python3-pkg-resources
python3-pyqt5
python3-pytest
python3-serial
python3-setuptools
python3-setuptools-pyqt
python3-setuptools-scm
python3-six
python3-wheel
python3-xlib
wmctrl
)
# }}}
help()
{
echo "Usage: $0 [python2|python3]"
exit 1
}
set -e
parse_opts args "$@" && [ "${#args[@]}" -le 1 ] || help
python="${args[0]:-python3}"
case "$python" in
python2|python3) ;;
*) help;;
esac
case "$OSTYPE" in
linux-gnu)
dist="$(find_dist)"
;;
darwin*)
dist='osx'
;;
*)
err "unsupported OS type: $OSTYPE"
exit 1
;;
esac
if [ "$python" == 'python2' -a "$OSTYPE" != 'linux-gnu' ]
then
err "Python 2 is only supported on Linux"
exit 1
fi
var="${dist}_${python}_packages[@]"
packages=("${!var}")
"${dist}_bootstrap"
if [ -n "$packages" ]
then
"${dist}_packages_install" "${packages[@]}"
fi
# Update antiquated version of pip on Ubuntu...
pip_install --user --upgrade pip
# Upgrade setuptools, we need at least 19.6 to prevent issues with Cython patched 'build_ext' command.
wheels_install --user --upgrade 'setuptools>=19.6'
# Manually install Cython if not already to speedup hidapi build.
wheels_install --user Cython
# Generate requirements.
run "$python" setup.py write_requirements
wheels_install --user -c requirements_constraints.txt -r requirements.txt
user_bin="$("$python" - <<\EOF
import os
import site
user_bin = os.path.join(site.USER_BASE, "bin")
home = os.path.expanduser("~/")
if user_bin.startswith(home):
user_bin = os.path.join("~", user_bin[len(home):])
print(user_bin)
EOF
)"
info -c32 "Note: please make sure $user_bin is in your \$PATH!"
# vim: foldmethod=marker