add copy !.py file to build dir
Showing
5 changed files
with
32 additions
and
0 deletions
... | @@ -48,6 +48,32 @@ def get_py_files(dir_path, exclude_paths): | ... | @@ -48,6 +48,32 @@ def get_py_files(dir_path, exclude_paths): |
48 | yield file_path | 48 | yield file_path |
49 | 49 | ||
50 | 50 | ||
51 | def is_about_py(filename): | ||
52 | if filename.endswith('.py') or filename.endswith('.pyc') or filename.endswith('.pyo') or filename.endswith('.pyd'): | ||
53 | return True | ||
54 | return False | ||
55 | |||
56 | |||
57 | def copy_other_files(input_path, exclude_paths, output_path): | ||
58 | if not os.path.isdir(input_path): | ||
59 | return | ||
60 | for parent, _, filenames in os.walk(input_path): | ||
61 | if parent in exclude_paths: | ||
62 | relpath = os.path.relpath(parent, input_path) | ||
63 | target_dir = os.path.join(output_path, relpath) | ||
64 | shutil.copytree(parent, target_dir) | ||
65 | print('copy {0} to {1}'.format(parent, target_dir)) | ||
66 | continue | ||
67 | for filename in filenames: | ||
68 | file_path = os.path.join(parent, filename) | ||
69 | if file_path in exclude_paths or not is_about_py(filename): | ||
70 | relpath = os.path.relpath(file_path, input_path) | ||
71 | target_path = os.path.join(output_path, relpath) | ||
72 | os.makedirs(os.path.dirname(target_path), exist_ok=True) | ||
73 | shutil.copy(file_path, target_path) | ||
74 | print('copy {0} to {1}'.format(file_path, target_path)) | ||
75 | |||
76 | |||
51 | def del_c(dir_path, timestamp): | 77 | def del_c(dir_path, timestamp): |
52 | if not os.path.isdir(dir_path): | 78 | if not os.path.isdir(dir_path): |
53 | c_file_path = '{0}.c'.format(os.path.splitext(dir_path)[0]) | 79 | c_file_path = '{0}.c'.format(os.path.splitext(dir_path)[0]) |
... | @@ -110,6 +136,7 @@ def main(): | ... | @@ -110,6 +136,7 @@ def main(): |
110 | extensions = get_extensions(file_paths, input_path) | 136 | extensions = get_extensions(file_paths, input_path) |
111 | 137 | ||
112 | print('---------- compile start ----------') | 138 | print('---------- compile start ----------') |
139 | success = False | ||
113 | try: | 140 | try: |
114 | compiler_directives = {"language_level": '3'} | 141 | compiler_directives = {"language_level": '3'} |
115 | ext_modules = cythonize(module_list=extensions, | 142 | ext_modules = cythonize(module_list=extensions, |
... | @@ -123,6 +150,7 @@ def main(): | ... | @@ -123,6 +150,7 @@ def main(): |
123 | else: | 150 | else: |
124 | print('---------- compile completed ----------') | 151 | print('---------- compile completed ----------') |
125 | print('output path: {0}'.format(output_path)) | 152 | print('output path: {0}'.format(output_path)) |
153 | success = True | ||
126 | finally: | 154 | finally: |
127 | print('---------- cleaning ----------') | 155 | print('---------- cleaning ----------') |
128 | if os.path.exists(tmp_path): | 156 | if os.path.exists(tmp_path): |
... | @@ -130,6 +158,10 @@ def main(): | ... | @@ -130,6 +158,10 @@ def main(): |
130 | print('remove output tmp path: {0}'.format(tmp_path)) | 158 | print('remove output tmp path: {0}'.format(tmp_path)) |
131 | del_c(input_path, timestamp) | 159 | del_c(input_path, timestamp) |
132 | 160 | ||
161 | if success: | ||
162 | print('---------- copy !.py file to {0} ----------'.format(build_dir_name)) | ||
163 | copy_other_files(input_path, exclude_paths, output_path) | ||
164 | |||
133 | 165 | ||
134 | if __name__ == '__main__': | 166 | if __name__ == '__main__': |
135 | main() | 167 | main() | ... | ... |
test/model/test.md
0 → 100644
File mode changed
test/model/test/index.html
0 → 100644
File mode changed
test/test.md
0 → 100644
File mode changed
test/test/main/main.py
0 → 100644
File mode changed
-
Please register or sign in to post a comment