-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmac_run.command
More file actions
executable file
·49 lines (43 loc) · 1.82 KB
/
Copy pathmac_run.command
File metadata and controls
executable file
·49 lines (43 loc) · 1.82 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
#!/bin/bash
# This script is used to install the requirements for the project on a mac
#cd into the directory of the script
cd "$(dirname "$0")" || exit
# Install homebrew if not already installed
if ! hash brew 2>/dev/null; then
echo "Installing homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# If portaudio and python-tk@3.11 are not installed, install them
if ! brew list | grep -q portaudio || ! brew list | grep -q python-tk@3.11; then
echo "Installing system dependencies"
echo "Installing portaudio and python-tk@3.11"
brew install portaudio python-tk@3.11
fi
# Get the python 3.11 executable and pip executable installed via homebrew
PYTHON_EXECUTABLE=$(brew --prefix python@3.11)/bin/python3.11
PIP_EXECUTABLE=$(brew --prefix python@3.11)/bin/pip3.11
# If python dependencies are not installed (requirements.txt), install them
# Check for a pyvenv.cfg file to determine if the environment is managed externally
if [ -f pyvenv.cfg ]; then
source ./bin/activate
if ! python -m pip freeze | grep -q -f requirements.txt; then
echo "Installing python dependencies"
$PIP_EXECUTABLE install -r requirements.txt
fi
else
if ! python -m pip freeze | grep -q -f requirements.txt; then
echo "Installing python dependencies"
$PIP_EXECUTABLE install -r requirements.txt || {
if [[ $? -eq 1 && $($PIP_EXECUTABLE install -r requirements.txt 2>&1) == *"externally-managed-environment"* ]]; then
echo "Handling externally managed environment error"
$PYTHON_EXECUTABLE -m venv ./
source ./bin/activate
$PIP_EXECUTABLE install -r requirements.txt
else
exit 1
fi
}
fi
fi
# Run the app
$PYTHON_EXECUTABLE app.py