-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSphinxsetup.sh
More file actions
executable file
·77 lines (66 loc) · 2.41 KB
/
Sphinxsetup.sh
File metadata and controls
executable file
·77 lines (66 loc) · 2.41 KB
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
#!/bin/bash
set -e
set -x
if [ "$UID" -eq 0 ]; then
echo "Sorry, this script must NOT be run as ROOT!"
exit 1
fi
# Check for lsb_release and set distribution variables safely
if command -v lsb_release &> /dev/null; then
DISTRIBUTION_ID=$(lsb_release -i -s)
DISTRIBUTION_CODENAME=$(lsb_release -c -s)
else
DISTRIBUTION_ID=""
DISTRIBUTION_CODENAME=""
fi
if [ ${DISTRIBUTION_ID} = 'Ubuntu' ]; then
if [ ${DISTRIBUTION_CODENAME} = 'focal' ] || [ ${DISTRIBUTION_CODENAME} = 'bionic' ] || [ ${DISTRIBUTION_CODENAME} = 'noble' ]; then
sudo add-apt-repository universe
fi
fi
# Check for macOS
if [[ "$(uname)" == "Darwin" ]]; then
echo "Detected macOS. Installing dependencies using Homebrew."
# Check for Homebrew and install if missing
if ! command -v brew &> /dev/null; then
echo "Homebrew not found. Installing Homebrew."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"
fi
brew update
brew install git imagemagick curl wget make python3 unzip
# Ensure pip is available
if ! command -v pip3 &> /dev/null; then
python3 -m ensurepip --upgrade || true
fi
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
python3 -m pip install --user --upgrade -r "$SCRIPT_DIR"/requirements.txt
echo "Setup completed successfully for macOS!"
exit 0
fi
sudo apt-get -y update
sudo apt-get install -y unzip git imagemagick curl wget make python3
# Install packages release specific
if [ ${DISTRIBUTION_CODENAME} = 'bionic' ]; then
sudo apt-get install -y python3-distutils
fi
# For WSL (esp. version 2) make DISPLAY empty to allow pip to run
STORED_DISPLAY_VALUE=$DISPLAY
if grep -qi -E '(Microsoft|WSL)' /proc/version; then
echo "Temporarily clearing the DISPLAY variable because this is WSL"
export DISPLAY=
fi
sudo apt-get install -y python3-pip
# Install required python packages
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
if [ "${DISTRIBUTION_CODENAME}" = "noble" ]; then
python3 -m pip install --upgrade -r "$SCRIPT_DIR"/requirements.txt
else
python3 -m pip install --user --upgrade -r "$SCRIPT_DIR"/requirements.txt
fi
# Reset the value of DISPLAY
if grep -qi -E '(Microsoft|WSL)' /proc/version; then
echo "Returning DISPLAY to the previous value in WSL"
export DISPLAY=$STORED_DISPLAY_VALUE
fi
echo "Setup completed successfully!"