FastDeploy icon indicating copy to clipboard operation
FastDeploy copied to clipboard

About using Nuitka to package fastdeploy

Open Liu-jian-kang opened this issue 1 year ago • 5 comments

Add --nofollow-import-to=fastdeploy when packing, and copy the python package by yourself after the packaging is successful

After packaging, run main.exe RTWD7UV `3CZW5DQ6JIIKNS

Copy fastdeploy from .../lib/site-packages to the sibling directory of main.exe Run again ~NS7S6QYIT BN8Z82`QS6ZA

This time tqdm is missing, then copy tqdm to the sibling directory of main.exe as well

The run was successful {IF1)DH5 }R7CWL6QN812WW

My packing command

import os
import sys
# 1.9.7
import nuitka

# 检查是否安装了这个nuitka
print(nuitka.__path__)

# python 程序入口文件路径
main_file_path = 'main.py'
# 程序图标路径,png图片需要安装imageio库
icon_file_path = 'icon.png'
# 打包结果保存路径
output_dir = 'output'

# C编译器的选项,msvc需要指定版本
# mingw 自行下载配置
# vs2022 14.3
# vs2019 14.2
# vs2017 14.1
# vs2015 14.0
c_compiler = ['mingw64', 'msvc=14.3']
# 使用的C编译器,此处使用msvc,根据自己情况调整
use_c_compiler = c_compiler[1]
# 有些步骤需要键盘输入,故另外启动一个命令行执行
os.system(f'start  "Nuitka打包"  cmd /K "'
          f'{sys.executable} -m nuitka '
          f'--{use_c_compiler} '
          f'--standalone '
          f'--show-progress '
          f'--output-dir={output_dir}   '
          # 启用Pyqt5支持
          f'--enable-plugin=pyqt5 '
          f'--nofollow-import-to=fastdeploy '
          # 编译出来的程序不带黑框框
          # 初次打包建议不带这个选项
          # 打包完成运行时可以看报错信息,等到运行正常再勾上,重新打包
          # f'--disable-console  '
          f'--windows-icon-from-ico={icon_file_path} '
          f'{main_file_path} '
          f'& pause '
          f'& exit"')

Liu-jian-kang avatar Jan 26 '24 08:01 Liu-jian-kang

没有用过这个打包工具,有使用过这个工具的同学可以一起参考下

rainyfly avatar Feb 05 '24 13:02 rainyfly

建议自己手动编译Fastdeploy,裁剪不需要的模块以减小打包后的体积

Liu-jian-kang avatar Feb 05 '24 16:02 Liu-jian-kang

我用onefile模式 让他自己搜索 是可以正常打包运行的

elky98 avatar Feb 19 '24 00:02 elky98