"""Install an isolated, reproducible Windows Android build toolchain.""" import concurrent.futures, pathlib, urllib.request, zipfile ROOT = pathlib.Path(__file__).resolve().parents[1] TOOLS = ROOT / '.tools' TOOLS.mkdir(exist_ok=True) def install(name, url, destination, marker): if (TOOLS / marker).exists(): return archive = TOOLS / (name + '.zip') if not archive.exists(): print('Downloading ' + name, flush=True) urllib.request.urlretrieve(url, archive) with zipfile.ZipFile(archive) as z: z.extractall(TOOLS / destination) print('Installed ' + name, flush=True) jobs = [ ('jdk','https://cdn.azul.com/zulu/bin/zulu17.68.203-ca-crac-jdk17.0.20.1-win_x64.zip','jdk','jdk/zulu17.68.203-ca-crac-jdk17.0.20.1-win_x64/bin/java.exe'), ('gradle','https://services.gradle.org/distributions/gradle-8.13-bin.zip','','gradle-8.13/bin/gradle.bat'), ('commandline','https://dl.google.com/android/repository/commandlinetools-win-13114758_latest.zip','sdk/cmdline-tools','sdk/cmdline-tools/latest/bin/sdkmanager.bat')] with concurrent.futures.ThreadPoolExecutor(max_workers=3) as pool: list(pool.map(lambda args: install(*args),jobs)) p = TOOLS / 'sdk/cmdline-tools/cmdline-tools' if p.exists(): p.rename(p.with_name('latest')) print('Tool downloads complete', flush=True)