Skip to content

Instantly share code, notes, and snippets.

@andiradulescu
Created July 29, 2024 18:17
Show Gist options
  • Save andiradulescu/16b1038a8986c855cf9ea71ea740f9b5 to your computer and use it in GitHub Desktop.
Save andiradulescu/16b1038a8986c855cf9ea71ea740f9b5 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
ARCH=$(uname -m)
# install brew if required
if [[ $(command -v brew) == "" ]]; then
echo "Installing Homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [[ $SHELL == "/bin/zsh" ]]; then
RC_FILE="$HOME/.zprofile"
elif [[ $SHELL == "/bin/bash" ]]; then
RC_FILE="$HOME/.bash_profile"
fi
# make brew available now
if [[ $ARCH == "x86_64" ]]; then
echo 'eval "$(/usr/local/bin/brew shellenv)"' >> $RC_FILE
eval "$(/usr/local/bin/brew shellenv)"
else
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> $RC_FILE
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
fi
BREW_PREFIX=$(brew --prefix)
# install libusb
if [ ! -f $BREW_PREFIX/lib/libusb-1.0.0.dylib ]; then
echo "Installing libusb"
brew install libusb
if [[ $ARCH == "arm64" ]]; then
# https://github.com/pyusb/pyusb/issues/520
# https://github.com/pyusb/pyusb/issues/355#issuecomment-974726078
ln -s $BREW_PREFIX/lib/libusb-1.0.0.dylib /usr/local/lib/libusb.dylib
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment