-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_uv_setup.sh
More file actions
executable file
·58 lines (51 loc) · 1.17 KB
/
python_uv_setup.sh
File metadata and controls
executable file
·58 lines (51 loc) · 1.17 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
confirm() {
local -r prompt="$1"
local choice
while true; do
read -r -p "$prompt (y/n): " choice
case "$choice" in
y | yes | Y | Yes)
return 0 # Return 0 for success (true)
;;
n | no | N | No)
return 1 # Return 1 for failure (false)
;;
*)
echo "Invalid input. Please enter 'y' or 'n'."
;;
esac
done
}
# Check for uv
uv --version
if [ $? != 0 ]; then
if confirm "Would you like to install uv?"; then
curl -LsSf https://astral.sh/uv/install.sh | sh
else
echo "Operation canceled."
exit 1
fi
else
echo "Found uv."
fi
if [ -d ./.venv ]; then
echo "Found .venv/"
else
echo ".venv/ not found."
if confirm "Would you like to create it?"; then
uv venv
else
echo "Operation canceled."
exit 1
fi
fi
source .venv/bin/activate
echo "Virtual environment activated."
if confirm "Install requirements?"; then
echo "Installing requirements..."
uv pip install -r requirements.txt
else
echo "Operation canceled."
exit 1
fi
echo "Run 'source .venv/bin/activate' in your shell"