Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a windows installer for python using inno setup

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.

like image 306
dileepVikram Avatar asked Jul 09 '13 08:07

dileepVikram


People also ask

How do I create an Inno installer?

Go to Menu, Project, then Compile to compile and create the setup file. This will create a complete installer. Run the Setup and your application will be installed correctly. Innosetup offers an awesome alternative to create great looking Installers for free.


2 Answers

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

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 

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

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

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

3.Query the registry with the python registry key names(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. 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.

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

like image 75
Gangadhar Avatar answered Nov 02 '22 08:11

Gangadhar


If your program depends on many 3rd party packages and not just the Python standard library then it might be easier to freeze it using cx_Freeze or py2exe and then package all files into an installer using Inno Setup.

like image 32
Felix Zumstein Avatar answered Nov 02 '22 08:11

Felix Zumstein