feat: modified scripts to use uv instead of pip for easier onboarding

This commit is contained in:
Chaudry24
2025-06-04 10:42:55 -05:00
parent e8e7a6ee3d
commit 4cf5761603
3 changed files with 113 additions and 48 deletions
+26 -19
View File
@@ -4,25 +4,18 @@ echo "Starting installation for Linux..."
set -e set -e
if ! command -v python3.10 &> /dev/null; then # Check if uv is installed
echo "Error: Python 3.10 is not installed. Please install Python 3.10 and try again." if ! command -v uv &> /dev/null; then
echo "You can install it using: sudo apt-get install python3.10 python3.10-dev python3.10-venv" echo "Error: uv is not installed. Please install uv first."
echo "You can install it using: curl -LsSf https://astral.sh/uv/install.sh | sh"
exit 1 exit 1
fi fi
# Check if pip3.10 is available
if ! python3.10 -m pip --version &> /dev/null; then
echo "Error: pip for Python 3.10 is not installed. Installing python3.10-pip..."
sudo apt-get install -y python3.10-pip || { echo "Failed to install python3.10-pip"; exit 1; }
fi
# Update package list # Update package list
sudo apt-get update || { echo "Failed to update package list"; exit 1; } sudo apt-get update || { echo "Failed to update package list"; exit 1; }
# make sure essential tool are installed # make sure essential tool are installed
sudo apt-get install -y \ sudo apt-get install -y \
python3-dev \ python3-dev \
python3-pip \
python3-wheel \
build-essential \ build-essential \
alsa-utils \ alsa-utils \
portaudio19-dev \ portaudio19-dev \
@@ -33,15 +26,29 @@ sudo apt-get install -y \
libnss3 \ libnss3 \
libxss1 || { echo "Failed to install packages"; exit 1; } libxss1 || { echo "Failed to install packages"; exit 1; }
# Upgrade pip for Python 3.10 # Initialize uv project if pyproject.toml doesn't exist
python3.10 -m pip install --upgrade pip || { echo "Failed to upgrade pip"; exit 1; } if [ ! -f "pyproject.toml" ]; then
# Install and upgrade setuptools and wheel echo "Initializing uv project..."
python3.10 -m pip install --upgrade setuptools wheel || { echo "Failed to install setuptools and wheel"; exit 1; } uv init --python 3.10 || { echo "Failed to initialize uv project"; exit 1; }
# Install Selenium for chromedriver fi
python3.10 -m pip install selenium || { echo "Failed to install selenium"; exit 1; }
# Install Python dependencies from requirements.txt # Sync the project (creates venv and installs dependencies)
python3.10 -m pip install -r requirements.txt --no-cache-dir || { echo "Failed to install requirements.txt"; exit 1; } echo "Setting up Python environment with uv..."
uv sync --python 3.10 || { echo "Failed to sync uv project"; exit 1; }
# Add specific packages
echo "Adding Selenium..."
uv add selenium || { echo "Failed to add selenium"; exit 1; }
# Add dependencies from requirements.txt if it exists
if [ -f "requirements.txt" ]; then
echo "Adding dependencies from requirements.txt..."
uv add -r requirements.txt || { echo "Failed to add requirements from requirements.txt"; exit 1; }
fi
# install docker compose # install docker compose
sudo apt install -y docker-compose sudo apt install -y docker-compose
echo "Installation complete for Linux!" echo "Installation complete for Linux!"
echo "To activate the environment, run: source .venv/bin/activate"
echo "Or run commands with: uv run <command>"
+25 -17
View File
@@ -4,18 +4,13 @@ echo "Starting installation for macOS..."
set -e set -e
if ! command -v python3.10 &> /dev/null; then # Check if uv is installed
echo "Error: Python 3.10 is not installed. Please install Python 3.10 and try again." if ! command -v uv &> /dev/null; then
echo "You can install it using: sudo apt-get install python3.10 python3.10-dev python3.10-venv" echo "Error: uv is not installed. Please install uv first."
echo "You can install it using: curl -LsSf https://astral.sh/uv/install.sh | sh"
exit 1 exit 1
fi fi
# Check if pip3.10 is available
if ! python3.10 -m pip --version &> /dev/null; then
echo "Error: pip for Python 3.10 is not installed. Installing python3.10-pip..."
sudo apt-get install -y python3.10-pip || { echo "Failed to install python3.10-pip"; exit 1; }
fi
# Check if homebrew is installed # Check if homebrew is installed
if ! command -v brew &> /dev/null; then if ! command -v brew &> /dev/null; then
echo "Homebrew not found. Installing Homebrew..." echo "Homebrew not found. Installing Homebrew..."
@@ -31,13 +26,26 @@ brew install --cask chromedriver
# Install portaudio for pyAudio using Homebrew # Install portaudio for pyAudio using Homebrew
brew install portaudio brew install portaudio
# Upgrade pip for Python 3.10 # Initialize uv project if pyproject.toml doesn't exist
python3.10 -m pip install --upgrade pip || { echo "Failed to upgrade pip"; exit 1; } if [ ! -f "pyproject.toml" ]; then
# Install and upgrade setuptools and wheel echo "Initializing uv project..."
python3.10 -m pip install --upgrade setuptools wheel || { echo "Failed to install setuptools and wheel"; exit 1; } uv init --python 3.10 || { echo "Failed to initialize uv project"; exit 1; }
# Install Selenium for chromedriver fi
python3.10 -m pip install selenium || { echo "Failed to install selenium"; exit 1; }
# Install Python dependencies from requirements.txt # Sync the project (creates venv and installs dependencies)
python3.10 -m pip install -r requirements.txt --no-cache-dir || { echo "Failed to install requirements.txt"; exit 1; } echo "Setting up Python environment with uv..."
uv sync --python 3.10 || { echo "Failed to sync uv project"; exit 1; }
# Add specific packages
echo "Adding Selenium..."
uv add selenium || { echo "Failed to add selenium"; exit 1; }
# Add dependencies from requirements.txt if it exists
if [ -f "requirements.txt" ]; then
echo "Adding dependencies from requirements.txt..."
uv add -r requirements.txt || { echo "Failed to add requirements from requirements.txt"; exit 1; }
fi
echo "Installation complete for macOS!" echo "Installation complete for macOS!"
echo "To activate the environment, run: source .venv/bin/activate"
echo "Or run commands with: uv run <command>"
+60 -10
View File
@@ -1,17 +1,67 @@
@echo off @echo off
echo Starting installation for Windows... echo Starting installation for Windows...
REM Install Python dependencies from requirements.txt REM Check if uv is installed
pip install pyreadline3 uv --version >nul 2>&1
pip install -r requirements.txt if %errorlevel% neq 0 (
echo Error: uv is not installed. Please install uv first.
echo You can install it using: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
pause
exit /b 1
)
REM Install Selenium REM Initialize uv project if pyproject.toml doesn't exist
pip install selenium if not exist "pyproject.toml" (
echo Initializing uv project...
uv init --python 3.10
if %errorlevel% neq 0 (
echo Failed to initialize uv project
pause
exit /b 1
)
)
REM Sync the project (creates venv and installs dependencies)
echo Setting up Python environment with uv...
uv sync --python 3.10
if %errorlevel% neq 0 (
echo Failed to sync uv project
pause
exit /b 1
)
REM Add specific packages
echo Adding pyreadline3...
uv add pyreadline3
if %errorlevel% neq 0 (
echo Failed to add pyreadline3
pause
exit /b 1
)
echo Adding Selenium...
uv add selenium
if %errorlevel% neq 0 (
echo Failed to add selenium
pause
exit /b 1
)
REM Add dependencies from requirements.txt if it exists
if exist "requirements.txt" (
echo Adding dependencies from requirements.txt...
uv add -r requirements.txt
if %errorlevel% neq 0 (
echo Warning: Some packages from requirements.txt failed to install.
)
)
echo Installation complete for Windows!
echo To activate the environment, run: .venv\Scripts\activate
echo Or run commands with: uv run ^<command^>
echo.
echo Note: pyAudio installation may require additional steps on Windows. echo Note: pyAudio installation may require additional steps on Windows.
echo Please install portaudio manually (e.g., via vcpkg or prebuilt binaries) and then run: pip install pyaudio echo If pyAudio fails to install, please install portaudio manually and try again.
echo Also, download and install chromedriver manually from: https://sites.google.com/chromium.org/driver/getting-started echo Also, chromedriver-autoinstaller should handle chromedriver automatically.
echo Place chromedriver in a directory included in your PATH. echo If needed, download chromedriver manually from: https://sites.google.com/chromium.org/driver/getting-started
echo Installation partially complete for Windows. Follow manual steps above.
pause pause