-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
84 lines (74 loc) · 2.23 KB
/
setup.sh
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
76
77
78
79
80
81
82
83
84
#!/bin/bash
echo "==================================="
echo "Code Structure Analyzer Setup"
echo "==================================="
echo ""
# Check if Python is installed
if command -v python &> /dev/null; then
PYTHON_CMD="python"
else
echo "Error: Python is not installed."
echo "Please install Python 3.10 or later from https://www.python.org/downloads/"
exit 1
fi
# Create virtual environment if it doesn't exist
if [ ! -d ".venv" ]; then
echo "Creating virtual environment..."
$PYTHON_CMD -m venv .venv
if [ $? -ne 0 ]; then
echo "Error: Failed to create virtual environment."
exit 1
fi
fi
# Activate virtual environment
echo "Activating virtual environment..."
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
if [ -f "$SCRIPT_DIR/.venv/bin/activate" ]; then
source "$SCRIPT_DIR/.venv/bin/activate"
elif [ -f "$SCRIPT_DIR/.venv/Scripts/activate" ]; then
source "$SCRIPT_DIR/.venv/Scripts/activate"
else
echo "Error: Could not find activation script."
exit 1
fi
if [ $? -ne 0 ]; then
echo "Error: Failed to activate virtual environment."
exit 1
fi
# Install requirements
echo "Installing requirements..."
pip install -r requirements.txt
if [ $? -ne 0 ]; then
echo "Error: Failed to install requirements."
exit 1
fi
# Install the package in development mode
echo "Installing package in development mode..."
pip install -e .
if [ $? -ne 0 ]; then
echo "Error: Failed to install the package."
exit 1
fi
# Create .env file if it doesn't exist
if [ ! -f ".env" ]; then
echo "Creating .env file..."
cp .env.example .env
if [ $? -ne 0 ]; then
echo "Error: Failed to create .env file."
exit 1
fi
fi
# Set up pre-commit hooks
echo "Setting up pre-commit hooks..."
pre-commit run --config ./dev_config/python/.pre-commit-config.yaml --all-files || echo "Pre-commit setup completed with warnings."
echo ""
echo "==================================="
echo "Setup completed successfully!"
echo "==================================="
echo ""
echo "To use Code Structure Analyzer:"
echo "1. Make sure LMStudio is running on localhost:1234"
echo "2. Run the tool with: python -m csa.cli [source_dir]"
echo ""
echo "For more options, run: python -m csa.cli --help"
echo ""