6

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.

4
  • 2
    Quote from python website "Python releases include an excellent Windows installer" - What is your question? Commented Jul 9, 2013 at 23:18
  • @sir Rufo My application need python environment for its functionality,So before installing my application I need to check whether python is installed or not,so I thought of making it automated by using an installer which will check for python and will install it if python is not found. I have observed inno setup as a good tool for such purposes.So would like to have some inno set up scripts or guidelines for the same. Commented Jul 10, 2013 at 6:21
  • So you are looking for something to integrate the python installer? Then you should update your question :o) Commented Jul 10, 2013 at 6:23
  • The keyword here is prerequisites and this is very common (e.g. deploying .Net applications) Commented Jul 10, 2013 at 6:26

2 Answers 2

7

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..

Sign up to request clarification or add additional context in comments.

3 Comments

Thank You for the advise,It really helped.More useful tip for me was how to search the resistry for python, than the code.
The code works fine, but it produces a default a directory with the name DefaultDirName, each time when I execute the code also I am not able to remove the code as the DefaultDirName,appName etc are required. Do you have any solution for this ?
if your intension is "disable default directory creation", you can use [Setup] section directive DisableDirPage=yes in inno setup script, to do this . If this is not your requirement, please explain more about your requirement
6

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.