简体   繁体   English

使用Inno Setup为Python创建Windows Installer

[英]Creating a windows installer for python using inno setup

I am developing an application that needs python to be installed to execute. 我正在开发需要安装python才能执行的应用程序。 I am thinking of creating an installer(for windows) which will install the required setups automatically before installing my application. 我正在考虑创建一个安装程序(用于Windows),该安装程序将在安装我的应用程序之前自动安装所需的设置。 I have gone through inno setup which looks like a better solution for my requirement.I am new to both python and inno setup.Can Any body provide some links and guidelines on this.Any help is appreciated. 我已经完成了inno设置,这似乎可以更好地满足我的要求。我对python和inno设置都是陌生的。任何机构都可以在此提供一些链接和指南。

if you are thinking of creating an installer(for windows) which will install the required setups automatically before Lauching(installing) my application 如果您正在考虑创建一个安装程序(用于Windows),它将在启动(安装)我的应用程序之前自动安装所需的设置

then the below script will help you to do this...you need to mention python executable in runsection and files section as like winscp in this script. 那么下面的脚本将帮助您做到这一点...您需要在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 

you can find whether python is installed or not by using these below ways 您可以使用以下方法查找是否已安装python

1.Direxists function(Here you can Check whether python directory exists in program files or not ) 1.Direxists功能(在这里您可以检查程序文件中是否存在python目录)

2.filexists function(with this you can check python files are there in the users systems ) 2. filexists函数(通过它可以检查用户系统中是否存在python文件)

3.Query the registry with the python registry key names(HKEY_LOCAL_MACHINE\\SOFTWARE\\Python).. 3.使用python注册表项名称(HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Python)查询注册表。

then if you get result positive then go for your application installation other wise install python for windows and then run your applications. 然后,如果您得到的结果是肯定的,则进行应用程序安装,否则,为Windows安装python,然后运行您的应用程序。 you need to pack python for windows setup with the help of files section. 您需要在“文件”部分的帮助下为Windows安装程序打包python。 you must use [Code] section of inno setup, to use above function. 您必须使用inno setup的[Code]部分才能使用上述功能。

please see pascal script : support functions in inno setup help file.. 请参阅pascal脚本:inno setup帮助文件中的支持功能。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM