From 84d9a4799958e85b65da2e48f1d35d718a56ae7a Mon Sep 17 00:00:00 2001 From: Emre <69351390+emredeveloper@users.noreply.github.com> Date: Sun, 19 Oct 2025 20:05:30 +0300 Subject: [PATCH] Improve setup script robustness and add Windows installer --- requirements.bat | 10 ++++++++++ setup.sh | 30 +++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 requirements.bat diff --git a/requirements.bat b/requirements.bat new file mode 100644 index 0000000..6712dfb --- /dev/null +++ b/requirements.bat @@ -0,0 +1,10 @@ +@echo off +REM Transformers Examples dependency installer for Windows + +IF NOT DEFINED VIRTUAL_ENV ( + echo Warning: No virtual environment detected. Consider creating one before installing dependencies. +) + +python -m pip install --upgrade pip +python -m pip install -r requirements.txt + diff --git a/setup.sh b/setup.sh index 6c76fa4..56eeef5 100755 --- a/setup.sh +++ b/setup.sh @@ -1,30 +1,45 @@ #!/bin/bash +set -euo pipefail + +trap 'echo "❌ An unexpected error occurred. Exiting setup." >&2' ERR +trap 'echo "âš ī¸ Setup interrupted." >&2' INT TERM # Transformers Examples Setup Script echo "🚀 Setting up Transformers Examples repository..." +# Suggest Windows alternative if running in Windows-like environment +if [[ "${OSTYPE:-}" == msys* || "${OSTYPE:-}" == cygwin* || "${OSTYPE:-}" == win32* ]]; then + echo "â„šī¸ Windows users can run requirements.bat or adapt the steps in a PowerShell script." +fi + # Check if Python is installed if ! command -v python3 &> /dev/null; then echo "❌ Python 3 is not installed. Please install Python 3.7+ first." exit 1 fi -echo "✅ Python 3 found: $(python3 --version)" +python_version="$(python3 --version)" +echo "✅ Python 3 found: ${python_version}" # Create virtual environment (optional but recommended) -if [ "$1" == "--venv" ]; then +if [[ "${1:-}" == "--venv" ]]; then echo "đŸ“Ļ Creating virtual environment..." python3 -m venv venv + # shellcheck source=/dev/null source venv/bin/activate echo "✅ Virtual environment activated" fi # Install requirements echo "đŸ“Ĩ Installing dependencies..." -pip install -r requirements.txt +if [[ -z "${VIRTUAL_ENV:-}" ]]; then + echo "âš ī¸ Warning: No active virtual environment detected. Consider running with --venv or activating one manually." +fi +python3 -m pip install --upgrade pip +python3 -m pip install -r requirements.txt # Check if .env file exists -if [ ! -f ".env" ]; then +if [[ ! -f ".env" ]]; then echo "âš™ī¸ Creating .env file from template..." cp .env.example .env echo "📝 Please edit .env file and add your Hugging Face token" @@ -38,9 +53,10 @@ echo "Next steps:" echo "1. Edit .env file and add your Hugging Face token (if needed)" echo "2. Explore the examples in different directories:" echo " - Genel-1/ for basic transformer examples" -echo " - Genel-2/ for vision transformers" +echo " - Genel-2/ for vision transformers" echo " - 'Multi Modal'/ for multimodal examples" echo " - llama/ for LLaMA implementation" -echo "3. Run: python test-time-scaling.py for a quick test" +echo "3. Run: python3 test-time-scaling.py for a quick test" echo "" -echo "📚 Check README.md for detailed usage instructions" \ No newline at end of file +echo "📚 Check README.md for detailed usage instructions" +