forked from AndySomogyi/sbmlsolver
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
263 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,23 @@ | |
#define MyAppVersion "1.0.0" | ||
#define MyAppPublisher "University of Washington, Seattle, WA, USA" | ||
#define MyAppURL "http://libroadrunner.org/" | ||
#define PyInstaller "python-2.7.6.msi" | ||
#define NumpyInstaller "numpy-1.8.0-win32-superpack-python2.7.exe" | ||
#define MatplotlibInstaller "matplotlib-1.3.1.win32-py2.7.exe" | ||
;downloads turned off, installers packaged | ||
#define PyInstallerURL "http://python.org/ftp/python/2.7.6/python-2.7.6.msi" | ||
#define NumpyInstallerURL "http://downloads.sourceforge.net/project/numpy/NumPy/1.8.0/numpy-1.8.0-win32-superpack-python2.7.exe?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fnumpy%2Ffiles%2FNumPy%2F&ts=1390956336&use_mirror=softlayer-ams" | ||
#define MatplotlibInstallerURL "https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.3.1/matplotlib-1.3.1.win32-py2.7.exe" | ||
|
||
#define Py "Python" | ||
#define PyVer "2.7" | ||
#define Numpy "Numpy" | ||
#define NumpyVer "1.0" | ||
#define Matplotlib "Matplotlib" | ||
#define MatplotlibVer "1.0" | ||
#define AppDir "roadrunner" | ||
;Used for downloader | ||
;#include ReadReg(HKEY_LOCAL_MACHINE,'Software\Sherlock Software\InnoTools\Downloader','ScriptPath',''); | ||
|
||
[Setup] | ||
; NOTE: The value of AppId uniquely identifies this application. | ||
|
@@ -19,7 +36,13 @@ AppPublisherURL={#MyAppURL} | |
AppSupportURL={#MyAppURL} | ||
AppUpdatesURL={#MyAppURL} | ||
DisableWelcomePage=yes | ||
DefaultDirName=C:\Python27\Lib\site-packages\{#MyAppName} | ||
DefaultDirName={code:SetDefaultAppDirName} | ||
;DefaultDirName=C:\Python27\Lib\site-packages\{#AppDir} | ||
|
||
;enable the next line for debug only | ||
;DisableDirPage=yes | ||
|
||
|
||
DefaultGroupName=libRoadRunner | ||
DisableProgramGroupPage=yes | ||
;LicenseFile=..\..\LICENSE.txt | ||
|
@@ -38,3 +61,242 @@ Name: "english"; MessagesFile: "compiler:Default.isl" | |
[Files] | ||
Source: "..\..\site-packages\roadrunner\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs | ||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files | ||
|
||
[Code] | ||
////////////////////////////////////////////////////////////////////////////// | ||
const | ||
appDir = '{#AppDir}'; | ||
pyReg = 'SOFTWARE\{#Py}\PythonCore\{#PyVer}\InstallPath'; | ||
pyRegWow6443Node = 'SOFTWARE\Wow6432Node\{#Py}\PythonCore\{#PyVer}\InstallPath'; | ||
var | ||
installPython, installMatplot, installNumpy: Boolean; | ||
DefaultAppDirName: String; | ||
////////////////////////////////////////////////////////////////////////////// | ||
procedure ExitProcess(exitCode:integer); | ||
external '[email protected] stdcall'; | ||
////////////////////////////////////////////////////////////////////////////// | ||
function GetPathForPythonSitePackages(): string; | ||
var | ||
InstallPath: string; | ||
begin | ||
if RegQueryStringValue(HKLM, pyReg, '', InstallPath) then | ||
begin | ||
Result := InstallPath + 'Lib\site-packages\' + appDir; | ||
end | ||
else | ||
if RegQueryStringValue(HKCU, pyReg, '', InstallPath) then | ||
begin | ||
Result := InstallPath + 'Lib\site-packages\' + appDir; | ||
end | ||
else | ||
if RegQueryStringValue(HKLM, pyRegWow6443Node, '', InstallPath) then | ||
begin | ||
Result := InstallPath + 'Lib\site-packages\' + appDir; | ||
end | ||
else | ||
begin | ||
MsgBox('Could not find Python',mbError,MB_OK); | ||
ExitProcess(1); | ||
end | ||
end; | ||
////////////////////////////////////////////////////////////////////////////// | ||
function IsPythonInstalled(): Boolean; | ||
var | ||
InstallPath: string; //not really used here | ||
begin | ||
if RegQueryStringValue(HKLM, pyReg, '', InstallPath) then | ||
begin | ||
Result := True; | ||
end | ||
else | ||
if RegQueryStringValue(HKCU, pyReg, '', InstallPath) then | ||
begin | ||
Result := True; | ||
end | ||
else | ||
if RegQueryStringValue(HKLM, pyRegWow6443Node, '', InstallPath) then | ||
begin | ||
Result := True; | ||
end | ||
else | ||
begin | ||
Result := False; | ||
end | ||
end; | ||
////////////////////////////////////////////////////////////////////////////// | ||
function SetDefaultAppDirName(Value: String): String; | ||
begin | ||
Result := DefaultAppDirName; | ||
end; | ||
////////////////////////////////////////////////////////////////////////////// | ||
function IsInstalled(name: string; version: string): boolean; | ||
var | ||
InstallPath: string; | ||
reg : string; | ||
begin | ||
reg := 'Software\' + name + '\' + version | ||
// + '\InstallPath' | ||
Log('reg Python: ' + reg) | ||
//if python installed (also gets its install path, not used here) | ||
if RegQueryStringValue(HKEY_CURRENT_USER, reg, 'InstallPath', InstallPath) then | ||
begin | ||
Result := True; | ||
end | ||
else | ||
begin | ||
Result := False; | ||
end; | ||
end; | ||
////////////////////////////////////////////////////////////////////////////// | ||
procedure RunMsiInstaller(execName: string); | ||
var | ||
ResultCode: Integer; | ||
ExecPath: String; | ||
ExecCommand: String; | ||
begin | ||
ExecPath := ExpandConstant('{tmp}\') + execName; | ||
ExecCommand := '/i ' + ExecPath + ''; //+ ' /qb'; //qb does it silently | ||
//Check that the msi installer file is present | ||
if FileExists(ExecPath) then | ||
begin | ||
Log('ExecPath exists : ' + ExecPath); | ||
end | ||
else | ||
begin | ||
Log('ExecPath doe not exist : ' + ExecPath); | ||
MsgBox('Could not find ' + execName + ' installer',mbError,MB_OK); | ||
ExitProcess(1); | ||
//something went wrong: hell or high water python installer must be there | ||
end; | ||
//execute msi installer, otherwie error and exit | ||
if not ShellExec('', 'msiexec.exe', ExecCommand, '', SW_SHOWNORMAL, | ||
ewWaitUntilTerminated, ResultCode) then | ||
//msi exec not working | ||
MsgBox('Msi installer failed to run!' + #13#10 + ExecCommand + ' ' + | ||
SysErrorMessage(ResultCode), mbError, MB_OK); | ||
end; | ||
////////////////////////////////////////////////////////////////////////////// | ||
function InitializeSetup(): Boolean; | ||
begin | ||
//if python installed get path for python site-packages | ||
//if isInstalled('{#Py}\PythonCore','{#PyVer}') then | ||
if IsPythonInstalled() then | ||
begin | ||
Log('Python: ' + 'True'); | ||
installPython := False; | ||
DefaultAppDirName := GetPathForPythonSitePackages() | ||
end | ||
else //Add Python to tmp folder [ // or download list.. ] | ||
begin | ||
Log('Python: ' + 'False'); | ||
installPython := True; | ||
filecopy(ExpandConstant('{#PyInstaller}'),ExpandConstant('{tmp}\{#PyInstaller}'),false); | ||
//DefaultAppDirName := 'C:\Python27\Lib\site-packages\{#AppDir}' //pretend default path | ||
//will be used when python is installed. | ||
//itd_addfile('{#PyInstallerURL}',ExpandConstant('{tmp}\{#PyInstaller}')); | ||
//itd_addfile('http://sbol.bhi.washington.edu/ppp/setup-dummyPython.exe',ExpandConstant('{tmp}\setup-dummyPython.exe')); | ||
end; | ||
Result := True; //Required for fwd progress, false would exist | ||
end; | ||
////////////////////////////////////////////////////////////////////////////// | ||
procedure InitializeWizard(); | ||
begin | ||
//itd_init; //turned off when packaging installers | ||
//Install Python now if needed, we want it in place before anything else is done | ||
if (installPython) then | ||
RunMsiInstaller('{#PyInstaller}'); | ||
//Check if Numpy is installed | ||
if IsInstalled('{#Numpy}','{#NumpyVer}') then | ||
begin | ||
Log('Numpy: ' + 'True'); | ||
installNumpy := False; | ||
end | ||
else | ||
//Add Numpy to d/l list | ||
begin | ||
Log('Numpy: ' + 'False'); | ||
installNumpy := True; | ||
filecopy(ExpandConstant('{#NumpyInstaller}'),ExpandConstant('{tmp}\{#NumpyInstaller}'),false); | ||
//The following were used to test downloader srategy | ||
//itd_addfile('http://sbol.bhi.washington.edu/ppp/setup-dummyNump.exe', | ||
// ExpandConstant('{tmp}\setup-dummyNump.exe')); | ||
end; | ||
//Check if Matplotlib is installed | ||
if IsInstalled('{#Matplotlib}','{#MatplotlibVer}') then | ||
begin | ||
Log('Matplotlib: ' + 'True'); | ||
installMatplot := False; | ||
end | ||
else | ||
//Add Matplotlib to d/l list | ||
begin | ||
Log('Matplotlib: ' + 'False'); | ||
installMatplot := True; | ||
filecopy(ExpandConstant('{#MatplotlibInstaller}'),ExpandConstant('{tmp}\{#MatplotlibInstaller}'),false); | ||
//The following were used to test downloader srategy | ||
//td_addfile('http://sbol.bhi.washington.edu/ppp/setup-dummyMatplot.exe', | ||
// ExpandConstant('{tmp}\setup-dummyMatplot.exe')); | ||
end; | ||
//Downloads turned off, packaging installers. | ||
//Start the download after the "Ready to install" screen is shown | ||
//itd_downloadafter(wpReady); | ||
end; | ||
////////////////////////////////////////////////////////////////////////////// | ||
procedure RunOtherInstaller(execName: string); | ||
var | ||
ResultCode: Integer; | ||
begin | ||
if not Exec(ExpandConstant('{tmp}\' + execName), '', '', SW_SHOWNORMAL, | ||
ewWaitUntilTerminated, ResultCode) | ||
then | ||
MsgBox('Other installer failed to run!' + #13#10 + execName + | ||
SysErrorMessage(ResultCode), mbError, MB_OK); | ||
end; | ||
////////////////////////////////////////////////////////////////////////////// | ||
// Install Numpy and Matplotlib if mising | ||
procedure CurStepChanged(CurStep: TSetupStep); | ||
var | ||
ResultCode: Integer; | ||
begin | ||
if CurStep=ssInstall then //If on the installation step | ||
//Lets install those files that were downloaded for us | ||
begin | ||
if ForceDirectories(ExpandConstant('{app}')) then | ||
begin | ||
Log('app: ' + ExpandConstant('{app}')); | ||
if (installNumpy) then | ||
RunOtherInstaller('{#NumpyInstaller}'); | ||
if (installMatplot) then | ||
RunOtherInstaller('{#MatplotlibInstaller}'); | ||
end; | ||
end; | ||
end; | ||