-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_m1.sh
More file actions
executable file
·155 lines (136 loc) · 4.85 KB
/
install_m1.sh
File metadata and controls
executable file
·155 lines (136 loc) · 4.85 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
#!/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
# Force link OpenBLAS
echo "Linking OpenBLAS..."
brew link --force openblas
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
# Special handling for Apple Silicon Macs
if [[ "$OSTYPE" == "darwin"* ]] && [[ $(uname -m) == 'arm64' ]]; then
echo "Detected Apple Silicon (M1/M2/M3) Mac..."
# First, ensure pip is upgraded
pip install --upgrade pip
# Install scipy separately using a specific, known-good version with binary wheel
echo "Installing scipy binary wheel for Apple Silicon..."
pip install --only-binary=:all: scipy==1.11.4
# Install numpy separately first (required for shedskin)
echo "Installing numpy binary wheel for Apple Silicon..."
pip install --only-binary=:all: numpy==1.26.4
# Install other basic scientific libraries that might be needed
echo "Installing other scientific libraries..."
pip install --only-binary=:all: matplotlib pandas
# Install the requirements.txt but skip scipy and numpy that are already installed
echo "Installing remaining requirements..."
pip install --only-binary=:all: --no-deps shedskin@git+https://github.com/shedskin/shedskin.git@v0.9.10#egg=shedskin
pip install pipx
else
# For other platforms, install requirements normally
echo "Installing Python requirements..."
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!"