Silin-Chen's picture
CrossSWE-Bench: current 171-instance release
0e239c6
Raw History Blame Contribute Delete
1.24 kB
import base64,hashlib,json,pathlib,subprocess,sys,zipfile,io,importlib.metadata
B=pathlib.Path('/crossrepo-patches')
if sys.argv[1]=='setup':
expected=json.loads((B/'runtime-wheels.json').read_text());blob=base64.b64decode((B/'runtime-wheels.zip.b64').read_text());assert hashlib.sha256(blob).hexdigest()==expected['bundle_sha256']
target=pathlib.Path('/tmp/crossrepo-anyvalue-wheels');target.mkdir(exist_ok=True);paths=[]
with zipfile.ZipFile(io.BytesIO(blob)) as z:
assert set(z.namelist())=={x['name'] for x in expected['wheels']}
for item in expected['wheels']:
data=z.read(item['name']);assert hashlib.sha256(data).hexdigest()==item['sha256'];p=target/item['name'];p.write_bytes(data);paths.append(str(p))
subprocess.run([sys.executable,'-m','pip','install','--no-index','--no-deps',*paths],check=True)
print('CROSSREPO_OFFLINE_DEPENDENCIES '+json.dumps({'bundle_sha256':expected['bundle_sha256'],'installed':{name:importlib.metadata.version(name) for name in ['packaging','protobuf','wrapt','typing_extensions']},'otel_implementation':'paired local source imports, no registry OpenTelemetry wheel'}),flush=True)
else:
raise SystemExit(subprocess.run([sys.executable,str(B/'anyvalue_tests.py'),sys.argv[1]]).returncode)