forked from microsoft/fabric-cicd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivate.sh
More file actions
executable file
·110 lines (101 loc) · 3.44 KB
/
activate.sh
File metadata and controls
executable file
·110 lines (101 loc) · 3.44 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
#!/bin/bash
#
#
# Script to check and install required Python packages, Node.js tools,
# add directories to PATH, and activate a virtual environment.
#
# ---------------------------------------------------------------------------------------
#
set -e
PACKAGES=""
if ! command -v python3.11 &> /dev/null; then PACKAGES="python3.11"; fi
if ! command -v pip &> /dev/null; then PACKAGES="${PACKAGES:+$PACKAGES }python3-pip"; fi
if ! command -v node &> /dev/null; then PACKAGES="${PACKAGES:+$PACKAGES }nodejs"; fi
if ! command -v npm &> /dev/null; then PACKAGES="${PACKAGES:+$PACKAGES }npm"; fi
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if [ -n "$PACKAGES" ]; then
echo "Installing required packages for Linux: $PACKAGES"
sudo apt-get update > /dev/null 2>&1
if sudo DEBIAN_FRONTEND=noninteractive apt-get install -y $PACKAGES > /dev/null 2>&1; then
echo "Packages installed successfully."
else
echo "Failed to install packages."
exit 1
fi
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
if ! command -v brew &> /dev/null; then
echo "Homebrew not found. Please install Homebrew first."
exit 1
fi
BREW_PACKAGES=""
if ! command -v python3.11 &> /dev/null; then BREW_PACKAGES="python@3.11"; fi
if ! command -v node &> /dev/null; then BREW_PACKAGES="${BREW_PACKAGES:+$BREW_PACKAGES }node"; fi
if [ -n "$BREW_PACKAGES" ]; then
echo "Installing required packages for macOS: $BREW_PACKAGES"
if brew install $BREW_PACKAGES; then
echo "Packages installed successfully."
else
echo "Failed to install packages."
exit 1
fi
fi
fi
# Install uv if not present
if ! command -v uv &> /dev/null; then
echo "Installing uv..."
if curl -LsSf https://astral.sh/uv/install.sh | sh; then
echo "uv installed successfully."
else
echo "Failed to install uv."
exit 1
fi
else
echo "uv is already installed."
fi
# Install changie globally via npm if not present
if ! command -v changie &> /dev/null; then
echo "Installing changie globally via npm..."
if npm install -g changie; then
echo "changie installed successfully."
else
echo "Failed to install changie."
exit 1
fi
else
echo "changie is already installed."
fi
# Install VS Code Python extension if VS Code is available
if command -v code &> /dev/null; then
echo "Installing VS Code Python extension..."
if code --install-extension ms-python.python --force > /dev/null 2>&1; then
echo "VS Code Python extension installed successfully."
else
echo "Failed to install VS Code Python extension."
fi
else
echo "VS Code not found, skipping extension installation."
fi
# Add required directories to PATH
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
export PATH="$PATH:$HOME/.local/bin"
echo "Added $HOME/.local/bin to PATH."
fi
if [[ ":$PATH:" != *":$HOME/.cargo/bin:"* ]]; then
export PATH="$PATH:$HOME/.cargo/bin"
echo "Added $HOME/.cargo/bin to PATH."
fi
# Sync Python environment and activate
echo "Syncing Python environment with uv..."
if uv sync --python 3.11; then
echo "Python environment synced successfully."
else
echo "Failed to sync Python environment."
exit 1
fi
if [ -f .venv/bin/activate ]; then
source .venv/bin/activate
echo "Virtual environment activated."
else
echo "Virtual environment not found."
fi