| from __future__ import annotations | |
| import subprocess,sys | |
| def ensure_anigen_abi(verbose=True): | |
| """Repair the known NumPy/SciPy/sklearn ABI mismatch in the upstream AniGen image. | |
| The pinned trio is the combination already validated with Torch 2.8/CUDA 12.8 on L4. | |
| """ | |
| try: | |
| import numpy as np, torch | |
| _=torch.from_numpy(np.zeros((1,),dtype=np.float32)) | |
| import scipy,sklearn | |
| return {'repaired':False,'numpy':np.__version__,'scipy':scipy.__version__,'sklearn':sklearn.__version__} | |
| except Exception as exc: | |
| if verbose: print(f'[companion-v7] repairing AniGen ABI: {exc}',flush=True) | |
| subprocess.check_call([sys.executable,'-m','pip','install','-q','--force-reinstall','--no-cache-dir','numpy==2.1.3','scipy==1.14.1','scikit-learn==1.6.1']) | |
| # The current process may have imported incompatible extension modules. Restart is safest. | |
| return {'repaired':True,'restart_required':True} | |