-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.py
More file actions
100 lines (74 loc) · 2.35 KB
/
install.py
File metadata and controls
100 lines (74 loc) · 2.35 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import sys
from typing import List
import distutils.sysconfig
from os import path
try:
import requests # type: ignore
except ModuleNotFoundError:
print('Please install requests package using: pip3 install requests')
exit(1)
BINARIES_PATH = 'https://github.com/somik861/hpc-datastore-cpp-pybind/blob/main/binaries/'
def url_join(*args) -> str:
final = ''
for url in args:
if not final.endswith('/') and final:
final += '/'
final += url
return final
def get_files_url() -> List[str]:
module_name = 'hpc_datastore'
suffix: str = distutils.sysconfig.get_config_var('EXT_SUFFIX')
file_name = module_name + suffix
url = url_join(BINARIES_PATH, sys.platform, file_name)
req = requests.get(url)
if (req.status_code == 404):
return []
out: List[str] = [url]
if sys.platform == 'win32':
for dll in [
'PocoFoundation.dll',
'PocoJSON.dll',
'PocoNet.dll',
'cbia.lib.i3dalgo.dyn.rel.x64.16.dll',
'cbia.lib.i3dcore.dyn.rel.x64.16.dll',
'fmt.dll',
'hdf5.dll',
'hdf5_hl.dll',
'jpeg62.dll',
'libics.dll',
'liblzma.dll',
'libpng16.dll',
'pcre.dll',
'rxspencer.dll',
'tiff.dll',
'zlib1.dll',
]:
out.append(url_join(BINARIES_PATH, sys.platform, 'dlls', dll))
return out
def download_files(urls: List[str], prefixes: List[str]) -> None:
for url in urls:
filename = url.split('/')[-1]
print(f"Downloading {filename} ... ", end='', flush=True)
full_url = url + '?raw=true'
req = requests.get(full_url)
if req.status_code != 200:
print("[Error]")
continue
for prefix in prefixes:
open(path.join(prefix, filename), 'wb').write(req.content)
print("[OK]")
def main():
urls = get_files_url()
if not urls:
print("Your system is not supported")
exit(1)
prefixes: list[str] = []
if len(sys.argv) == 1:
for syspath in sys.path:
if 'dynload' in syspath or 'DLLs' in syspath:
prefixes.append(syspath)
break
prefixes.extend(sys.argv[1:])
download_files(urls, prefixes)
if __name__ == '__main__':
main()