#!/usr/bin/env bash set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" log_dir="${SWIFT_VALIDATION_DIR:-$repo_root/validation-output}" mkdir -p "$log_dir" export SWIFT_VALIDATION_DIR="$log_dir" cd "$repo_root" python3 -m venv .venv .venv/bin/python -m pip install --upgrade pip .venv/bin/python -m pip install 'mlx[cpu]==0.32.2' 'transformers==5.14.1' 'huggingface_hub==1.31.0' 'safetensors==0.8.0' 'pytest==9.1.1' pillow sentencepiece protobuf .venv/bin/python -m pip install 'torch==2.11.0' 'torchvision==0.26.0' --index-url https://download.pytorch.org/whl/cpu if [ ! -d mlx-lm/.git ]; then git clone https://github.com/ml-explore/mlx-lm.git mlx-lm git -C mlx-lm checkout -b swift15-preserve-components c69d1288440a0dc4e6401fc417098b07598dccd5 fi if [ ! -f mlx-lm/mlx_lm/models/qwen3_5_full.py ]; then git -C mlx-lm apply --check "$repo_root/compatibility/swift15-mlx-lm.patch" git -C mlx-lm apply "$repo_root/compatibility/swift15-mlx-lm.patch" fi .venv/bin/python -m pip install --no-deps -e ./mlx-lm .venv/bin/python -m pip check .venv/bin/python -m pip freeze > "$log_dir/requirements-linux.txt" .venv/bin/python - <<'PY' import importlib.metadata as m,json,os,platform from pathlib import Path import mlx.core as mx mx.set_default_device(mx.cpu) x=mx.array([1,2,3]); mx.eval(x*x) r={'platform':platform.platform(),'python':platform.python_version(),'device':str(mx.default_device()),'cpu_test':(x*x).tolist(),'packages':{n:m.version(n) for n in ('mlx','mlx-cpu','mlx-lm','transformers','huggingface_hub','torch','torchvision','safetensors')}} Path(os.environ['SWIFT_VALIDATION_DIR'],'environment-linux.json').write_text(json.dumps(r,indent=2)+'\n') print(json.dumps(r,indent=2)) PY