-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·165 lines (147 loc) · 5.12 KB
/
install.sh
File metadata and controls
executable file
·165 lines (147 loc) · 5.12 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
#!/bin/bash
# Function to check if a brew package is installed
check_brew_package() {
brew list $1 &>/dev/null
return $?
}
# Function to check if a debian package is installed
check_deb_package() {
dpkg -l "$1" &>/dev/null
return $?
}
# Function to check if a rpm package is installed
check_rpm_package() {
rpm -q "$1" &>/dev/null
return $?
}
# Detect operating system
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
if ! command -v brew &> /dev/null; then
echo "Homebrew not found. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
if ! check_brew_package "bdw-gc"; then
echo "Installing bdw-gc on macOS..."
brew install bdw-gc
else
echo "bdw-gc is already installed"
fi
if ! check_brew_package "pcre"; then
echo "Installing pcre on macOS..."
brew install pcre
else
echo "pcre is already installed"
fi
# Add OpenBLAS installation for M1/M2/M3 Macs
if ! check_brew_package "openblas"; then
echo "Installing OpenBLAS on macOS..."
brew install openblas
else
echo "OpenBLAS is already installed"
fi
# Install LLVM for OpenMP support on macOS
if ! check_brew_package "llvm"; then
echo "Installing LLVM for OpenMP support..."
brew install llvm
else
echo "LLVM is already installed"
fi
# Force link OpenBLAS
echo "Linking OpenBLAS..."
brew link --force openblas
# Set environment variables for OpenBLAS and OpenMP
echo "Setting up environment variables..."
export OPENBLAS=$(brew --prefix openblas)
export LLVM_PATH=$(brew --prefix llvm)
export CC="$LLVM_PATH/bin/clang"
export CXX="$LLVM_PATH/bin/clang++"
export CFLAGS="-I$OPENBLAS/include -I$LLVM_PATH/include ${CFLAGS}"
export CXXFLAGS="-I$OPENBLAS/include -I$LLVM_PATH/include ${CXXFLAGS}"
export LDFLAGS="-L$OPENBLAS/lib -L$LLVM_PATH/lib ${LDFLAGS}"
export PKG_CONFIG_PATH="$OPENBLAS/lib/pkgconfig:$LLVM_PATH/lib/pkgconfig:${PKG_CONFIG_PATH}"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
if command -v apt-get &> /dev/null; then
echo "Checking dependencies on Debian/Ubuntu..."
if ! check_deb_package "libgc-dev"; then
echo "Installing libgc-dev..."
sudo apt-get update
sudo apt-get install -y libgc-dev
else
echo "libgc-dev is already installed"
fi
if ! check_deb_package "libpcre3-dev"; then
echo "Installing libpcre3-dev..."
sudo apt-get update
sudo apt-get install -y libpcre3-dev
else
echo "libpcre3-dev is already installed"
fi
# Add OpenBLAS for Linux
if ! check_deb_package "libopenblas-dev"; then
echo "Installing libopenblas-dev..."
sudo apt-get update
sudo apt-get install -y libopenblas-dev
else
echo "libopenblas-dev is already installed"
fi
elif command -v dnf &> /dev/null; then
echo "Checking dependencies on Fedora..."
if ! check_rpm_package "gc-devel"; then
echo "Installing gc-devel..."
sudo dnf install -y gc-devel
else
echo "gc-devel is already installed"
fi
if ! check_rpm_package "pcre-devel"; then
echo "Installing pcre-devel..."
sudo dnf install -y pcre-devel
else
echo "pcre-devel is already installed"
fi
# Add OpenBLAS for Fedora
if ! check_rpm_package "openblas-devel"; then
echo "Installing openblas-devel..."
sudo dnf install -y openblas-devel
else
echo "openblas-devel is already installed"
fi
else
echo "Unsupported Linux distribution. Please install libgc-dev, libpcre3-dev, and libopenblas-dev manually."
exit 1
fi
else
echo "Unsupported operating system: $OSTYPE"
exit 1
fi
# Check if virtual environment already exists
if [ ! -d "venv" ]; then
echo "Creating Python virtual environment..."
python3.12 -m venv venv
else
echo "Virtual environment already exists"
fi
echo "Activating virtual environment..."
source venv/bin/activate
# For M1/M2/M3 Macs, install scipy binary wheel and disable OpenMP
if [[ "$OSTYPE" == "darwin"* ]] && [[ $(uname -m) == 'arm64' ]]; then
echo "Configuring for Apple Silicon..."
# Disable OpenMP on macOS to avoid compilation issues
export SCIPY_USE_PYTHRAN=0
export SCIPY_USE_PROPACK=0
export NPY_USE_BLAS_ILP64=0
export OPENBLAS_NUM_THREADS=1
export SCIPY_ALLOW_OPENMP_BUILD=0
# Force binary wheel installation for scipy
pip install --only-binary=scipy scipy
# Install other requirements with binary preference
pip install --prefer-binary -r requirements.txt
else
# For other platforms
pip install -r requirements.txt
fi
# Install aider from GitHub
echo "Installing aider-chat from GitHub..."
pip install --upgrade --upgrade-strategy only-if-needed git+https://github.com/Aider-AI/aider.git
echo "Installation completed successfully!"