使用Inno Setup为Python创建Windows安装程序 [英] Creating a windows installer for python using inno setup

查看:183
本文介绍了使用Inno Setup为Python创建Windows安装程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个需要安装python才能执行的应用程序.我正在考虑创建一个安装程序(用于Windows),该安装程序将在安装我的应用程序之前自动安装所需的设置.我已经完成了inno设置,这似乎可以更好地满足我的要求.我是python和inno设置的新手.任何机构都可以提供与此相关的链接和指南.感谢您的帮助.

I am developing an application that needs python to be installed to execute. I am thinking of creating an installer(for windows) which will install the required setups automatically before installing my application. 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.

推荐答案

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

if you are thinking of creating an installer(for windows) which will install the required setups automatically before Lauching(installing) my application

然后下面的脚本将帮助您完成此操作...您需要在runsection和files部分中提及python可执行文件,就像此脚本中的winscp.

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.

; 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

you can find whether python is installed or not by using these below ways

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

1.Direxists function(Here you can Check whether python directory exists in program files or not )

2.filexists函数(通过此功能,您可以检查用户系统中是否存在python文件)

2.filexists function(with this you can check python files are there in the users systems )

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

3.Query the registry with the python registry key names(HKEY_LOCAL_MACHINE\SOFTWARE\Python)..

然后,如果您得到的结果是肯定的,则进行应用程序安装,否则,为Windows安装python,然后运行您的应用程序. 您需要在文件"部分的帮助下为Windows安装程序打包python. 您必须使用inno setup的[Code]部分才能使用上述功能.

then if you get result positive then go for your application installation other wise install python for windows and then run your applications. you need to pack python for windows setup with the help of files section. you must use [Code] section of inno setup, to use above function.

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

please see pascal script : support functions in inno setup help file..

这篇关于使用Inno Setup为Python创建Windows安装程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