Python detection code for InnoSetup
Robert Olson
olson at mcs.anl.gov
Mon Sep 29 10:31:01 CDT 2003
Sending this off for future reference since it doesn't belong in the .iss
I'm working on at the moment.
--bob
-------------- next part --------------
[Code]
var
PythonPaths, PythonNames : TArrayOfString;
PythonPathVals: TArrayOfString;
HavePy22, HavePy23, MultiplePythonInstalls: Boolean;
function InitializeSetup(): Boolean;
var
py22path, py22name, py23path, py23name: String;
begin
if RegQueryStringValue(HKLM, 'Software\Python\PythonCore\2.2\InstallPath', '', py22path) then begin
HavePy22 := true;
RegQueryStringValue(HKLM, 'Software\Python\PythonCore\2.2\InstallPath\InstallGroup', '', py22name)
end else begin
HavePy22 := false
end;
if RegQueryStringValue(HKLM, 'Software\Python\PythonCore\2.3\InstallPath', '', py23path) then begin
HavePy23 := true;
RegQueryStringValue(HKLM, 'Software\Python\PythonCore\2.3\InstallPath\InstallGroup', '', py23name)
end else begin
HavePy23 := false
end;
if HavePy22 and HavePy23 then begin
SetArrayLength(PythonPaths, 2);
SetArrayLength(PythonNames, 2);
SetArrayLength(PythonPathVals, 2);
PythonPaths[0] := py22path
PythonPaths[1] := py23path
PythonNames[0] := py22name
PythonNames[1] := py23name
{ Default to the latest one. }
PythonPathVals[1] := '1';
MultiplePythonInstalls := true;
end else begin
MultiplePythonInstalls := false;
end;
Result := true;
end;
function ScriptDlgPages(CurPage: Integer; BackClicked: Boolean): Boolean;
var
I, CurSubPage: Integer;
Nextt, NextOk: Boolean;
pythonPath: String;
begin
if (not BackClicked and (CurPage = wpSelectDir)) or (BackClicked and (CurPage = wpSelectProgramGroup)) then begin
{ Insert a custom wizard page between two non custom pages }
{ First open the custom wizard page }
ScriptDlgPageOpen();
{ Set some captions }
ScriptDlgPageSetCaption('Choose python version.');
ScriptDlgPageSetSubCaption1('Multiple versions of Python are installed on this system.');
ScriptDlgPageSetSubCaption2('Select the version you wish to use for the Access Grid Toolkit, and click Next.');
Nextt := InputOptionArray(PythonNames, PythonPathVals, True, False);
for i := 0 to GetArrayLength(PythonPathVals) - 1 do begin
if (PythonPathVals[i] = '1') then begin
pythonPath := PythonPaths[i];
break
end;
end;
MsgBox(pythonPath, mbInformation, MB_OK);
if not BackClicked then
Result := Nextt
else
Result := not Nextt;
ScriptDlgPageClose(not Result);
end else begin
Result := true
end;
end;
function NextButtonClick(CurPage: Integer): Boolean;
begin
if MultiplePythonInstalls then
Result := ScriptDlgPages(CurPage, False)
else
Result := True
end;
function BackButtonClick(CurPage: Integer): Boolean;
begin
if MultiplePythonInstalls then
Result := ScriptDlgPages(CurPage, True)
else
Result := True
end;
More information about the ag-dev
mailing list