-
Notifications
You must be signed in to change notification settings - Fork 16
/
install.py
51 lines (43 loc) · 1.72 KB
/
install.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
import os
import urllib.request
import configparser
import zipfile
# prepare progressbar
def show_progress(block_num, block_size, total_size):
print(round(block_num * block_size / total_size *100,2), end="\r")
platforms = ['ios', 'macos', 'linux', 'windows']
download_dir = 'downloads~'
def main():
config = configparser.ConfigParser()
config.read('version.ini')
version = config['ffi']['version']
for platform in platforms:
archs = ['arm64', 'x86_64']
if platform == 'android':
archs = [ 'armv7', 'arm64', 'x86_64']
elif platform == 'ios':
archs = ['arm64', 'sim-arm64']
for arch in archs:
filename = 'ffi-' + platform + '-' + arch + '.zip'
url = config['ffi']['url'] + '/ffi-' + version + '/' + filename
file_to_download = download_dir + '/' + filename
if download_file_if_not_exists(url, file_to_download) :
dest = 'Runtime/Plugins' + '/ffi-' + platform + '-' + arch
unzip_file(file_to_download, filename, dest)
def download_file_if_not_exists(url, filename):
if os.path.isdir(download_dir) == False:
print( download_dir + " directory not exists, creating one...")
os.makedirs(download_dir)
if os.path.isfile(filename):
print("file " + filename + " exists, skipping download")
return False
print("downloading file " + url)
urllib.request.urlretrieve(url, filename, show_progress)
return True
def unzip_file(srcfile, filename, dest):
print("unzipping " + filename + " to " + dest)
with zipfile.ZipFile(srcfile, 'r') as zip_ref:
zip_ref.extractall(dest)
print("unzipped " + srcfile)
if __name__ == "__main__":
main()