-
Notifications
You must be signed in to change notification settings - Fork 4
/
fxnc.py
67 lines (61 loc) · 2.2 KB
/
fxnc.py
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#
# Function
# Copyright © 2024 NatML Inc. All Rights Reserved.
#
from argparse import ArgumentParser
from pathlib import Path
from requests import get
from shutil import unpack_archive
parser = ArgumentParser()
parser.add_argument("--version", type=str, default=None)
def _download_fxnc (url: str, path: Path):
# Download
response = get(url)
response.raise_for_status()
with open(path, "wb") as f:
f.write(response.content)
print(f"Wrote {url} to path: {path}")
# Unzip
if path.suffix == ".zip":
unpack_archive(path, extract_dir=path.parent)
path.unlink()
print(f"Extracted {path}")
def _get_latest_version () -> str:
response = get(f"https://api.github.com/repos/fxnai/fxnc/releases/latest")
response.raise_for_status()
release = response.json()
return release["tag_name"]
def main (): # CHECK # Linux # Android AAR
args = parser.parse_args()
version = args.version if args.version else _get_latest_version()
LIB_PATH_BASE = Path("Packages") / "ai.fxn.fxn3d" / "Plugins"
LIBS = [
{
"url": f"https://cdn.fxn.ai/fxnc/{version}/Function-ios-iphoneos.framework.zip",
"path": LIB_PATH_BASE / "iOS" / "Function.framework.zip"
},
{
"url": f"https://cdn.fxn.ai/fxnc/{version}/Function-macos.dylib",
"path": LIB_PATH_BASE / "macOS" / "Function.dylib"
},
{
"url": f"https://cdn.fxn.ai/fxnc/{version}/libFunction-linux-arm64.so",
"path": LIB_PATH_BASE / "Linux" / "arm64" / "libFunction.so"
},
{
"url": f"https://cdn.fxn.ai/fxnc/{version}/libFunction-linux-x86_64.so",
"path": LIB_PATH_BASE / "Linux" / "x86_64" / "libFunction.so"
},
{
"url": f"https://cdn.fxn.ai/fxnc/{version}/Function-win-x86_64.dll",
"path": LIB_PATH_BASE / "Windows" / "x86_64" / "Function.dll"
},
{
"url": f"https://cdn.fxn.ai/fxnc/{version}/Function-win-arm64.dll",
"path": LIB_PATH_BASE / "Windows" / "arm64" / "Function.dll"
},
]
for lib in LIBS:
_download_fxnc(lib["url"], lib["path"])
if __name__ == "__main__":
main()