一、简介:

基本代码同上一篇:
python自动设置,利用nuitka打包
基本类似,只增加了多进程部分,主要是为了有些打起来较慢的包,同时进行隐藏命令窗和不隐藏命令窗的操作,打完的同时,只要对不隐藏命令窗进行运行,无报错,那么就不用再次重复打包浪费时间了。当然也可以运用在需要多代码打包的情况下,需要注意内存占用。

二、部分代码:

1.轮子:

  1. from multiprocessing import Process#多进程

2.创建进程并运行:

  1. rig = subprocess.getstatusoutput("gcc -v")#cmdgcc-v,错误则返回非0值,判断是否已经设置好环境
  2. if (rig[0]) == 0:
  3. if __name__ == '__main__':
  4. p1 = Process(target=nuitkaing)
  5. p2 = Process(target=nuitkaing2)
  6. p1.start()
  7. p2.start()

3.打包部分:

  1. #打包部分0↓
  2. def nuitkaing():
  3. windows_icon = ''
  4. if windows_icon:
  5. icon = ' --windows-icon-from-ico=' + windows_icon
  6. else:
  7. icon = ''
  8. file_version = '1.0.0.0'
  9. if file_version:
  10. f_version = ' --windows-file-version=' + file_version
  11. else:
  12. f_version = ''
  13. company_name = 'wUw(wuwofcproject.com)'
  14. if company_name:
  15. c_name = ' --windows-company-name=' + str(company_name)
  16. else:
  17. c_name = ''
  18. file_description = 'Copyright2022wUw(wuwofcproject.com)'
  19. if file_description:
  20. f_description = ' --windows-file-description=' + file_description
  21. else:
  22. f_description = ''
  23. output_dir = 'Uncertainty'
  24. if output_dir:
  25. o_dir = ' --output-dir=' + output_dir
  26. else:
  27. o_dir = ''
  28. pythonfile = ' Uncertaintyerl.py'
  29. subprocess.run('nuitka --mingw64 --onefile '
  30. '--windows-disable-console '
  31. '--show-progress '
  32. '--show-memory '
  33. '--plugin-enable=tk-inter '
  34. '--plugin-enable=numpy '
  35. '--plugin-enable=pylint-warnings '
  36. '--windows-file-version='
  37. + icon
  38. + f_version
  39. + c_name
  40. + f_description
  41. + ' --follow-imports'
  42. + o_dir
  43. + pythonfile)
  44. print('over')
  45. #打包部分0↑
  46. #打包部分01↓
  47. def nuitkaing2():
  48. windows_icon = ''
  49. if windows_icon:
  50. icon = ' --windows-icon-from-ico=' + windows_icon
  51. else:
  52. icon = ''
  53. file_version = '1.0.0.0'
  54. if file_version:
  55. f_version = ' --windows-file-version=' + file_version
  56. else:
  57. f_version = ''
  58. company_name = 'wUw(wuwofcproject.com)'
  59. if company_name:
  60. c_name = ' --windows-company-name=' + str(company_name)
  61. else:
  62. c_name = ''
  63. file_description = 'Copyright2022wUw(wuwofcproject.com)'
  64. if file_description:
  65. f_description = ' --windows-file-description=' + file_description
  66. else:
  67. f_description = ''
  68. output_dir = 'Uncertaintynon'
  69. if output_dir:
  70. o_dir = ' --output-dir=' + output_dir
  71. else:
  72. o_dir = ''
  73. pythonfile = ' Uncertaintyerl.py'
  74. subprocess.run('nuitka --mingw64 --onefile '
  75. '--show-progress '
  76. '--show-memory '
  77. '--plugin-enable=tk-inter '
  78. '--plugin-enable=numpy '
  79. '--plugin-enable=pylint-warnings '
  80. '--windows-file-version='
  81. + icon
  82. + f_version
  83. + c_name
  84. + f_description
  85. + ' --follow-imports'
  86. + o_dir
  87. + pythonfile)
  88. print('over')
  89. #打包部分01↑