6

我正在开发一个需要安装 python 才能执行的应用程序。我正在考虑创建一个安装程序(适用于 Windows),它将在安装我的应用程序之前自动安装所需的设置。我已经完成了 inno 设置,这看起来像是一个更好的解决方案来满足我的要求。我对 python 和 inno setup 都是新手。任何机构都可以提供一些关于此的链接和指南。感谢任何帮助。

4

2 回答 2

6

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

那么下面的脚本将帮助您执行此操作...您需要在运行部分和文件部分提及 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 

您可以通过以下方式查看是否安装了 python

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

2.filexists 函数(通过这个你可以检查用户系统中是否有python文件)

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

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

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

于 2013-07-10T06:15:43.937 回答
5

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

于 2013-07-10T17:40:48.800 回答