Skip to content

Commit a538ded

Browse files
committed
build: combine setup and run into one script, add .sh file which supports linux and macOS
1 parent ffa2ae3 commit a538ded

3 files changed

Lines changed: 92 additions & 46 deletions

File tree

run.bat

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,48 @@
22
title LineBackupToDiscord
33
cd /d %~dp0
44

5-
REM Check if uv is installed
5+
REM Check if the virtual environment exists
6+
if not exist .venv (
7+
echo Virtual environment not found. Starting setup...
8+
9+
REM Check if uv is installed
10+
where uv >nul 2>nul
11+
if %errorlevel% equ 0 (
12+
echo Found uv! Using uv for setup...
13+
uv sync
14+
if errorlevel 1 (
15+
echo Failed to sync with uv
16+
pause
17+
exit /b 1
18+
)
19+
) else (
20+
echo uv not found, falling back to traditional setup...
21+
echo Creating virtual environment...
22+
python -m venv .venv
23+
if errorlevel 1 (
24+
echo Failed to create virtual environment
25+
pause
26+
exit /b 1
27+
)
28+
echo Activating virtual environment...
29+
call .venv\Scripts\activate
30+
if errorlevel 1 (
31+
echo Failed to activate virtual environment
32+
pause
33+
exit /b 1
34+
)
35+
echo Installing requirements...
36+
pip install -r requirements.txt
37+
if errorlevel 1 (
38+
echo Failed to install requirements
39+
pause
40+
exit /b 1
41+
)
42+
)
43+
echo Setup completed successfully!
44+
)
45+
46+
REM Run the application
647
where uv >nul 2>nul
748
if %errorlevel% equ 0 (
849
echo Running with uv...

run.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
# Change to the script's directory
4+
cd "$(dirname "$0")"
5+
6+
# Check if the virtual environment exists
7+
if [ ! -d ".venv" ]; then
8+
echo "Virtual environment not found. Starting setup..."
9+
10+
# Check if uv is installed
11+
if command -v uv &> /dev/null; then
12+
echo "Found uv! Using uv for setup..."
13+
uv sync
14+
if [ $? -ne 0 ]; then
15+
echo "Failed to sync with uv"
16+
exit 1
17+
fi
18+
else
19+
echo "uv not found, falling back to traditional setup..."
20+
echo "Creating virtual environment..."
21+
python3 -m venv .venv
22+
if [ $? -ne 0 ]; then
23+
echo "Failed to create virtual environment"
24+
exit 1
25+
fi
26+
echo "Activating virtual environment..."
27+
source .venv/bin/activate
28+
if [ $? -ne 0 ]; then
29+
echo "Failed to activate virtual environment"
30+
exit 1
31+
fi
32+
echo "Installing requirements..."
33+
pip install -r requirements.txt
34+
if [ $? -ne 0 ]; then
35+
echo "Failed to install requirements"
36+
exit 1
37+
fi
38+
fi
39+
echo "Setup completed successfully!"
40+
fi
41+
42+
# Run the application
43+
if command -v uv &> /dev/null; then
44+
echo "Running with uv..."
45+
uv run main.py
46+
else
47+
echo "Running with traditional venv..."
48+
source .venv/bin/activate
49+
python3 main.py
50+
fi

setup.bat

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)