@@ -150,10 +150,14 @@ install_dependencies() {
150150install_python_dependencies () {
151151 print_step " Installing Python dependencies for Lambda..."
152152
153+ # Lambda runtime platform options (Amazon Linux 2, x86_64, Python 3.12)
154+ # This ensures we get Linux-compatible binaries even when running on macOS
155+ local PIP_PLATFORM_OPTS=" --platform manylinux2014_x86_64 --implementation cp --python-version 3.12 --only-binary=:all:"
156+
153157 # Install webapp-backend dependencies
154158 local WEBAPP_DIR=" $SCRIPT_DIR /lambda/webapp-backend"
155159 if [ -f " $WEBAPP_DIR /requirements.txt" ]; then
156- echo " Installing webapp-backend dependencies..."
160+ echo " Installing webapp-backend dependencies for Lambda (Linux x86_64) ..."
157161
158162 # Clean up old packages (keep only main.py and requirements.txt)
159163 find " $WEBAPP_DIR " -mindepth 1 -maxdepth 1 \
@@ -162,11 +166,23 @@ install_python_dependencies() {
162166 ! -name " .gitkeep" \
163167 -exec rm -rf {} + 2> /dev/null || true
164168
165- # Install dependencies to the directory
169+ # Install dependencies with Lambda-compatible platform
166170 python3 -m pip install \
167171 --quiet \
168172 --target " $WEBAPP_DIR " \
169- -r " $WEBAPP_DIR /requirements.txt"
173+ $PIP_PLATFORM_OPTS \
174+ -r " $WEBAPP_DIR /requirements.txt" 2> /dev/null || {
175+ # Fallback: some packages don't have pre-built wheels
176+ # Try without --only-binary for pure Python packages
177+ print_warning " Some packages need source build, retrying..."
178+ python3 -m pip install \
179+ --quiet \
180+ --target " $WEBAPP_DIR " \
181+ --platform manylinux2014_x86_64 \
182+ --implementation cp \
183+ --python-version 3.12 \
184+ -r " $WEBAPP_DIR /requirements.txt"
185+ }
170186
171187 # Count installed packages
172188 PKG_COUNT=$( find " $WEBAPP_DIR " -maxdepth 1 -type d | wc -l | tr -d ' ' )
@@ -178,19 +194,30 @@ install_python_dependencies() {
178194 # Install layer dependencies
179195 local LAYER_DIR=" $SCRIPT_DIR /lambda/layers/dependencies"
180196 if [ -f " $LAYER_DIR /requirements.txt" ]; then
181- echo " Installing Lambda layer dependencies..."
197+ echo " Installing Lambda layer dependencies for Lambda (Linux x86_64) ..."
182198
183199 # Create python directory for layer
184200 mkdir -p " $LAYER_DIR /python"
185201
186202 # Clean up old packages
187203 rm -rf " $LAYER_DIR /python/" * 2> /dev/null || true
188204
189- # Install dependencies to python/ directory ( Lambda layer structure)
205+ # Install dependencies with Lambda-compatible platform
190206 python3 -m pip install \
191207 --quiet \
192208 --target " $LAYER_DIR /python" \
193- -r " $LAYER_DIR /requirements.txt"
209+ $PIP_PLATFORM_OPTS \
210+ -r " $LAYER_DIR /requirements.txt" 2> /dev/null || {
211+ # Fallback for pure Python packages
212+ print_warning " Some packages need source build, retrying..."
213+ python3 -m pip install \
214+ --quiet \
215+ --target " $LAYER_DIR /python" \
216+ --platform manylinux2014_x86_64 \
217+ --implementation cp \
218+ --python-version 3.12 \
219+ -r " $LAYER_DIR /requirements.txt"
220+ }
194221
195222 # Count installed packages
196223 PKG_COUNT=$( find " $LAYER_DIR /python" -maxdepth 1 -type d | wc -l | tr -d ' ' )
0 commit comments