使用inno设置为python创建Windows安装程序

dil*_*ram 4 python installer inno-setup

我正在开发一个需要安装python来执行的应用程序.我正在考虑创建一个安装程序(用于Windows),它将在安装我的应用程序之前自动安装所需的安装程序.我已经通过inno设置,看起来更符合我的要求.我是python和inno setup的新手.可以任何机构提供一些关于此的链接和指南.任何帮助表示赞赏.

Gan*_*har 6

如果您正在考虑创建一个安装程序(用于Windows),它将在Lauching(安装)我的应用程序之前自动安装所需的设置

然后下面的脚本将帮助你这样做...你需要在runsection和files部分提到python可执行文件,就像在这个脚本中的winscp一样.

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.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={{BD59E856-F194-4E05-A93B-89089F3E3E9D}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\Program Files (x86)\Inno Setup 5\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\softwares\winscp512setup.exe"; DestDir: "{app}"; Flags: ignoreversion

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\winscp512setup.exe"; Description: "Before launching this application you need to install xxx this ,so please install this and then launch"; Flags: nowait shellexec skipifsilent
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent 
Run Code Online (Sandbox Code Playgroud)

你可以通过以下方式找到是否安装了python

1.Direxists函数(这里可以检查程序文件中是否存在python目录)

2.filexists函数(用这个你可以查看用户系统中的python文件)

3.使用python注册表项名称(HKEY_LOCAL_MACHINE\SOFTWARE\Python)查询注册表.

然后,如果你得到结果肯定,那么去你的应用程序安装其他明智的安装python for windows然后运行你的应用程序.你需要在文件部分的帮助下打包python for windows setup.你必须使用inno设置的[Code]部分,才能使用上述功能.

请参阅pascal脚本:在inno设置帮助文件中支持功能..


Fel*_*ein 5

如果您的程序依赖于许多第三方软件包而不仅仅是Python标准库,那么使用cx_Freezepy2exe冻结它可能会更容易,然后使用Inno Setup将所有文件打包到安装程序中.