22import shutil
33import sys
44from enum import Enum
5+ import sys
56
67import PyInstaller .__main__
7-
8- from modules .utils .SysUtils import SysType , SysUtils
9- from script .appDetails import APP_NAME
10-
8+ #///////////////不能改变导入顺序///////////////////////////////
119workPath = os .getcwd ()
1210workParentPath = os .path .dirname (workPath )
11+ # 将workParentPath也设置为工作目录
12+ sys .path .append (workParentPath )
13+ from script .appDetails import APP_NAME
14+ from modules .utils .SysUtils import SysType , SysUtils
15+ #//////////////////////////////////////////////
16+
17+
1318# 未打包路径
14- ffmpegExePath = "../ res/ffmpeg/ffmpeg.exe"
19+ ffmpegExePath = os . path . join ( workParentPath , " res/ffmpeg/ffmpeg.exe")
1520# 打包后的路径
1621ffmpegPackageDir = "./res/ffmpeg"
1722ffmpegPackageDirUpkg = "./res/ffmpeg/ffmpeg.exe"
1823pythonMainPath = os .path .join (workParentPath , 'main.py' )
1924outputDir = os .path .join (workPath , "dist" )
20- icoPath = workParentPath + '/ res/images/images/ml.ico'
25+ icoPath = os . path . join ( workParentPath , ' res/images/images/ml.ico')
2126
2227themesPath = os .path .join (workParentPath , 'themes' )
2328themesPackageDir = "./themes"
2833def beforePkgMac ():
2934 global ffmpegExePath
3035 global ffmpegPackageDirUpkg
31- ffmpegExePath = "../ res/ffmpeg/ffmpeg-mac"
36+ ffmpegExePath = os . path . join ( workParentPath , " res/ffmpeg/ffmpeg-mac")
3237 ffmpegPackageDirUpkg = "./res/ffmpeg/ffmpeg-mac"
3338
3439
3540def beforePkgLinux ():
3641 global ffmpegExePath
3742 global ffmpegPackageDirUpkg
38- ffmpegExePath = "../ res/ffmpeg/ffmpeg-linux"
43+ ffmpegExePath = os . path . join ( workParentPath , " res/ffmpeg/ffmpeg-linux")
3944 ffmpegPackageDirUpkg = "./res/ffmpeg/ffmpeg-linux"
4045
4146
@@ -52,10 +57,10 @@ def Ppkg(sysType):
5257 pythonMainPath , # 指定你的Python脚本文件
5358 '--add-data' , f'{ ffmpegExePath } ;{ ffmpegPackageDir } ' , # 将ffmpeg文件复制到指定目录
5459 '-n' , softName ,
60+ '--add-binary' , f'{ themesPath } ;{ themesPackageDir } ' ,
5561 # 前面的顺序不要动
56- # '--add-binary', f'{ffmpegExePath}; {ffmpegPackageDir}', # 将ffmpeg文件夹复制到指定目录
62+ # '--add-binary', f'{ffmpegExePath}: {ffmpegPackageDir}', # 将ffmpeg文件夹复制到指定目录
5763 # '--onefile', # 打包成一个单独的可执行文件
58- '--add-binary' , f'{ themesPath } ;{ themesPackageDir } ' ,
5964 '-i' , icoPath ,
6065 '--noconsole' , # 不显示控制台窗口
6166 '--clean' ,
@@ -64,8 +69,9 @@ def Ppkg(sysType):
6469 # 需要打包文件夹
6570 if sysType == SysType .LINUX :
6671 cmd [1 ] = "--add-binary"
67- cmd [2 ] = f'{ ffmpegExePath } ; { ffmpegPackageDirUpkg } '
72+ cmd [2 ] = f'{ ffmpegExePath } : { ffmpegPackageDirUpkg } '
6873 cmd [4 ] = APP_NAME
74+ cmd [6 ] = f'{ themesPath } :{ themesPackageDir } '
6975
7076 PyInstaller .__main__ .run (cmd )
7177
@@ -145,7 +151,6 @@ def chooseType(sysType, inType):
145151 print (
146152 f"请选择打包方式:\n { PkgType .PYINSTALLER_PKG .value } .PyInstaller\n { PkgType .NUITKA .value } .Nuitka\n { PkgType .NON .value } .什么也不做\n 请输入前面的序号:" )
147153 inType = int (input ())
148-
149154 # sysType = SysType.MAC
150155 # sysType = SysType.LINUX
151156 if inType == PkgType .NON .value :
0 commit comments