IAGO / setup.sh
James Frecheville
Initial commit for Hugging Face Spaces deployment
0354298
#!/bin/bash
# Script to automate running OWL locally on a Mac
# Check if Python 3 is installed and check version compatibility
echo "Checking Python version..."
PYTHON_VERSION=$(python3 --version 2>&1)
if [[ "$PYTHON_VERSION" =~ "Python 3" ]]; then
echo "Python found: $PYTHON_VERSION"
# Extract version numbers
VERSION_NUM=$(echo $PYTHON_VERSION | cut -d' ' -f2)
MAJOR=$(echo $VERSION_NUM | cut -d. -f1)
MINOR=$(echo $VERSION_NUM | cut -d. -f2)
if [ "$MAJOR" -eq 3 ] && [ "$MINOR" -ge 10 ] && [ "$MINOR" -lt 13 ]; then
echo "Python version is compatible!"
else
echo "Error: OWL requires Python version >=3.10 and <3.13"
echo "Your version ($VERSION_NUM) is not compatible."
echo ""
echo "Please install Python 3.10 using one of these methods:"
echo "1. Download from python.org/downloads/"
echo "2. Using Homebrew:"
echo " a. Install Homebrew first (if not installed):"
echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
echo " b. Then install Python 3.10:"
echo " brew install [email protected]"
echo ""
echo "After installing, run this script again using the correct Python version:"
echo "python3.10 setup.sh"
exit 1
fi
else
echo "Python 3 not found! Please install it from python.org/downloads/ and rerun this script."
exit 1
fi
# Create and activate virtual environment
echo "Setting up Python virtual environment..."
python3 -m venv venv
source venv/bin/activate || { echo "Failed to activate virtual environment!"; exit 1; }
# Install dependencies
echo "Installing dependencies from requirements.txt..."
if [ -f "requirements.txt" ]; then
pip3 install -r requirements.txt || { echo "Failed to install dependencies!"; exit 1; }
else
echo "No requirements.txt found! Cannot continue."
exit 1
fi
# Run OWL
echo "Attempting to run OWL..."
if [ -f "owl/webapp.py" ]; then
python3 owl/webapp.py
else
echo "Could not find owl/webapp.py! Please check the repository structure."
exit 1
fi
echo "If you see errors, copy them and ask for help!"