"""Explicit local compilation; downloaded repositories never execute code on loading.""" from pathlib import Path import os,subprocess,sys,shutil root=Path(__file__).resolve().parents[1] compiler=os.environ.get('CC') or shutil.which('cc') or shutil.which('gcc') if not compiler:raise SystemExit('No C compiler found. The Python reference remains usable.') out=root/'phillnet_recall/native';out.mkdir(exist_ok=True) name='ugr.dll' if os.name=='nt' else 'libugr.dylib' if sys.platform=='darwin' else 'libugr.so' flags=['-std=c99','-O3','-ffp-contract=off','-fno-fast-math','-shared'] if os.name!='nt':flags+=['-fPIC'] cmd=[compiler,*flags,str(root/'native/ugr.c'),'-o',str(out/name),'-lm'] subprocess.run(cmd,check=True) print(out/name)