Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno setup code to install python

I have an inno set up code , which installs python . It works fine and I am getting the setup.exe file with the set up file having the python in it. But when I tried installing python with that setup file , it didnt work.Is that because the setup file is looking for the python file specified in the file section, If so How can I change the code so that the python inside the setup.exe will be used .Also the setup is creating a default application every time when I install the set up.I have tried the attribute DisableDirPage=yes ,but it didnt work. Can any body suggest some solution to this.

             #define MyAppName "My Program"
             #define MyAppVersion "1.5"



                    [Setup]
           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
           DisableDirPage=yes


          [Files]
             Source: "H:\python-2.7.5.msi"; DestDir: "{app}"; Flags: ignoreversion




            [code]
             #define MinJRE "1.6"
            #define WebJRE "H:\python-2.7.5.msi"

           function InitializeSetup(): Boolean;
           var
          ErrorCode: Integer;
         PythonInstalled : Boolean;
          Result1 : Boolean;
          begin
              PythonInstalled :=                      RegKeyExists(HKLM,'SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath');
          if PythonInstalled then
            begin
          MsgBox('installed', mbInformation, MB_OK);
           end
                else
            begin

           Result1 := MsgBox('2222222222222222This tool requires python Runtime Environment  to run.  Do you want to install it now?',
            mbConfirmation, MB_YESNO) = idYes;
          if Result1 = false then
             begin    
             Result:=false;
             end 
         else
            begin

             MsgBox('not installed', mbInformation, MB_OK);
              Result:=true;
              ShellExec('',
               '{#WebJRE}',
              '','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
             end;
                  end;
                end;
like image 545
dileepVikram Avatar asked Jul 24 '13 14:07

dileepVikram


People also ask

How do I install a Python script?

Installing Python Packages with Setup.py To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.

How do I create a setup file for Windows application in Python?

Steps To Make Installer From .Step 1: Download inno setup software. Step 2: Choose Create new script file using the Script Wizard. Step 3: Fill Application Information. Step 4: Add files and folders and click on Next.


1 Answers

Made some changes to your script as Tlama said. Working fine at my side, Changed the File section entry and used Exec instead ShellExec...

replace python-2.7.5.amd64.msi to python-2.7.5.msi and replace D:\ to H:\

#define MyAppName "My Program"
#define MyAppVersion "1.5"

[Setup]
AppId={{BD59E856-F194-4E05-A93B-89089F3E3E9D}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
DisableDirPage=yes

[Files]
Source: "D:\python-2.7.5.amd64.msi"; Flags: dontcopy

[code]
#define MinJRE "1.6"

function InitializeSetup: Boolean;
var
  ErrorCode: Integer;
  PythonInstalled: Boolean;
  Result1: Boolean;
  WebJRE: string;
begin
  PythonInstalled := RegKeyExists(HKLM, 'SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath');
  if PythonInstalled then
  begin
    MsgBox('installed', mbInformation, MB_OK);
  end
  else
  begin
    Result1 := MsgBox('This tool requires python Runtime Environment  to run.  Do you want to install it now ?', mbConfirmation, MB_YESNO) = IDYES;
    if not Result1 then
    begin    
      Result := False;
    end 
    else
    begin
      MsgBox('not installed', mbInformation, MB_OK);
      Result := True;

      ExtractTemporaryFile('python-2.7.5.amd64.msi')
      WebJRE:='"'+Expandconstant('{tmp}\python-2.7.5.amd64.msi')+'"'
      Exec('cmd.exe ','/c'+WebJRE,'', SW_HIDE,ewWaituntilterminated, Errorcode);
    end;
  end;
end;
like image 59
Gangadhar Avatar answered Oct 18 '22 15:10

Gangadhar