@@ -350,23 +350,42 @@ def _install_dependencies(
350350 # Input: "PYTHON_3_10" or "python3.10" → Output: "3.10"
351351 python_version = runtime_version .upper ().replace ("PYTHON" , "" ).replace ("_" , "." ).strip ("_. " )
352352
353- cmd = self ._build_uv_command (requirements_file , target_dir , python_version , cross_compile )
354- log .info ("Installing dependencies with uv%s..." , " (cross-compiling for Linux ARM64)" if cross_compile else "" )
355-
356- try :
357- subprocess .run (cmd , check = True , capture_output = True , text = True ) # nosec B603 - using uv command
358- log .info ("✓ Dependencies installed with uv" )
359- except subprocess .CalledProcessError as e :
360- raise RuntimeError (f"Failed to install dependencies with uv: { e .stderr } " ) from e
361-
362- def _build_uv_command (self , requirements : Path , target : Path , py_version : str , cross : bool ) -> List [str ]:
353+ if cross_compile :
354+ # Try multiple platforms in order of preference for better compatibility
355+ platforms = ["aarch64-manylinux2014" , "aarch64-manylinux_2_17" , "aarch64-manylinux_2_28" ]
356+
357+ for i , platform in enumerate (platforms ):
358+ cmd = self ._build_uv_command (requirements_file , target_dir , python_version , platform )
359+ log .info ("Installing dependencies with uv for %s%s..." , platform ,
360+ " (cross-compiling for Linux ARM64)" if i == 0 else "" )
361+
362+ try :
363+ subprocess .run (cmd , check = True , capture_output = True , text = True ) # nosec B603 - using uv command
364+ if i == 0 :
365+ log .info ("✓ Dependencies installed with uv" )
366+ except subprocess .CalledProcessError as e :
367+ if i == len (platforms ) - 1 : # Last platform failed
368+ raise RuntimeError (f"Failed to install dependencies with uv: { e .stderr } " ) from e
369+ # Try next platform
370+ continue
371+ else :
372+ cmd = self ._build_uv_command (requirements_file , target_dir , python_version , None )
373+ log .info ("Installing dependencies with uv..." )
374+
375+ try :
376+ subprocess .run (cmd , check = True , capture_output = True , text = True ) # nosec B603 - using uv command
377+ log .info ("✓ Dependencies installed with uv" )
378+ except subprocess .CalledProcessError as e :
379+ raise RuntimeError (f"Failed to install dependencies with uv: { e .stderr } " ) from e
380+
381+ def _build_uv_command (self , requirements : Path , target : Path , py_version : str , platform : Optional [str ]) -> List [str ]:
363382 """Build uv pip install command.
364383
365384 Args:
366385 requirements: Path to requirements.txt
367386 target: Target directory
368387 py_version: Python version (e.g., "3.10")
369- cross: Whether to cross-compile
388+ platform: Platform string (e.g., "aarch64-manylinux2014") or None for native
370389
371390 Returns:
372391 Command as list of strings
@@ -381,13 +400,12 @@ def _build_uv_command(self, requirements: Path, target: Path, py_version: str, c
381400 py_version ,
382401 ]
383402
384- # Always use aarch64-manylinux2014 for AgentCore Runtime (ARM64)
385- # Note: uv uses --python-platform (not --platform like pip)
386- if cross :
403+ # Add platform-specific options for cross-compilation
404+ if platform :
387405 cmd .extend (
388406 [
389407 "--python-platform" ,
390- "aarch64-manylinux2014" ,
408+ platform ,
391409 "--only-binary" ,
392410 ":all:" ,
393411 ]
0 commit comments