setup.iss 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. ; Installation program script for Hello world
  2. ; WARNING: do not forget to regenerate the AppId (Inno Setup > Tools > Generate GUI) ; Double the bracklaces
  3. #define AppGuid "{3ABFE415-C8DA-43E8-91BD-0DFD8231A58F}"
  4. ; Version of the installer
  5. #define FileVersion "1.0.0"
  6. ; Application short name (also the name of the install directory)
  7. #define AppName "hello_world"
  8. ; Application verbose name
  9. #define AppVerboseName "Python Hello World"
  10. ; Application current version
  11. #define AppVersion "0.1"
  12. ; Publisher's name
  13. #define AppPublisher "Conseil Départemental du Bas-Rhin"
  14. ; Website
  15. #define AppURL "http://codebox/lab/Python_3-6-1"
  16. ; Install diretory
  17. #define AppLocation "{%temp}"
  18. ; Python version required
  19. #define PythonVersion "3.6-32"
  20. [Setup]
  21. AppId={{#AppGuid}}
  22. VersionInfoVersion={#FileVersion}
  23. AppName={#AppVerboseName}
  24. AppVersion={#AppVersion}
  25. AppPublisher={#AppPublisher}
  26. AppPublisherURL={#AppURL}
  27. AppSupportURL={#AppURL}
  28. AppUpdatesURL={#AppURL}
  29. DefaultDirName={#AppLocation}\\{#AppName}
  30. DefaultGroupName={#AppName}
  31. Compression=lzma
  32. PrivilegesRequired=lowest
  33. SolidCompression=yes
  34. VersionInfoCompany={#AppPublisher}
  35. DisableDirPage=yes
  36. DisableProgramGroupPage=yes
  37. DisableFinishedPage=yes
  38. OutputDir=.
  39. OutputBaseFilename=setup-{#AppName}
  40. ChangesEnvironment=yes
  41. UninstallFilesDir={app}\uninstall\
  42. [Languages]
  43. Name: "french"; MessagesFile: "compiler:Languages\French.isl"
  44. [Files]
  45. ; Files to be installed
  46. Source: "core\*"; DestDir: "{app}\core"; Flags: recursesubdirs
  47. Source: "ui\*"; DestDir: "{app}\ui"; Flags: recursesubdirs
  48. Source: "main.py"; DestDir: "{app}"
  49. Source: "updater.py"; DestDir: "{app}"
  50. Source: "icon.ico"; DestDir: "{app}"
  51. Source: "requirements.txt"; DestDir: "{app}"
  52. Source: "VERSION"; DestDir: "{app}"
  53. [Icons]
  54. ; Shortcuts to be created in the menu bar and on the desktop
  55. ; WARNING: Because it's an UI app, pythonw.exe is used. Replace with 'python.exe' for a console app.
  56. Name: "{group}\{#AppName}"; Filename: "{code:fPythonDir}\pythonw.exe"; Parameters: """{app}\main.py"""; WorkingDir: "{app}"; IconFilename: "{app}\icon.ico"
  57. Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}"
  58. Name: "{commondesktop}\{#AppName}"; Filename: "{code:fPythonDir}\pythonw.exe"; Parameters: """{app}\main.py"""; WorkingDir: "{app}"; IconFilename: "{app}\icon.ico"
  59. [Code]
  60. var
  61. sPythonDir: String;
  62. sPythonExecPath: String;
  63. sPythonWExecPath: String;
  64. // Return the directory containing the python executable
  65. procedure UpdatePythonDir();
  66. var
  67. Dirname: String;
  68. begin
  69. sPythonDir := '';
  70. if RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\Python\PythonCore\{#PythonVersion}\InstallPath', '', Dirname) OR
  71. RegQueryStringValue(HKLM, 'SOFTWARE\Python\PythonCore\{#PythonVersion}\InstallPath', '', Dirname) then
  72. begin
  73. sPythonDir := Dirname;
  74. sPythonExecPath := Dirname + 'python.exe'
  75. sPythonWExecPath := Dirname + 'pythonw.exe'
  76. end
  77. end;
  78. // Initial checkup
  79. function InitializeSetup(): Boolean;
  80. begin
  81. UpdatePythonDir();
  82. // check that python is installed
  83. if not FileExists(sPythonExecPath) then
  84. begin
  85. MsgBox('Python {#PythonVersion} doit être installé.' + #13#10 + 'Installation annulée.', mbError, MB_OK);
  86. Result := False;
  87. Exit;
  88. end
  89. Result := True;
  90. end;
  91. procedure CurStepChanged(CurStep: TSetupStep);
  92. var
  93. ShowCmd: Integer;
  94. ExitCode: Integer;
  95. begin
  96. if CurStep = ssPostInstall then
  97. begin
  98. // Search for a requirements.txt file,and process it if exists
  99. if FileExists(ExpandConstant('{app}\requirements.txt')) then
  100. begin
  101. if WizardSilent then begin ShowCmd := SW_HIDE end else begin ShowCmd := SW_SHOWNORMAL end
  102. Exec(sPythonDir + 'Scripts\pip67.exe', 'install -r ' + ExpandConstant('"{app}\requirements.txt"'), '', ShowCmd, ewWaitUntilTerminated, ExitCode);
  103. if ExitCode <> 0 then
  104. begin
  105. MsgBox('Python 3.6 - Une erreur s''est produite lors de l''installation des librairies' + #13#10 + '[' + SysErrorMessage(ExitCode) + ']', mbError, MB_OK);
  106. Exit;
  107. end
  108. Log('Installed in ' + ExpandConstant('{app}'))
  109. end
  110. end
  111. end;
  112. // Scripted Constants for use in the other sections
  113. function fPythonDir(Param: String): String;
  114. begin
  115. Result := sPythonDir;
  116. end;