microproduct/landcover_s_geo_sar/pyinstallerMain.py

64 lines
1.8 KiB
Python
Raw Normal View History

2023-08-28 10:17:29 +00:00
import glob
import os
import shutil
from tool.file.fileHandle import fileHandle
file =fileHandle()
cwdpath = os.getcwd()
EXE_NAME = 'LandCover'
Polar_Mode = 'S-GEO-SAR'
Version = 'V2.1.1'
File_NAME = EXE_NAME + '-' +Polar_Mode + '-' + Version
OUT_PATH = r'I:\MicroWorkspace\exe_file/' + File_NAME
base_list = ['model_meta.xml',
'config.ini',
EXE_NAME + '.xml',
'版本更新说明.txt']
exe_list = ['freeman_decomposition_T3.exe',
'h_a_alpha_decomposition_T3.exe',
'h_a_alpha_eigenvalue_set_T3.exe',
'h_a_alpha_eigenvector_set_T3.exe',
'lee_refined_filter_T3.exe',
'yamaguchi_4components_decomposition_T3.exe']
dependence_list = base_list
def del_dump():
#删除多余文件夹
file.del_folder(cwdpath +'/dist')
file.del_folder(cwdpath +'/build')
file.del_folder(cwdpath +'/tool')
# file.del_folder(cwdpath +'/run_log')
if os.path.exists(cwdpath +'/tool.tar.gz'):
os.remove(cwdpath +'/tool.tar.gz')
def get_dll_list():
src_dir = '../exe_denpendence/dll'
return list(glob.glob(os.path.join(src_dir, '*.*')))
if __name__ == '__main__':
del_dump()
# 执行打包脚本
cmd = 'pyinstaller -D pyinstaller.spec'
result = os.system(cmd)
print("result:" + str(result))
if result == 0:
# 拷贝依赖库
dst_dir = './dist/' # 目的路径记得加斜杠
dll_list = get_dll_list()
file_list = dll_list + dependence_list
for srcfile in file_list:
file.copyfile2dir(srcfile, dst_dir)
#移动到指定目录下
shutil.move('./dist', OUT_PATH)
os.startfile(OUT_PATH)
#拷贝文件到指定文件夹
del_dump()
print("完成打包!")