Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; This is the install script for the Sample Program build for Inno Setup.
- #define MyAppName "Sample Program"
- #define MyAppPublisher "company"
- #define MyAppURL "http://www.company.com/"
- #define MyAppContact "email@email.com"
- ; Read previous build number from INI config. If no build number exists, set to 0
- #define MyAppVersion Int(ReadIni(SourcePath+"\\version.ini", "Info", "Build", "0"))
- ; Increment build number and write to INI
- #expr MyAppVersion = MyAppVersion + 1
- #expr WriteIni(SourcePath+"\\version.ini", "Info", "Build", MyAppVersion)
- [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={{6525583A-1BF8-43C9-AF77-59A4813D207E}
- AppName={#MyAppName}
- AppVersion={#MyAppVersion}
- AppVerName={#MyAppName} {#MyAppVersion}
- AppPublisher={#MyAppPublisher}
- AppPublisherURL={#MyAppURL}
- AppSupportURL={#MyAppURL}
- AppUpdatesURL={#MyAppURL}
- AppContact={#MyAppContact}
- AppCopyright={#MyAppPublisher}
- VersionInfoTextVersion=Build {#MyAppVersion}
- DefaultDirName={pf}\{#MyAppPublisher}\Sample Program
- DefaultGroupName={#MyAppPublisher}
- AllowNoIcons=yes
- OutputBaseFilename=setup_r{#MyAppVersion}
- Compression=lzma/ultra64
- SolidCompression=yes
- ShowTasksTreeLines=True
- SetupLogging=yes
- EnableDirDoesntExistWarning=True
- MinVersion=0,5.01sp3
- UsePreviousAppDir=False
- AppendDefaultDirName=False
- OutputDir="..\bin\"
- ChangesEnvironment=True
- CloseApplications=yes
- DisableProgramGroupPage=auto
- PrivilegesRequired=admin
- SetupIconFile="..\resource\logo_fb.ico"
- WizardImageFile="..\resource\wizard.bmp"
- WizardSmallImageFile="..\resource\wizardSmall.bmp"
- InfoBeforeFile="info.txt"
- LicenseFile="license.txt"
- Uninstallable=True
- ArchitecturesInstallIn64BitMode="x64 ia64"
- ArchitecturesAllowed="x64 ia64"
- VersionInfoVersion={#MyAppVersion}
- VersionInfoCompany=company
- VersionInfoDescription=Sample Program
- VersionInfoCopyright=company
- VersionInfoProductName=Sample Program
- VersionInfoProductVersion={#MyAppVersion}
- VersionInfoProductTextVersion=Build {#MyAppVersion}
- InternalCompressLevel=ultra64
- [Registry]
- ; Set environment variable to point to company installation
- Root: "HKLM64"; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "MY_ENV_VARIABLE"; ValueData: "{app}"; Flags: uninsdeletevalue; Components: connect
- ; Append python to PATH if does not already exist
- Root: "HKLM64"; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "PATH"; ValueData: "{olddata};{sd}\Python27\;{sd}\Python27\Scripts\"; Components: connect; Check: NeedsAddPath('{sd}\Python27')
- ; Set environment variable to point to graphviz installation
- Root: "HKLM64"; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "GRAPHVIZ"; ValueData: "{pf32}\GraphViz2.38\bin\"; Flags: uninsdeletevalue; Components: developerResources
- [Languages]
- Name: "english"; MessagesFile: "compiler:Default.isl"
- Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
- Name: "chinese_simplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
- Name: "korean"; MessagesFile: "compiler:Languages\Korean.isl"
- [Files]
- ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
- Source: "..\dependencies\ez_setup.py"; DestDir: "{app}\dependencies"; Flags: ignoreversion; Components: connect
- Source: "..\dependencies\get-pip.py"; DestDir: "{app}\dependencies"; Flags: ignoreversion; Components: connect
- Source: "..\dependencies\python-2.7.6.amd64.msi"; DestDir: "{app}\dependencies"; Flags: ignoreversion; Components: connect
- Source: "..\dependencies\graphviz-2.38.msi"; DestDir: "{app}\dependencies"; Flags: ignoreversion; Components: developerResources
- Source: "..\dependencies\lowdown\*"; DestDir: "{app}\dependencies\lowdown\"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: developerResources; Excludes: "*.pyc"
- Source: "..\..\.eggs\*"; DestDir: "{app}\eggs"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: connect; Excludes: "*.pyc"
- Source: "..\..\build\*"; DestDir: "{app}\build"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: connect; Excludes: "*.pyc"
- Source: "..\..\doc\*"; DestDir: "{app}\doc"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: connect; Excludes: "*.pyc"
- Source: "..\..\event\*"; DestDir: "{app}\event"; Flags: ignoreversion createallsubdirs recursesubdirs; Excludes: "*.pyc"
- Source: "..\..\resource\*"; DestDir: "{app}\resource"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: connect; Excludes: "*.pyc"
- Source: "..\..\installer\*"; DestDir: "{app}\installer"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: developerResources; Excludes: "bin, *.pyc"
- Source: "..\..\source\*"; DestDir: "{app}\source"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: developerResources; Excludes: "*.pyc"
- Source: "..\..\test\*"; DestDir: "{app}\test"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: developerResources; Excludes: "*.pyc"
- Source: "..\..\.gitignore"; DestDir: "{app}"; Flags: ignoreversion; Components: developerResources
- Source: "..\..\company_build.bat"; DestDir: "{app}"; Flags: ignoreversion; Components: developerResources
- Source: "..\..\company_launch.bat"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
- Source: "..\..\company_launch.sh"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
- Source: "..\..\company_launch_standalone.bat"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
- Source: "..\..\LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
- Source: "..\..\logo.icns"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
- Source: "..\..\logo.ico"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
- Source: "..\..\logo_fb.ico"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
- Source: "..\..\MANIFEST.in"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
- Source: "..\..\README.rst"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
- Source: "..\..\setup.cfg"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
- Source: "..\..\setup.py"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
- [Icons]
- Name: "{group}\{#MyAppName}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
- Name: "{group}\{#MyAppName}\{cm:LaunchProgram, {#MyAppName}}"; Filename: "{app}\company_launch_standalone.bat"; IconFilename: "{app}\logo_fb.ico"; Comment: "Launch Sample Program"
- [ThirdParty]
- UseRelativePaths=True
- [Run]
- ; Install Python 2.7.6
- Filename: "msiexec"; Parameters: "/i ""{app}\dependencies\python-2.7.6.amd64.msi"" /qb! ALLUSERS=1 ADDLOCAL=ALL"; Flags: 64bit; Description: "Install Python 2.7.6 AMD64"; MinVersion: 0,6.0; Components: connect; Check: PythonSetup
- ; Install pip and setuptools
- Filename: "{sd}\Python27\python.exe"; Parameters: """{app}\dependencies\get-pip.py"""; Description: "Install pip"; Components: connect; Check: DependenciesSetup('pip')
- Filename: "{sd}\Python27\python.exe"; Parameters: """{app}\dependencies\ez_setup.py"""; Description: "Install setuptools"; Components: connect; Check: DependenciesSetup('setuptools')
- ; Install Python dependencies
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install boto==2.28.0"""; Description: "Install boto 2.28.0"; Components: connect; Check: DependenciesSetup('boto')
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install PySide==1.2.2"""; Description: "Install PySide"; Components: connect; Check: DependenciesSetup('PySide')
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install riffle"""; Description: "Install Riffle"; Components: connect; Check: DependenciesSetup('riffle')
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\easy_install http://www.voidspace.org.uk/downloads/pycrypto26/pycrypto-2.6.win-amd64-py2.7.exe"""; Description: "Install Crypto"; Components: connect; Check: DependenciesSetup('pycrypto')
- ; Install Developer Python dependencies
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install Sphinx"""; Description: "Install Sphinx"; Components: developerResources; Check: DependenciesSetup('Sphinx')
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install sphinx_rtd_theme"""; Description: "Install sphinx_rtd_theme"; Components: developerResources; Check: DependenciesSetup('sphinx_rtd_theme')
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install virtualenv"""; Description: "Install virtualenv"; Components: developerResources; Check: DependenciesSetup('virtualenv')
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install virtualenv-clone"""; Description: "Install virtualenv-clone"; Components: developerResources; Check: DependenciesSetup('virtualenv-clone')
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install virtualenvwrapper"""; Description: "Install virtualenvwrapper"; Components: developerResources; Check: DependenciesSetup('virtualenvwrapper')
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install mock"""; Description: "Install mock"; Components: developerResources; Check: DependenciesSetup('mock')
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install Pillow"""; Description: "Install Pillow"; Components: developerResources; Check: DependenciesSetup('Pillow')
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install pyScss"""; Description: "Install pyScss"; Components: developerResources; Check: DependenciesSetup('pyScss')
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install Pytest"""; Description: "Install Pytest"; Components: developerResources; Check: DependenciesSetup('Pytest')
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install arrow"""; Description: "Install arrow"; Components: developerResources; Check: DependenciesSetup('arrow')
- ; Install Lowdown package for building release notes
- Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\python.exe {app}\lowdown\setup.py install"""; Description: "Install lowdown (company)"; Components: developerResources; Check: DependenciesSetup('lowdown')
- ; Install graphviz for documentation graph generation
- Filename: "msiexec"; Parameters: "/i ""{app}\dependencies\graphviz-2.38.msi"" /qb! ALLUSERS=1 ADDLOCAL=ALL"; Description: "Install graphviz 2.38"; MinVersion: 0,6.0; Components: developerResources;
- ; Open Documentation after installation
- Filename: "{app}\build\doc\html\index.html"; Flags: postinstall shellexec; Description: "Open Sample Program documentation"; Components: connect
- [Components]
- Name: "connect"; Description: "Sample Program"; Types: full compact; Flags: fixed; MinVersion: 0,6.0; Languages: chinese_simplified english japanese korean
- Name: "developerResources"; Description: "Developer Resources"; Types: full; MinVersion: 0,6.0; Languages: chinese_simplified english japanese korean
- [Code]
- // Global variables
- // This function checks the registry for an existing Python 2.7.x installation
- function IsPythonInstalled: boolean;
- begin
- Result := RegKeyExists(HKLM64, 'SOFTWARE\Python\PythonCore\2.7' );
- end;
- // This function checks if Python is installed and brings up user confirmation to automatically install it
- function PythonSetup(): boolean;
- var
- installPythonResult : Boolean;
- check : Boolean;
- begin
- // Check if installer is being run in silent mode and skip all dialogs
- if WizardSilent() then
- begin
- Result := True;
- Exit;
- end;
- check := IsPythonInstalled;
- if not check then
- begin
- installPythonResult := MsgBox('The toolkit requires Python 2.7.6 to be installed! Do you want to have it automatically installed for you?', mbConfirmation, MB_YESNO) = IDYES;
- if not installPythonResult then
- begin
- MsgBox('Python 2.7.6 will not be installed! Remember to install it later manually on your own!', mbInformation, MB_OK);
- Result := False;
- end;
- end;
- Result := True;
- end;
- // This function returns True if Python 2.7 registry key is detected on the system
- function DependenciesSetup(Param: String): Boolean;
- var
- check : Boolean;
- begin
- if WizardSilent() then
- begin
- Result := True;
- Exit;
- end;
- check := IsPythonInstalled;
- if not check then
- begin
- MsgBox('Could not install' + Param + 'because Python 2.7.x was not detected on the system!', mbInformation, MB_OK);
- Result := False;
- end;
- Result := True;
- end;
- // This function will return True if the Param already exists in the system PATH
- function NeedsAddPath(Param: String): Boolean;
- var
- OrigPath: String;
- begin
- if not RegQueryStringValue(HKLM64, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'PATH', OrigPath) then
- begin
- Result := True;
- exit;
- end;
- // look for the path with leading and trailing semicolon; Pos() returns 0 if not found
- Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
- end;
- // Check for working internet connection
- function CheckInternetConnection(Param: String) : Boolean;
- var
- WinHttpReq : Variant;
- begin
- try
- // Create COM object to handle net connection attempt
- WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
- WinHttpReq.Open('GET', Param, false);
- WinHttpReq.Send();
- except
- MsgBox('Could not connect to: ' + Param + '!' + #13#10 + 'Ensure that this computer has a working internet connection!', mbError, MB_OK);
- end;
- // Check for timeout
- if WinHttpReq.Status <> 200 then begin
- MsgBox('Could not connect to' + Param + '! Connection timed out!', mbError, MB_OK);
- Result := False;
- end;
- if Length(WinHttpReq.ResponseText) > 0 then begin
- Result := True;
- end;
- end;
- // This method checks for presence of uninstaller entries in the registry and returns the path to the uninstaller executable.
- function GetUninstallString: String;
- var
- uninstallerPath: String;
- uninstallerString: String;
- begin
- Result := '';
- // Get the uninstallerPath from the registry
- uninstallerPath := ExpandConstant('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{6525583A-1BF8-43C9-AF77-59A4813D207E}_is1');
- uninstallerString := '';
- // Check if uninstaller entries in registry have values in them
- if not RegQueryStringValue(HKLM64, uninstallerPath, 'UninstallString', uninstallerString) then
- RegQueryStringValue(HKCU, uninstallerPath, 'UninstallString', uninstallerString);
- // Return path of uninstaller to run
- Result := uninstallerString;
- end;
- // This method checks if a previous version has been installed
- function PreviousInstallationExists : Boolean;
- begin
- // Check if not equal '<>' to empty string and return result
- Result := (GetUninstallString() <> '');
- end;
- // This Event function runs before setup is initialized
- function InitializeSetup(): Boolean;
- var
- checkNetCxn : Boolean;
- uninstallChoiceResult: Boolean;
- uninstallPath : String;
- iResultCode : Integer;
- previouslyInstalledCheck : Boolean;
- begin
- // Connect to Python package dist server
- checkNetCxn := CheckInternetConnection('https://pypi.python.org/pypi');
- if not checkNetCxn then
- begin
- MsgBox('Please ensure that this computer has a working internet connection and try again!', mbError, MB_OK)
- Result := False;
- Exit;
- end;
- // Now check if previous version was installed
- previouslyInstalledCheck := PreviousInstallationExists;
- if previouslyInstalledCheck then
- begin
- uninstallChoiceResult := MsgBox('A previous installation was detected. Do you want to uninstall the previous version first? (Recommended)', mbInformation, MB_YESNO) = IDYES;
- // If user chooses, uninstall the previous version and wait until it has finished before allowing installation to proceed
- if uninstallChoiceResult then
- begin
- uninstallPath := RemoveQuotes(GetUninstallString());
- Exec(ExpandConstant(uninstallPath), '', '', SW_SHOW, ewWaitUntilTerminated, iResultCode);
- Result := True;
- end
- else
- begin
- Result := True;
- Exit;
- end;
- end
- else
- Result := True;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement