-
Notifications
You must be signed in to change notification settings - Fork 20
/
install.bash
executable file
·97 lines (89 loc) · 2.92 KB
/
install.bash
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
#!/usr/bin/env bash
# Function to check for "-y" flag to skip prompts
for arg; do
if [ "$arg" = "-y" ]; then
# Set an environment variable when -y is present
export SKIP_PROMPT=true
else
export SKIP_PROMPT=false
fi
done
# Package installation functions
mbd_install_linux_packages() {
sudo apt-get update
if dpkg -s python3 python3-pip python3-venv libcairo2-dev libgirepository1.0-dev libffi-dev portaudio19-dev python3-gi python3-gi-cairo gir1.2-gtk-3.0 libgirepository1.0-dev >/dev/null 2>&1; then
echo "All required linux packages are already installed."
else
echo "Installing required packages without prompt..."
sudo apt-get install -y python3 python3-pip python3-venv
sudo apt-get install -y libcairo2-dev libgirepository1.0-dev
sudo apt-get install -y libffi-dev
sudo apt-get install -y portaudio19-dev
sudo apt install -y python3-gi python3-gi-cairo gir1.2-gtk-3.0
sudo apt-get install -y libgirepository1.0-dev
CFLAGS="-march=native" pip install pyaudio
python3 -m pip install hatch
fi
}
mbd_install_macos_packages() {
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
if command -v brew >/dev/null; then
echo "Homebrew is already installed."
else
echo "Installing Homebrew..."
NONINTERACTIVE=$SKIP_PROMPT /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
if brew list hatch cairo pygobject3 libffi >/dev/null 2>&1; then
echo "All required macos packages are already installed."
else
echo "Installing required packages..."
brew update
brew install hatch
brew install cairo
brew install pygobject3
brew install libffi
brew install portaudio
PKG_CONFIG_PATH="$(brew --prefix libffi)/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH
LDFLAGS="-L$(brew --prefix libffi)/lib"
export LDFLAGS
CPPFLAGS="-I$(brew --prefix libffi)/include"
export CPPFLAGS
fi
}
# Detect the operating system
OS=$(uname -s)
if [[ $OS == "Linux" ]]; then
if [[ "$SKIP_PROMPT" = false ]]; then
read -rp "Install required Linux packages? (y/n) " response
if [[ $response =~ ^[Yy]$ ]]; then
mbd_install_linux_packages
else
echo "Skipping linux package installation."
fi
else
mbd_install_linux_packages
fi
elif [[ $OS == "Darwin" ]]; then
if [[ "$SKIP_PROMPT" = false ]]; then
read -rp "Install required macOS packages? (y/n) " response
if [[ $response =~ ^[Yy]$ ]]; then
mbd_install_macos_packages
else
echo "Skipping package installation."
fi
else
mbd_install_macos_packages
fi
else
# Unsupported operating system
echo "Unsupported operating system: $OS"
exit 1
fi
if [[ -z "$CI" ]]; then
# shellcheck disable=SC1091
hatch run echo "Sourcing environment..."
source .mbodied/envs/mbodied/bin/activate
else
echo "CI environment detected. Skipping sourcing of environment."
fi