一、简介:
基本代码同上一篇:
python自动设置,利用nuitka打包
基本类似,只增加了多进程部分,主要是为了有些打起来较慢的包,同时进行隐藏命令窗和不隐藏命令窗的操作,打完的同时,只要对不隐藏命令窗进行运行,无报错,那么就不用再次重复打包浪费时间了。当然也可以运用在需要多代码打包的情况下,需要注意内存占用。
二、部分代码:
1.轮子:
from multiprocessing import Process#多进程
2.创建进程并运行:
rig = subprocess.getstatusoutput("gcc -v")#cmdgcc-v,错误则返回非0值,判断是否已经设置好环境
if (rig[0]) == 0:
if __name__ == '__main__':
p1 = Process(target=nuitkaing)
p2 = Process(target=nuitkaing2)
p1.start()
p2.start()
3.打包部分:
#打包部分0↓
def nuitkaing():
windows_icon = ''
if windows_icon:
icon = ' --windows-icon-from-ico=' + windows_icon
else:
icon = ''
file_version = '1.0.0.0'
if file_version:
f_version = ' --windows-file-version=' + file_version
else:
f_version = ''
company_name = 'wUw(wuwofcproject.com)'
if company_name:
c_name = ' --windows-company-name=' + str(company_name)
else:
c_name = ''
file_description = 'Copyright2022wUw(wuwofcproject.com)'
if file_description:
f_description = ' --windows-file-description=' + file_description
else:
f_description = ''
output_dir = 'Uncertainty'
if output_dir:
o_dir = ' --output-dir=' + output_dir
else:
o_dir = ''
pythonfile = ' Uncertaintyerl.py'
subprocess.run('nuitka --mingw64 --onefile '
'--windows-disable-console '
'--show-progress '
'--show-memory '
'--plugin-enable=tk-inter '
'--plugin-enable=numpy '
'--plugin-enable=pylint-warnings '
'--windows-file-version='
+ icon
+ f_version
+ c_name
+ f_description
+ ' --follow-imports'
+ o_dir
+ pythonfile)
print('over')
#打包部分0↑
#打包部分01↓
def nuitkaing2():
windows_icon = ''
if windows_icon:
icon = ' --windows-icon-from-ico=' + windows_icon
else:
icon = ''
file_version = '1.0.0.0'
if file_version:
f_version = ' --windows-file-version=' + file_version
else:
f_version = ''
company_name = 'wUw(wuwofcproject.com)'
if company_name:
c_name = ' --windows-company-name=' + str(company_name)
else:
c_name = ''
file_description = 'Copyright2022wUw(wuwofcproject.com)'
if file_description:
f_description = ' --windows-file-description=' + file_description
else:
f_description = ''
output_dir = 'Uncertaintynon'
if output_dir:
o_dir = ' --output-dir=' + output_dir
else:
o_dir = ''
pythonfile = ' Uncertaintyerl.py'
subprocess.run('nuitka --mingw64 --onefile '
'--show-progress '
'--show-memory '
'--plugin-enable=tk-inter '
'--plugin-enable=numpy '
'--plugin-enable=pylint-warnings '
'--windows-file-version='
+ icon
+ f_version
+ c_name
+ f_description
+ ' --follow-imports'
+ o_dir
+ pythonfile)
print('over')
#打包部分01↑