Skip to content

Commit c8e452f

Browse files
JanJan
authored andcommitted
fix: mac scipt
1 parent 8a6b2ed commit c8e452f

File tree

1 file changed

+52
-68
lines changed

1 file changed

+52
-68
lines changed

docs/install_depthai.sh

Lines changed: 52 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -e
33

4-
VENV_PATH=".local/share/virtualenvs"
4+
VENV_PATH="$HOME/.local/share/virtualenvs"
55

66
echo "Installing viewer dependencies..."
77

@@ -15,117 +15,101 @@ readonly linux_pkgs=(
1515
git
1616
python3-numpy
1717
)
18+
PYTHONPATH=$(which python3)
19+
# Function to create virtual environment
20+
create_venv() {
21+
echo "Creating python virtual environment in $VENV_PATH"
22+
23+
if [ ! -d "$VENV_PATH" ]; then
24+
echo "Creating virtual environment at $VENV_PATH"
25+
mkdir -p "$VENV_PATH"
26+
"$PYTHONPATH" -m venv "$VENV_PATH"
27+
fi
28+
}
29+
30+
# Function to install depthai viewer
31+
install_depthai() {
32+
echo "Installing viewer in virtual environment..."
33+
"$VENV_PATH/bin/python" -m pip install --upgrade pip
34+
"$VENV_PATH/bin/python" -m pip install depthai-viewer packaging depthai
35+
36+
sudo mkdir -p /usr/local/bin/
37+
printf '#!/bin/bash\nsource %s/bin/activate\n depthai-viewer "$@"' $VENV_PATH | sudo tee /usr/local/bin/depthai-viewer > /dev/null
38+
sudo chmod +x /usr/local/bin/depthai-viewer
39+
}
1840

41+
# macOS specific installation
1942
if [[ $(uname -s) == "Darwin" ]]; then
20-
echo _____________________________
43+
echo "_____________________________"
2144
echo "Calling macOS_installer.sh"
22-
echo _____________________________
45+
echo "_____________________________"
2346
echo "Running macOS installer."
2447

2548
echo "Installing global dependencies."
2649
bash -c "$(curl -fL https://raw.githubusercontent.com/luxonis/depthai-python/refs/heads/feat/install-rework/docs/install_dependencies.sh)"
2750

2851
echo "Upgrading brew."
2952
brew update
53+
brew install cmake
3054

31-
# clone depthai form git
32-
if [ -d "$DEPTHAI_DIR" ]; then
33-
echo "Demo app already downloaded. Checking out main and updating."
34-
else
35-
echo "Downloading demo app."
36-
git clone https://github.com/luxonis/depthai.git "$DEPTHAI_DIR"
37-
fi
38-
cd "$DEPTHAI_DIR"
39-
git fetch
40-
git checkout main
41-
git pull
42-
43-
# install python 3.10 and python dependencies
44-
brew update
45-
46-
if [ "$install_python" == "true" ]; then
47-
echo "installing python 3.10"
48-
brew install [email protected]
49-
python_executable=$(which python3.10)
50-
fi
55+
# Install Python 3.10 and dependencies if requested
56+
echo "Installing Python 3.10"
57+
brew install [email protected]
58+
59+
PYTHONPATH=$(which python3.10)
5160

5261
# pip does not have pyqt5 for arm
5362
if [[ $(uname -m) == 'arm64' ]]; then
5463
echo "Installing pyqt5 with homebrew."
5564
brew install pyqt@5
5665
fi
5766

58-
# create python virtual environment
59-
echo "Creating python virtual environment in $VENV_DIR"
60-
echo "$python_executable"
61-
"$python_executable" -m venv "$VENV_DIR"
62-
# activate environment
63-
source "$VENV_DIR/bin/activate"
64-
python -m pip install --upgrade pip
67+
create_venv
68+
69+
6570

