Creating a windows installer for python using inno setup

前端 未结 2 1614
独厮守ぢ
独厮守ぢ 2021-02-01 11:09

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 automati

相关标签:
2条回答
  • 2021-02-01 11:40

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

    0 讨论(0)
  • 2021-02-01 11:50

    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.

    0 讨论(0)
提交回复
热议问题