-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
69 lines (58 loc) · 2.06 KB
/
setup.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
68
69
import subprocess
import sys
from glob import glob
from os.path import isdir, isfile, join
def gather(modules, module_type):
"""
`gather` function to clone repositories from a file.
:param modules: TextIO
:param module_type: string
"""
for repository in [repository for repository in modules.readlines() if repository.strip()]:
repository = repository.strip()
destination = f"{module_type}/{repository.split('/')[-1].split('.')[0]}"
try:
subprocess.check_call(
[
"git",
"clone",
repository,
destination
]
)
except subprocess.CalledProcessError:
print(f'{repository} already exists. Skipping...')
def install(requirements):
"""
`install` function to install requirements from a file.
:param requirements: TextIO
"""
for package in [package for package in requirements.readlines() if package.strip()]:
if package.startswith('#'):
continue
package = package.strip()
subprocess.check_call(
[
sys.executable,
"-m",
"pip",
"install",
package
]
)
if __name__ == '__main__':
args = sys.argv[1:]
module_types = ['ai', 'input', 'plugins']
if 'gather' in args:
for module_type in module_types:
with open(join(module_type, 'modules.txt')) as modules_file:
gather(modules_file, module_type)
if 'install' in args:
# Install requirements for Sierra
with open('requirements.txt') as requirements_file:
install(requirements_file)
for module_type in module_types:
for module_glob in glob(join(module_type, '*')):
if isdir(module_glob) and isfile(join(module_glob, 'requirements.txt')):
with open(join(module_glob, 'requirements.txt')) as requirements_file:
install(requirements_file)