-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·75 lines (64 loc) · 1.88 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·75 lines (64 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Setup script for snap7-gui (Unix/macOS/Linux)
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_DIR="$SCRIPT_DIR/venv"
echo "=== snap7-gui Setup ==="
echo ""
# Check Python version
PYTHON_CMD=""
for cmd in python3 python; do
if command -v "$cmd" &> /dev/null; then
version=$("$cmd" -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
major=$("$cmd" -c "import sys; print(sys.version_info.major)")
minor=$("$cmd" -c "import sys; print(sys.version_info.minor)")
if [ "$major" -ge 3 ] && [ "$minor" -ge 9 ]; then
PYTHON_CMD="$cmd"
echo "Found Python $version at $(which $cmd)"
break
fi
fi
done
if [ -z "$PYTHON_CMD" ]; then
echo "Error: Python 3.9 or higher is required but not found."
echo "Please install Python 3.9+ and try again."
exit 1
fi
# Create virtual environment
if [ -d "$VENV_DIR" ]; then
echo ""
echo "Virtual environment already exists at $VENV_DIR"
read -p "Do you want to recreate it? [y/N] " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Removing existing virtual environment..."
rm -rf "$VENV_DIR"
else
echo "Keeping existing virtual environment."
fi
fi
if [ ! -d "$VENV_DIR" ]; then
echo ""
echo "Creating virtual environment..."
"$PYTHON_CMD" -m venv "$VENV_DIR"
fi
# Activate virtual environment
echo "Activating virtual environment..."
source "$VENV_DIR/bin/activate"
# Upgrade pip
echo ""
echo "Upgrading pip..."
pip install --upgrade pip --quiet
# Install dependencies
echo ""
echo "Installing dependencies..."
pip install -r "$SCRIPT_DIR/requirements.txt"
echo ""
echo "=== Setup Complete ==="
echo ""
echo "To run the application:"
echo " ./run.sh"
echo ""
echo "Or manually activate the environment:"
echo " source venv/bin/activate"
echo " python main.py"