@@ -38,9 +38,11 @@ def install():
38
38
call (install_cmd )
39
39
sys .exit (exit_code )
40
40
41
+
41
42
def in_venv ():
42
43
return sys .prefix != sys .base_prefix
43
44
45
+
44
46
def create_setup_file ():
45
47
with open ("setup.tmpl" , "r" , encoding = "utf-8" ) as tmpl :
46
48
tmpl_content = tmpl .read ()
@@ -98,8 +100,10 @@ def copy(src, dest):
98
100
99
101
usage = """
100
102
Usage: python build.py --[option]
103
+ Example: python build.py --test --install
101
104
102
105
Options:
106
+ --dist : creates the distributable.
103
107
--test : runs unit tests.
104
108
--install : installs python plugin and generates the pip package
105
109
"""
@@ -112,26 +116,31 @@ def run_tests() -> int:
112
116
all_python_test_files = glob .glob (f"{ ROOT_DIR } /tests/**/test_*.py" , recursive = True )
113
117
for i , file_name_path in enumerate (all_python_test_files ):
114
118
command = ["coverage" , "run" , file_name_path ]
115
- exit_code = call (command ) if exit_code == 0 else exit_code
119
+
120
+ exit_code = call (command )
121
+ if exit_code != 0 :
122
+ break
123
+
116
124
# Keep coverage files
117
125
os .rename (".coverage" , f".coverage.{ i } " )
126
+
118
127
call (["coverage" , "combine" ])
119
128
return exit_code
120
129
121
130
122
131
def main ():
123
- if len (sys .argv ) < 2 :
132
+ if len (sys .argv ) < 2 or '--help' in sys . argv :
124
133
print (usage )
125
134
else :
126
- if sys .argv [1 ] == '--dist' :
127
- create_zip ()
128
- generate_package ()
129
- else :
135
+ if '--test' in sys .argv :
130
136
exit_code = run_tests ()
131
137
if exit_code != 0 :
132
138
sys .exit (exit_code )
133
- elif sys .argv [1 ] == '--install' :
134
- install ()
139
+ if '--dist' in sys .argv :
140
+ create_zip ()
141
+ generate_package ()
142
+ if '--install' in sys .argv :
143
+ install ()
135
144
136
145
137
146
if __name__ == '__main__' :
0 commit comments