ISCC配置
; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "软件名" #define MyAppVersion "2.0.0" #define MyAppPublisher "niyuming, Inc." #define MyAppURL "https://member.niyuming.com/#/login" #define MyAppExeName "upexe.exe" [Setup] ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) AppId={{DCBC5E2E-91C7-45F1-8843-15DE4E0E0F2A} AppName={#MyAppName} AppVersion={#MyAppVersion} ;AppVerName={#MyAppName} {#MyAppVersion} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName=D:\Program Files\{#MyAppName} DisableProgramGroupPage=yes LicenseFile=E:\软件名打包记录\软件名资料\license.txt PrivilegesRequired=admin ; Uncomment the following line to run in non administrative install mode (install for current user only.) ;PrivilegesRequired=lowest ;OutputDir=C:\Users\NING MEI\Desktop OutputDir=output OutputBaseFilename=新版本软件名安装包 SetupIconFile=F:\code.fy.com\myNewStart\new_start.dist\cate\icons\logo.ico Compression=lzma SolidCompression=yes WizardStyle=modern [Languages] Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl" [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone [Files] Source: "F:\code.fy.com\myNewStart\new_start.dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion Source: "F:\code.fy.com\myNewStart\new_start.dist\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons] Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
nuitka脚本如下:
# coding:utf-8 import json import shutil import time import zipfile, os import hashlib # 创建多级文件(不含文件) def create_dir(file_path): if os.path.exists(file_path) is False: try: os.makedirs(file_path) except Exception as e: pass #先移除 上次打包得缓存 old_cache_path = os.path.join(os.getcwd(),'new_start.dist') if os.path.exists(old_cache_path): try: shutil.rmtree(old_cache_path) except Exception as e: print(str(e)) start_time = time.time() version = '1.0.67' with open('config.json',encoding='utf-8')as f: res = f.read() config = json.loads(res) config['appInfo']['version']=version with open('config.json','w',encoding='utf-8')as f: f.write(json.dumps(config,indent=1,ensure_ascii=False)) strr = r'nuitka --windows-icon-from-ico="./logo.ico" --standalone --mingw64 --enable-plugin=pyqt5 --nofollow-import-to=psutil,flask,requests,email,http,sqlalchemy,cryptography,pymysql,pycparser,urllib3,idna,sqlite3,Crypto --show-progress --show-modules --include-data-dir=cate=cate --include-data-files=config.json=config.json --include-data-files=upexe.exe=upexe.exe --windows-disable-console --windows-uac-admin --remove-output ./new_start.py' # # #debug # strr = r'nuitka --windows-icon-from-ico="./logo.ico" --standalone --mingw64 --enable-plugin=pyqt5 --nofollow-import-to=psutil,flask,requests,email,http,sqlalchemy,cryptography,pymysql,pycparser,urllib3,idna,sqlite3,Crypto --show-progress --show-modules --include-data-dir=cate=cate --include-data-files=./libs/libEGL.dll=libEGL.dll --include-data-files=./libs/libGLESv2.dll=libGLESv2.dll --include-data-files=./libs/d3dcompiler_47.dll=d3dcompiler_47.dll --include-data-files=config.json=config.json --include-data-files=upexe.exe=upexe.exe --windows-uac-admin --remove-output ./new_start.py' # # #打包命令 os.system(strr) package_path = 'need_pkg\*' libs_path = 'libs\*' gen_dir_path = 'new_start.dist\*' #复制包文件 进入dist里面 os.system('xcopy /y /s "{0}" "{1}"'.format(package_path,gen_dir_path)) os.system('xcopy /y /s "{0}" "{1}"'.format(libs_path,gen_dir_path)) # # 复制包文件进入 打包文件内 path = os.path.join('F:\软件打包\你的软件名打包记录', 'package',version+"__"+time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime())) if not os.path.exists(path): create_dir(path) zip_path = os.path.join(path, 'test.zip') if os.path.exists(zip_path): os.remove(zip_path) # # 执行方法 zip_strr = 'WinRAR -ep1 a -r -x*upexe.exe {0} "{1}"'.format(zip_path, gen_dir_path) os.system(zip_strr) with open(os.path.join(path, 'test.zip'), 'rb') as f: res = f.read() with open(os.path.join(path, 'info.txt'),'w',encoding='utf-8')as f: f.write('md5:'+hashlib.md5(res).hexdigest()+'\n') f.write('version:'+version+'\n') exe_strr = 'ISCC.exe ./yududouo3.iss' os.system(exe_strr) # shutil.move(os.path.join('C:\Users\NING\\ MEI\Desktop\output','新版本鱼多多安装包.exe'),path) if os.name == 'nt': home = os.getenv('USERPROFILE') else: home = os.getenv('HOME') shutil.move(os.path.join('output','新版本你的软件名安装包.exe'), path) end_time = time.time() print(end_time-start_time)
总结
程序爱好者经常要把自己编写的软件进行打包成可安装的exe,以上保姆级教程让大家傻瓜式学会打包。喜欢私聊。