| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- ; Installation program script for Hello world
- ; WARNING: do not forget to regenerate the AppId (Inno Setup > Tools > Generate GUI) ; Double the bracklaces
- #define AppGuid "{3ABFE415-C8DA-43E8-91BD-0DFD8231A58F}"
- ; Version of the installer
- #define FileVersion "1.0.0"
- ; Application short name (also the name of the install directory)
- #define AppName "hello_world"
- ; Application verbose name
- #define AppVerboseName "Python Hello World"
- ; Application current version
- #define AppVersion "0.1"
- ; Publisher's name
- #define AppPublisher "Conseil Départemental du Bas-Rhin"
- ; Website
- #define AppURL "http://codebox/lab/Python_3-6-1"
- ; Install diretory
- #define AppLocation "{tmp}"
- ; Python version required
- #define PythonVersion "3.6-32"
- [Setup]
- AppId={{#AppGuid}}
- VersionInfoVersion={#FileVersion}
- AppName={#AppVerboseName}
- AppVersion={#AppVersion}
- AppPublisher={#AppPublisher}
- AppPublisherURL={#AppURL}
- AppSupportURL={#AppURL}
- AppUpdatesURL={#AppURL}
- DefaultDirName={#AppLocation}\\{#AppName}
- DefaultGroupName={#AppName}
- Compression=lzma
- PrivilegesRequired=lowest
- SolidCompression=yes
- VersionInfoCompany={#AppPublisher}
- DisableDirPage=yes
- DisableProgramGroupPage=yes
- DisableFinishedPage=yes
- OutputDir=.
- OutputBaseFilename=setup-{#AppName}
- ChangesEnvironment=yes
- UninstallFilesDir={app}\uninstall\
- [Languages]
- Name: "french"; MessagesFile: "compiler:Languages\French.isl"
- [Files]
- ; Files to be installed
- Source: "core\*"; DestDir: "{app}\core"; Flags: recursesubdirs
- Source: "ui\*"; DestDir: "{app}\ui"; Flags: recursesubdirs
- Source: "main.py"; DestDir: "{app}"
- Source: "updater.py"; DestDir: "{app}"
- Source: "icon.ico"; DestDir: "{app}"
- Source: "requirements.txt"; DestDir: "{app}"
- Source: "VERSION"; DestDir: "{app}"
- [Icons]
- ; Shortcuts to be created in the menu bar and on the desktop
- ; WARNING: Because it's an UI app, pythonw.exe is used. Replace with 'python.exe' for a console app.
- Name: "{group}\{#AppName}"; Filename: "{code:fPythonDir}\pythonw.exe"; Parameters: """{app}\main.py"""; WorkingDir: "{app}"; IconFilename: "{app}\icon.ico"
- Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}"
- Name: "{commondesktop}\{#AppName}"; Filename: "{code:fPythonDir}\pythonw.exe"; Parameters: """{app}\main.py"""; WorkingDir: "{app}"; IconFilename: "{app}\icon.ico"
- [Code]
- var
- sPythonDir: String;
- sPythonExecPath: String;
- sPythonWExecPath: String;
- // Return the directory containing the python executable
- function UpdatePythonDir(): String;
- var
- Dirname: String;
- begin
- sPythonDir := '';
- if RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\Python\PythonCore\{#PythonVersion}\InstallPath', '', Dirname) OR
- RegQueryStringValue(HKLM, 'SOFTWARE\Python\PythonCore\{#PythonVersion}\InstallPath', '', Dirname) then
- begin
- sPythonDir := Dirname;
- sPythonExecPath := Dirname + 'python.exe'
- sPythonWExecPath := Dirname + 'pythonw.exe'
- end
- end;
- // Initial checkup
- function InitializeSetup(): Boolean;
- begin
- UpdatePythonDir();
- // check that python is installed
- if not FileExists(sPythonExecPath) then
- begin
- MsgBox('Python {#PythonVersion} doit être installé.' + #13#10 + 'Installation annulée.', mbError, MB_OK);
- Result := False;
- Exit;
- end
- Result := True;
- end;
- procedure CurStepChanged(CurStep: TSetupStep);
- var
- ShowCmd: Integer;
- ExitCode: Integer;
- begin
- if CurStep = ssPostInstall then
- begin
- // Search for a requirements.txt file,and process it if exists
- if FileExists(ExpandConstant('{app}\requirements.txt')) then
- begin
-
- if WizardSilent then begin ShowCmd := SW_HIDE end else begin ShowCmd := SW_SHOWNORMAL end
- Exec(sPythonDir + 'Scripts\pip67.exe', 'install -r ' + ExpandConstant('"{app}\requirements.txt"'), '', ShowCmd, ewWaitUntilTerminated, ExitCode);
- if ExitCode <> 0 then
- begin
- MsgBox('Python 3.6 - Une erreur s''est produite lors de l''installation des librairies' + #13#10 + '[' + SysErrorMessage(ExitCode) + ']', mbError, MB_OK);
- Exit;
- end
- end
- end
- end;
- // Scripted Constants for use in the other sections
- function fPythonDir(Param: String): String;
- begin
- Result := sPythonDir;
- end;
|