"""Run the stock fixed Mathlib cache client using native Windows Lean on drive E.""" import argparse,ctypes,json,os,subprocess from pathlib import Path def main(): p=argparse.ArgumentParser(description=__doc__);p.add_argument('--base',type=Path,required=True);p.add_argument('--report',type=Path,required=True);a=p.parse_args();base=a.base.resolve();source=base/'private-environment/original-source' bins=list((base/'private-environment/windows-toolchain').glob('*/bin/lean.exe')) if len(bins)!=1:raise ValueError('native compiler is not ready') leanbin=bins[0].parent version=subprocess.check_output([str(bins[0]),'--version'],text=True).strip() if '4.33.1' not in version or '819816b2' not in version:raise ValueError('incorrect native compiler') actual=subprocess.check_output(['git','-C',str(source/'.lake/packages/mathlib'),'rev-parse','HEAD'],text=True).strip() if actual!='0df444a360eaa60ab8c11dca51a86af692955474':raise ValueError('wrong Mathlib revision') env=os.environ.copy();env['PATH']=str(leanbin)+os.pathsep+env['PATH'] env['MATHLIB_CACHE_DIR']=str(base/'private-environment/mathlib-cache') env['MATHLIB_CACHE_GET_URL']='https://cache.mathlib.org/mathlib4';env['LAKE_ARTIFACT_CACHE']='false' env['LAKE_CACHE_DIR']=str(base/'private-environment/lake-cache');env['LEAN_ABORT_ON_PANIC']='1' env['GIT_CONFIG_COUNT']='3';env['GIT_CONFIG_KEY_0']='core.longpaths';env['GIT_CONFIG_VALUE_0']='true' env['GIT_CONFIG_KEY_1']='core.autocrlf';env['GIT_CONFIG_VALUE_1']='false';env['GIT_CONFIG_KEY_2']='credential.helper';env['GIT_CONFIG_VALUE_2']='';env['GIT_TERMINAL_PROMPT']='0' temp=base/'.shoal/tmp';temp.mkdir(exist_ok=True);env['TEMP']=str(temp);env['TMP']=str(temp) kernel=ctypes.WinDLL('kernel32',use_last_error=True);handle=kernel.GetCurrentProcess();allowed=ctypes.c_size_t();system=ctypes.c_size_t() if kernel.GetProcessAffinityMask(handle,ctypes.byref(allowed),ctypes.byref(system)): selected=[i for i in range(64) if allowed.value & (1<