66-
# install launcher dependencies
67-
# only on mac silicon point PYTHONPATH to pyqt5 installation via homebrew, otherwise install pyqt5 with pip
71+
"$VENV_PATH/bin/python" -m pip install --upgrade pip setuptools wheel
72+
# If on ARM, set the PYTHONPATH to include the Homebrew installation path
6873
if [[ $(uname -m) == 'arm64' ]]; then
6974
if [[ ":$PYTHONPATH:" == *":/opt/homebrew/lib/python3.10/site-packages:"* ]]; then
70-
echo "/opt/homebrew/lib/python$nr_1.$nr_2/site-packages already in PYTHONPATH"
75+
echo "/opt/homebrew/lib/python3.10/site-packages already in PYTHONPATH"
7176
else
72-
export "PYTHONPATH=/opt/homebrew/lib/python$nr_1.$nr_2/site-packages:"$PYTHONPATH
73-
echo "/opt/homebrew/lib/pythonv$nr_1.$nr_2/site-packages added to PYTHONPATH"
77+
export "PYTHONPATH=/opt/homebrew/lib/python3.10/site-packages:"$PYTHONPATH
78+
echo "/opt/homebrew/lib/python3.10/site-packages added to PYTHONPATH"
7479
fi
7580
else
76-
pip install pyqt5
81+
"$VENV_PATH/bin/python" -m pip install pyqt5
7782
fi
7883

79-
pip install packaging
84+
install_depthai
8085

86+
# Linux specific installation
8187
elif [[ $(uname -s) == "Linux" ]]; then
82-
echo _____________________________
88+
echo "_____________________________"
8389
echo "Calling linux_installer.sh"
84-
echo _____________________________
90+
echo "_____________________________"
8591

8692
echo "Updating sudo-apt."
8793
sudo apt-get update
88-
echo -e '\nRunning Linux installer.'
89-
94+
echo "Running Linux installer."
9095

9196
echo "Installing global dependencies."
9297
sudo apt-get install -y "${linux_pkgs[@]}"
9398

94-
echo "Creating python virtual environment in $VENV_PATH"
95-
96-
97-
if [ ! -d "$VENV_PATH" ]; then
98-
echo "Creating virtual environment at $VENV_PATH"
99-
mkdir -p "$VENV_PATH"
100-
python3 -m venv "$VENV_PATH"
101-
fi
102-
103-
echo "Installing viewer in virtual environment..."
104-
"$VENV_PATH/bin/python" -m pip install --upgrade pip
105-
"$VENV_PATH/bin/python" -m pip install depthai-viewer packaging
106-
99+
create_venv
107100
echo "Creating udev rules..."
108101
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666"' | sudo tee /etc/udev/rules.d/80-movidius.rules
109102
sudo udevadm control --reload-rules && sudo udevadm trigger
110103

111-
echo -e '#!/bin/bash\nsource .local/share/virtualenvs\nexec depthai-viewer "$@"' | sudo tee /usr/local/bin/depthai-viewer > /dev/null
112-
sudo chmod +x /usr/local/bin/depthai-viewer
104+
install_depthai
113105

106+
# Catch all other unsupported OS
114107
else
115108
echo "Error: Host $(uname -s) not supported."
116109
exit 99
117110
fi
118111

119-
echo "Creating virtual environment at $VENV_PATH"
120-
121-
if [ ! -d "$VENV_PATH" ]; then
122-
echo "Creating virtual environment at $VENV_PATH"
123-
mkdir -p "$VENV_PATH"
124-
python3 -m venv "$VENV_PATH"
125-
fi
126-
127-
128-
112+
# Final success message
129113
echo "Installation complete successfully"
130-
echo -e '\n\n:::::::::::::::: INSTALATION COMPLETE ::::::::::::::::\n'
131-
echo -e '\nTo run demo app write **depthai-viewer** in terminal.'
114+
echo -e '\n\n:::::::::::::::: INSTALLATION COMPLETE ::::::::::::::::\n'
115+
echo -e '\nTo run demo app, write **depthai-viewer** in terminal.'

0 commit comments

Comments
 (0)