Skip to content

Commit 25880e4

Browse files
authored
Decouple build steps to be more flexible (#446)
Signed-off-by: sschulz92 <[email protected]>
1 parent f935436 commit 25880e4

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

build.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ def install():
3838
call(install_cmd)
3939
sys.exit(exit_code)
4040

41+
4142
def in_venv():
4243
return sys.prefix != sys.base_prefix
4344

45+
4446
def create_setup_file():
4547
with open("setup.tmpl", "r", encoding="utf-8") as tmpl:
4648
tmpl_content = tmpl.read()
@@ -98,8 +100,10 @@ def copy(src, dest):
98100

99101
usage = """
100102
Usage: python build.py --[option]
103+
Example: python build.py --test --install
101104
102105
Options:
106+
--dist : creates the distributable.
103107
--test : runs unit tests.
104108
--install : installs python plugin and generates the pip package
105109
"""
@@ -112,26 +116,31 @@ def run_tests() -> int:
112116
all_python_test_files = glob.glob(f"{ROOT_DIR}/tests/**/test_*.py", recursive=True)
113117
for i, file_name_path in enumerate(all_python_test_files):
114118
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+
116124
# Keep coverage files
117125
os.rename(".coverage", f".coverage.{i}")
126+
118127
call(["coverage", "combine"])
119128
return exit_code
120129

121130

122131
def main():
123-
if len(sys.argv) < 2:
132+
if len(sys.argv) < 2 or '--help' in sys.argv:
124133
print(usage)
125134
else:
126-
if sys.argv[1] == '--dist':
127-
create_zip()
128-
generate_package()
129-
else:
135+
if '--test' in sys.argv:
130136
exit_code = run_tests()
131137
if exit_code != 0:
132138
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()
135144

136145

137146
if __name__ == '__main__':

0 commit comments

Comments
 (0)