-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
Β·186 lines (158 loc) Β· 5.56 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
Β·186 lines (158 loc) Β· 5.56 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/bash
# Sayna Python SDK - Development Environment Setup Script
# This script helps set up the development environment with either pip or uv
set -e # Exit on error
echo "π Sayna Python SDK - Development Setup"
echo "========================================"
echo ""
# Check Python version
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
echo "β Python version: $PYTHON_VERSION"
# Check if we're in the correct directory
if [ ! -f "pyproject.toml" ]; then
echo "β Error: pyproject.toml not found. Please run this script from the python-sdk directory."
exit 1
fi
# Function to check if python3-venv is available
check_venv_support() {
if python3 -m venv --help &> /dev/null; then
return 0
else
return 1
fi
}
# Function to verify venv was created successfully
verify_venv() {
if [ -f ".venv/bin/activate" ]; then
return 0
else
return 1
fi
}
echo ""
echo "Choose installation method:"
echo "1) pip (traditional)"
echo "2) uv (modern, faster)"
read -p "Enter your choice (1 or 2): " choice
case $choice in
1)
echo ""
echo "π¦ Setting up with pip..."
# Check if venv module is available
if ! check_venv_support; then
echo ""
echo "β Error: python3-venv is not installed on your system."
echo ""
echo "To fix this, install python3-venv:"
echo " sudo apt install python3.12-venv"
echo ""
echo "Or install for your specific Python version:"
echo " sudo apt install python3-venv"
echo ""
echo "After installing, run this script again."
exit 1
fi
# Create virtual environment
if [ ! -d ".venv" ]; then
echo "Creating virtual environment..."
python3 -m venv .venv
# Verify venv was created successfully
if ! verify_venv; then
echo ""
echo "β Error: Virtual environment creation failed."
echo ""
echo "The .venv directory was created but the activation script is missing."
echo "This usually means python3-venv is not properly installed."
echo ""
echo "Please install it with:"
echo " sudo apt install python3.12-venv"
echo ""
exit 1
fi
echo "β Virtual environment created successfully"
else
echo "Virtual environment already exists."
# Verify existing venv is valid
if ! verify_venv; then
echo ""
echo "β οΈ Warning: Existing .venv directory is incomplete."
echo "Removing and recreating..."
rm -rf .venv
python3 -m venv .venv
if ! verify_venv; then
echo "β Error: Could not create valid virtual environment."
echo "Please install python3-venv:"
echo " sudo apt install python3.12-venv"
exit 1
fi
fi
fi
# Activate virtual environment
echo "Activating virtual environment..."
source .venv/bin/activate
# Ensure pip is available in the venv
if ! command -v pip &> /dev/null; then
echo "β οΈ pip not found in venv, installing..."
python3 -m ensurepip --upgrade || {
echo "β Error: Could not install pip using ensurepip"
echo "Trying alternative method..."
curl -sS https://bootstrap.pypa.io/get-pip.py | python3
}
fi
# Upgrade pip
echo "Upgrading pip..."
python3 -m pip install --upgrade pip
# Install package in editable mode with dev dependencies
echo "Installing package and dependencies..."
python3 -m pip install -e ".[dev]"
echo ""
echo "β
Setup complete with pip!"
echo ""
echo "To activate the virtual environment in the future, run:"
echo " source .venv/bin/activate"
;;
2)
echo ""
echo "π¦ Setting up with uv (faster)..."
# Check if uv is installed
if ! command -v uv &> /dev/null; then
echo "uv is not installed. Installing uv..."
pip install uv
else
echo "β uv is already installed"
fi
# Create virtual environment
if [ ! -d ".venv" ]; then
echo "Creating virtual environment with uv..."
uv venv
else
echo "Virtual environment already exists."
fi
# Activate virtual environment
echo "Activating virtual environment..."
source .venv/bin/activate
# Install package in editable mode with dev dependencies
echo "Installing package and dependencies with uv..."
uv pip install -e ".[dev]"
echo ""
echo "β
Setup complete with uv!"
echo ""
echo "To activate the virtual environment in the future, run:"
echo " source .venv/bin/activate"
;;
*)
echo "β Invalid choice. Please run the script again and choose 1 or 2."
exit 1
;;
esac
echo ""
echo "π Development environment is ready!"
echo ""
echo "Next steps:"
echo " 1. Activate the environment: source .venv/bin/activate"
echo " 2. Run tests: pytest"
echo " 3. Type check: mypy src/sayna_client"
echo " 4. Lint code: ruff check ."
echo " 5. Format code: ruff format ."
echo ""
echo "Happy coding! π"