blob: 9411f3030d8339980f749af690fbad34b84d2b6d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import asyncio
import pathlib
import sys
import httpx
DOWNLOAD_URL = "https://bitbucket.org/vinay.sajip/simple_launcher/downloads/{}"
VENDOR_DIR = (
pathlib.Path(__file__)
.parent.parent.joinpath("src", "installer", "_scripts")
.resolve()
)
LAUNCHERS = [
"t32.exe",
"t64.exe",
"t_arm.exe",
"t64-arm.exe",
"w32.exe",
"w64.exe",
"w_arm.exe",
"w64-arm.exe",
]
async def _download(client: httpx.AsyncClient, name):
url = DOWNLOAD_URL.format(name)
print(f" Fetching {url}")
resp = await client.get(url)
data = await resp.aread()
VENDOR_DIR.joinpath(name).write_bytes(data)
async def main():
print(f"Downloading into {VENDOR_DIR} ...")
async with httpx.AsyncClient() as client:
await asyncio.gather(*(_download(client, name) for name in LAUNCHERS))
def _patch_windows_38():
# https://github.com/encode/httpx/issues/914
if sys.version_info >= (3, 8) and sys.platform.startswith("win"):
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
if __name__ == "__main__":
_patch_windows_38()
asyncio.run(main())
|