55import platform
66import argparse
77from pathlib import Path
8- from zip import zip_files_and_folders
8+ # from zip import zip_files_and_folders
99
1010def main ():
1111 print ("=" * 50 )
@@ -53,7 +53,7 @@ def main():
5353 dist_path = base_dir / task ['distpath' ]
5454 requirements = task .get ('install-requirements' , [])
5555 use_upx = task .get ('upx' , False )
56- onefile = task .get ('onefile' , 0 )
56+ # onefile = task.get('onefile', 0)
5757 icon = task .get ('icon' )
5858 windowed = task .get ('windowed' , False )
5959 name = task .get ('name' )
@@ -89,7 +89,8 @@ def main():
8989 '--specpath' , str (base_dir / 'build' ),
9090 '--workpath' , str (base_dir / 'build' / 'temp' ),
9191 '--noconfirm' ,
92- '--clean'
92+ '--clean' ,
93+ '--onefile'
9394 ]
9495
9596 # 添加窗口模式选项
@@ -118,47 +119,30 @@ def main():
118119 print ("不使用UPX压缩" )
119120
120121 # 添加单文件打包选项
121- if onefile == 0 :
122- pass
123- elif onefile == 1 :
124- cmd .append ('--onefile' )
125- elif onefile == 2 :
126- cmd .append ('--onefile' )
127- bcmd = cmd
122+ # if onefile == 0:
123+ # pass
124+ # elif onefile == 1:
125+ # cmd.append('--onefile')
126+ # elif onefile == 2:
127+ # cmd.append('--onefile')
128+ # bcmd = cmd
128129
129130 # 添加主Python文件
130131 cmd .append (str (python_file ))
131132
132133 # 打印并执行命令
133134 print ("执行命令:" , ' ' .join (cmd ))
134- result1 = subprocess .run (cmd )
135+ result = subprocess .run (cmd )
135136
136- if onefile == 2 :
137- cmd .append (str (python_file ))
138- result2 = subprocess .run (bcmd )
137+ # if onefile == 2:
138+ # cmd.append(str(python_file))
139+ # result2 = subprocess.run(bcmd)
139140
140- if result1 .returncode == 0 :
141+ if result .returncode == 0 :
141142 print (f"(onefile)打包成功: { dist_path / output_name } " )
142143 success_count += 1
143144 else :
144- print (f"(onefile)打包失败,退出码: { result1 .returncode } " )
145-
146- if result2 .returncode == 0 :
147- print (f"(onedir)打包成功: { dist_path / output_name } " )
148- zip_files_and_folders (None , dist_path / output_name , str (dist_path / output_name )+ '.zip' )
149- success_count += 1
150- else :
151- print (f"(onefdir)打包失败,退出码: { result2 .returncode } " )
152-
153- if onefile == 0 :
154- if result1 .returncode == 0 :
155- success_count += 1
156- elif onefile == 1 :
157- if result2 .returncode == 0 :
158- success_count += 1
159- elif onefile == 2 :
160- if result2 .returncode == 0 and result1 .returncode == 0 :
161- success_count += 1
145+ print (f"(onefile)打包失败,退出码: { result .returncode } " )
162146 except Exception as e :
163147 print (f"任务[{ i } /{ len (config )} { task ['name' ]} ]失败: { e } " )
164148 task_error_list .append (task ['name' ])
@@ -170,7 +154,7 @@ def main():
170154 else :
171155 print ("打包失败,没有成功打包任何任务" )
172156 print (f"失败的任务: { ', ' .join (task_error_list )} " )
173- sys .exit (1 )
157+ sys .exit (0 )
174158
175159if __name__ == '__main__' :
176160 main ()
0 commit comments