Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ def install():
call(install_cmd)
sys.exit(exit_code)


def in_venv():
return sys.prefix != sys.base_prefix


def create_setup_file():
with open("setup.tmpl", "r", encoding="utf-8") as tmpl:
tmpl_content = tmpl.read()
Expand Down Expand Up @@ -98,8 +100,10 @@ def copy(src, dest):

usage = """
Usage: python build.py --[option]
Example: python build.py --test --install

Options:
--dist : creates the distributable.
--test : runs unit tests.
--install : installs python plugin and generates the pip package
"""
Expand All @@ -112,26 +116,31 @@ def run_tests() -> int:
all_python_test_files = glob.glob(f"{ROOT_DIR}/tests/**/test_*.py", recursive=True)
for i, file_name_path in enumerate(all_python_test_files):
command = ["coverage", "run", file_name_path]
exit_code = call(command) if exit_code == 0 else exit_code

exit_code = call(command)
if exit_code != 0:
break

# Keep coverage files
os.rename(".coverage", f".coverage.{i}")

call(["coverage", "combine"])
return exit_code


def main():
if len(sys.argv) < 2:
if len(sys.argv) < 2 or '--help' in sys.argv:
print(usage)
else:
if sys.argv[1] == '--dist':
create_zip()
generate_package()
else:
if '--test' in sys.argv:
exit_code = run_tests()
if exit_code != 0:
sys.exit(exit_code)
elif sys.argv[1] == '--install':
install()
if '--dist' in sys.argv:
create_zip()
generate_package()
if '--install' in sys.argv:
install()


if __name__ == '__main__':
Expand Down
Loading