wangzhibo
2024-12-04 d87753061d40595bfb1d5b296cc777e1094f3ccf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# -*- mode: python ; coding: utf-8 -*-
 
import os
import shutil
from PyInstaller.utils.hooks import collect_all
 
a = Analysis(
    ['tkv.py'],
    pathex=[],
    binaries=[],
    datas=[],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
    optimize=0,
)
pyz = PYZ(a.pure)
 
exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.datas,
    [],
    name='videosplitorV0.1',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    icon=['main.ico'],
)
 
# 定义额外拷贝的文件
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')
 
# 将 ffmpeg.exe 和 plugins 文件夹添加到 EXE 的同级目录
datas = [
    (path_ffmpeg, '.'), 
    (path_thumb, '.'),  
    (path_checkmark, '.'),  
    (path_libvlc, '.'),  
    (path_libvlccore, '.'),  
    (plugins_path, 'plugins') 
]
 
 
 
# 将额外的文件拷贝到目标目录
def post_processing_hook(app):
    # 获取生成的 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)
 
# 在打包后的应用中执行文件拷贝操作
post_processing_hook(exe)