29ca3332 by 周伟奇

add copy !.py file to build dir

1 parent 7f3fea26
......@@ -48,6 +48,32 @@ def get_py_files(dir_path, exclude_paths):
yield file_path
def is_about_py(filename):
if filename.endswith('.py') or filename.endswith('.pyc') or filename.endswith('.pyo') or filename.endswith('.pyd'):
return True
return False
def copy_other_files(input_path, exclude_paths, output_path):
if not os.path.isdir(input_path):
return
for parent, _, filenames in os.walk(input_path):
if parent in exclude_paths:
relpath = os.path.relpath(parent, input_path)
target_dir = os.path.join(output_path, relpath)
shutil.copytree(parent, target_dir)
print('copy {0} to {1}'.format(parent, target_dir))
continue
for filename in filenames:
file_path = os.path.join(parent, filename)
if file_path in exclude_paths or not is_about_py(filename):
relpath = os.path.relpath(file_path, input_path)
target_path = os.path.join(output_path, relpath)
os.makedirs(os.path.dirname(target_path), exist_ok=True)
shutil.copy(file_path, target_path)
print('copy {0} to {1}'.format(file_path, target_path))
def del_c(dir_path, timestamp):
if not os.path.isdir(dir_path):
c_file_path = '{0}.c'.format(os.path.splitext(dir_path)[0])
......@@ -110,6 +136,7 @@ def main():
extensions = get_extensions(file_paths, input_path)
print('---------- compile start ----------')
success = False
try:
compiler_directives = {"language_level": '3'}
ext_modules = cythonize(module_list=extensions,
......@@ -123,6 +150,7 @@ def main():
else:
print('---------- compile completed ----------')
print('output path: {0}'.format(output_path))
success = True
finally:
print('---------- cleaning ----------')
if os.path.exists(tmp_path):
......@@ -130,6 +158,10 @@ def main():
print('remove output tmp path: {0}'.format(tmp_path))
del_c(input_path, timestamp)
if success:
print('---------- copy !.py file to {0} ----------'.format(build_dir_name))
copy_other_files(input_path, exclude_paths, output_path)
if __name__ == '__main__':
main()
......
File mode changed
File mode changed
File mode changed
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!