| | |
| | | import os |
| | | import shutil |
| | | from PyInstaller.utils.hooks import collect_all |
| | | import zipfile |
| | | import time |
| | | |
| | | a = Analysis( |
| | | ['tkv.py'], |
| | | ['video-splitor.py'], |
| | | pathex=[], |
| | | binaries=[], |
| | | datas=[], |
| | |
| | | |
| | | # 定义额外拷贝的文件 |
| | | path_ffmpeg = os.path.join(os.getcwd(), 'ffmpeg.exe') |
| | | path_thumb = os.path.join(os.getcwd(), 'mp4_generate_thumbnails.bat') |
| | | path_checkmark = os.path.join(os.getcwd(), 'checkmark.png') |
| | | path_libvlc = os.path.join(os.getcwd(), 'libvlc.dll') |
| | | path_libvlccore = os.path.join(os.getcwd(), 'libvlccore.dll') |
| | | |
| | | plugins_path = os.path.join(os.getcwd(), 'plugins') |
| | | path_vlc_plugins = os.path.join(os.getcwd(), 'VLC.zip') |
| | | |
| | | # 将 ffmpeg.exe 和 plugins 文件夹添加到 EXE 的同级目录 |
| | | datas = [ |
| | | (path_ffmpeg, '.'), |
| | | (path_thumb, '.'), |
| | | (path_checkmark, '.'), |
| | | (path_libvlc, '.'), |
| | | (path_libvlccore, '.'), |
| | | (plugins_path, 'plugins') |
| | | (path_checkmark, '.'), |
| | | (path_vlc_plugins, '.') |
| | | ] |
| | | |
| | | |
| | |
| | | # 获取生成的 dist 目录 |
| | | dist_dir = os.path.join(os.getcwd(), 'dist') |
| | | |
| | | # 递归拷贝 plugins 目录 |
| | | if os.path.exists(plugins_path): |
| | | destination_plugins = os.path.join(dist_dir, 'plugins') |
| | | shutil.copytree(plugins_path, destination_plugins) |
| | | |
| | | if os.path.exists(path_ffmpeg): |
| | | shutil.copy(path_ffmpeg, dist_dir) |
| | | |
| | | if os.path.exists(path_thumb): |
| | | shutil.copy(path_thumb, dist_dir) |
| | | |
| | | if os.path.exists(path_checkmark): |
| | | shutil.copy(path_checkmark, dist_dir) |
| | | |
| | | if os.path.exists(path_libvlc): |
| | | shutil.copy(path_libvlc, dist_dir) |
| | | |
| | | if os.path.exists(path_libvlccore): |
| | | shutil.copy(path_libvlccore, dist_dir) |
| | | |
| | | if os.path.exists(path_vlc_plugins): |
| | | copied_file_path = shutil.copy(path_vlc_plugins, dist_dir) |
| | | with zipfile.ZipFile(copied_file_path, 'r') as zip_ref: |
| | | zip_ref.extractall(dist_dir) |
| | | time.sleep(1) # 等待资源释放 |
| | | os.remove(copied_file_path) |
| | | |
| | | # 在打包后的应用中执行文件拷贝操作 |
| | | post_processing_hook(exe) |
| | | |
| | | |
| | | post_processing_hook(exe) |