-
Notifications
You must be signed in to change notification settings - Fork 10
/
setup.sh
executable file
·87 lines (72 loc) · 2.01 KB
/
setup.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
# Exit on errors.
set -e
echo "========================================================================="
echo "Set up SLING development environment"
echo "========================================================================="
# Install packages.
echo
echo "=== Install SLING dependencies"
PYVER=3.6
PYPKGS="python${PYVER} python${PYVER}-dev python3-pip"
CLIBS="lbzip2 libcurl4-openssl-dev"
PKGS="g++ ${CLIBS} ${PYPKGS} unzip"
sudo apt install ${PKGS}
# Install bazel.
BAZELVER=1.0.0
BAZELSH=bazel-${BAZELVER}-installer-linux-x86_64.sh
BAZELREPO=https://github.com/bazelbuild/bazel
BAZELURL=${BAZELREPO}/releases/download/${BAZELVER}/${BAZELSH}
if [[ $UPGRADE_BAZEL = "1" ]]; then
echo "=== Forcing reinstall of Bazel"
sudo rm $(which bazel)
fi
if ! which bazel > /dev/null; then
echo
echo "=== Install Bazel build system"
wget -P /tmp ${BAZELURL}
chmod +x /tmp/${BAZELSH}
sudo /tmp/${BAZELSH}
rm /tmp/${BAZELSH}
fi
# Build SLING.
echo
echo "=== Build SLING"
tools/buildall.sh
# Install SLING Python API.
echo
echo "=== Set up SLING Python API"
SLINGPKG=/usr/lib/python3/dist-packages/sling
PIP="sudo -H pip3 --disable-pip-version-check"
if [[ $(${PIP} freeze | grep "sling==") ]]; then
echo "Removing existing SLING pip package"
${PIP} uninstall sling
fi
if [[ -x "${SLINGPKG}" ]]; then
echo "SLING Python package already installed"
else
echo "Adding link for SLING Python package"
sudo ln -s $(realpath python) ${SLINGPKG}
fi
# Install sling command.
CMD="/usr/local/bin/sling"
if [ ! -f "$CMD" ]; then
echo "Adding sling command to $CMD"
SCRIPT="#!$(which python3)\nimport sling.run\nsling.run.main()"
echo -e $SCRIPT | sudo tee $CMD > /dev/null
sudo chmod +x $CMD
fi
# Extra Python packages:
# requests (http download)
# numpy (myelin tests)
# tweepy (twitter)
# praw (reddit)
# urllib3 (proxy)
# pillow (photo dedup)
# requests-oauthlib (OAuth)
# torch (bert analyzer)
# transformers (bert analyzer)
# pymupdf (epub2pdf)
# Done.
echo
echo "=== SLING is now set up."