python复杂项目打包

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
92
93
94
95
96
97
98
1、安装pipinstaller
     ==>pip install pyinstaller
     or ==> python -m pip install pyinstaller
 
2、新建 .spec文件
1)进入入口文件所在目录
2)pyi-makespec xx.py
 
3、修改文件:
1)递归遍历所有的项目py文件和常量
 
    py_file_list = []
    other_file_list = []
 
    def getallfilesofwalk(dir):
        """使用listdir循环遍历"""
        if not os.path.isdir(dir):
            # print(dir)
            return
        dirlist = os.walk(dir)
        for root, dirs, files in dirlist:
            for file in files:
                this_f = os.path.join(root, file)
                # print(this_f)
                if file.endswith(".py"):
                    py_file_list.append(this_f)
                elif re.findall("\.xml|\.json|\.dll|\.ini|\.h", str(file)) and not re.findall("result|source|\.idea", str(file)):
                    fn, this_d_ = get_filename_and_dir(this_f)
                    # filename, this_d = get_filename_and_dir(this_d_)
                    # f_item = (his_d, filentame)
                    # if (this_d, filename) in other_file_list:
                    #     continue
 
                    if this_d_ not in other_file_list:
                        other_file_list.append(this_d_)
                else:
                    pass
 
2)修改 xx.spec
# -*- mode: python -*-
import sys
import os.path as osp
sys.setrecursionlimit(5000)
  
block_cipher = None
  
  
SETUP_DIR = 'D:\\install_test\\FASTPLOT\\'
  
a = Analysis(['fastplot.py',
'frozen_dir.py',
'D:\\install_test\\FASTPLOT\\lib\\app\\start.py',
'D:\\install_test\\FASTPLOT\\lib\\models\\analysis_model.py',
'D:\\install_test\\FASTPLOT\\lib\\models\\datafile_model.py',
'D:\\install_test\\FASTPLOT\\lib\\models\\data_model.py',
'D:\\install_test\\FASTPLOT\\lib\\models\\figure_model.py',
'D:\\install_test\\FASTPLOT\\lib\\models\\time_model.py',
'D:\\install_test\\FASTPLOT\\lib\\models\\mathematics_model.py',
'D:\\install_test\\FASTPLOT\\lib\\views\\constant.py',
'D:\\install_test\\FASTPLOT\\lib\\views\\custom_dialog.py',
'D:\\install_test\\FASTPLOT\\lib\\views\\data_dict_window.py',
'D:\\install_test\\FASTPLOT\\lib\\views\\data_process_window.py',
'D:\\install_test\\FASTPLOT\\lib\\views\\data_sift_window.py',
'D:\\install_test\\FASTPLOT\\lib\\views\\mathematics_window.py',
'D:\\install_test\\FASTPLOT\\lib\\views\\para_temp_window.py',
'D:\\install_test\\FASTPLOT\\lib\\views\\mainwindow.py',
'D:\\install_test\\FASTPLOT\\lib\\views\\paralist_window.py',
'D:\\install_test\\FASTPLOT\\lib\\views\\plot_window.py'],
pathex=['D:\\install_test\\FASTPLOT'],
binaries=[],
datas=[(SETUP_DIR+'lib\\icon','lib\\icon'),(SETUP_DIR+'data','data')],
hiddenimports=['pandas','pandas._libs','pandas._libs.tslibs.np_datetime','pandas._libs.tslibs.timedeltas',
'pandas._libs.tslibs.nattype', 'pandas._libs.skiplist','scipy._lib','scipy._lib.messagestream'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
  
  
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='fastplot',
debug=False,
strip=False,
upx=True,
console=True)
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='fastplot')

 

4、打包:pyinstaller xxx.spec

5、按需添加未正常添加的包和常量,如配置表等。

参考:https://www.cnblogs.com/shiyongge/p/10582552.html

 

posted @   小毛编  阅读(253)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2022-05-26 txt处理成excel
2021-05-26 python len() 与 __sizeof__()区别
点击右上角即可分享
微信分享提示