-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
65 lines (54 loc) · 2.28 KB
/
build.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
from build_cfg.Utils.print_tree import res_print
from build_cfg.Utils.check import check_cython, check_setuptools
from build_cfg.Utils.load import load_cfg
from build_cfg.Utils.build import build
from build_cfg.Utils.test import run_tests
import copy
import traceback
import argparse
### RUN THIS SCRIPT FROM ROOT.OPTIMIZED FOLDER ###
def parse():
parser = argparse.ArgumentParser()
parser.add_argument('--modules', '-m', nargs='+', required=False, default='default')
args = parser.parse_args()
return args
def main():
"""
This function is the main entry point of the program. It performs the following steps:
1. Loads the configuration from the file using the `load_cfg()` function.
2. Retrieves the settings from the loaded configuration.
3. Retrieves the modules from the loaded configuration.
4. Checks the installation of Cython using the `check_cython()` function. Checks the installation of setuptools using the `check_setuptools()` function.
5. Builds the modules using the `build()` function.
6. Runs the tests using the `run_tests()` function.
7. Prints the result using the `res_print()` function.
"""
args = parse()
cfg = load_cfg() # load config
settings = cfg['settings'] # get settings
if args.modules == 'default' or args.modules[0] == 'all':
modules = cfg['modules'] # get modules
else:
modules = {}
for module in args.modules:
m, s = module.split('.', 1)
if m not in modules:
modules[m] = []
modules[m].append(s)
try:
check_cython(settings) # check cython installation
check_setuptools(settings)
libs, failed = build(modules, settings) # build modules
test_libs = copy.copy(libs)
for lib in libs:
if lib in failed.keys():
print(f"\n🔴 {lib} build failed, cant run {lib}.TEST.test | SKIPPED.")
test_libs.remove(lib) # remove failed libs from test
run_tests(settings, test_libs) # run tests
res_print(settings, modules, libs, failed) # print result
except Exception as e:
print("Error: " + str(e))
if settings['traceback']:
traceback.print_exc()
if __name__ == '__main__':
main() # run main