2023-10-23 06:02:34 +08:00
|
|
|
import glob
|
|
|
|
import py_compile as pyc
|
|
|
|
|
2023-10-23 16:06:33 +08:00
|
|
|
if __name__ == "__main__":
|
|
|
|
# find source code files
|
|
|
|
src_paths = sorted(glob.glob("codes/python/**/*.py"))
|
|
|
|
num_src = len(src_paths)
|
|
|
|
num_src_error = 0
|
2023-10-23 06:02:34 +08:00
|
|
|
|
2023-10-23 16:06:33 +08:00
|
|
|
# compile python code
|
|
|
|
for src_path in src_paths:
|
|
|
|
try:
|
|
|
|
pyc.compile(src_path, doraise=True)
|
|
|
|
except pyc.PyCompileError as e:
|
|
|
|
num_src_error += 1
|
|
|
|
print(e)
|
2023-10-23 06:02:34 +08:00
|
|
|
|
2023-10-23 16:06:33 +08:00
|
|
|
print(f"===== Build Complete =====")
|
|
|
|
print(f"Total: {num_src}")
|
|
|
|
print(f"Error: {num_src_error}")
|