!define PRODUCT_NAME "[[ib.appname]]" !define PRODUCT_VERSION "[[ib.version]]" !define PY_VERSION "[[ib.py_version]]" !define PY_MAJOR_VERSION "[[ib.py_major_version]]" !define PY_QUALIFIER "[[ib.py_qualifier]]" !define BITNESS "[[ib.py_bitness]]" !define ARCH_TAG "[[arch_tag]]" !define INSTALLER_NAME "[[ib.installer_name]]" !define PRODUCT_ICON "[[icon]]" SetCompressor lzma RequestExecutionLevel admin [% block modernui %] ; Modern UI installer stuff !include "MUI2.nsh" !define MUI_ABORTWARNING !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" ; UI pages !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_LANGUAGE "English" [% endblock modernui %] Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "${INSTALLER_NAME}" InstallDir "$PROGRAMFILES${BITNESS}\${PRODUCT_NAME}" ShowInstDetails show [% block sections %] Section -SETTINGS SetOutPath "$INSTDIR" SetOverwrite ifnewer SectionEnd Section "Python ${PY_VERSION}" sec_py File "python-${PY_VERSION}${ARCH_TAG}.msi" DetailPrint "Installing Python ${PY_MAJOR_VERSION}, ${BITNESS} bit" ExecWait 'msiexec /i "$INSTDIR\python-${PY_VERSION}${ARCH_TAG}.msi" \ /qb ALLUSERS=1 TARGETDIR="$COMMONFILES${BITNESS}\Python\${PY_MAJOR_VERSION}"' Delete $INSTDIR\python-${PY_VERSION}${ARCH_TAG}.msi SectionEnd Section "!${PRODUCT_NAME}" sec_app SectionIn RO SetShellVarContext all File ${PRODUCT_ICON} SetOutPath "$INSTDIR\pkgs" File /r "pkgs\*.*" SetOutPath "$INSTDIR" ; Install files [% for destination, group in grouped_files %] SetOutPath "[[destination]]" [% for file in group %] File "[[ file ]]" [% endfor %] [% endfor %] ; Install directories [% for dir, destination in ib.install_dirs %] SetOutPath "[[ pjoin(destination, dir) ]]" File /r "[[dir]]\*.*" [% endfor %] [% block install_shortcuts %] ; Install shortcuts ; The output path becomes the working directory for shortcuts SetOutPath "%HOMEDRIVE%\%HOMEPATH%" [% if single_shortcut %] [% for scname, sc in ib.shortcuts.items() %] CreateShortCut "$SMPROGRAMS\[[scname]].lnk" "[[sc['target'] ]]" \ '[[ sc['parameters'] ]]' "$INSTDIR\[[ sc['icon'] ]]" [% endfor %] [% else %] [# Multiple shortcuts: create a directory for them #] CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}" [% for scname, sc in ib.shortcuts.items() %] CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\[[scname]].lnk" "[[sc['target'] ]]" \ '[[ sc['parameters'] ]]' "$INSTDIR\[[ sc['icon'] ]]" [% endfor %] [% endif %] SetOutPath "$INSTDIR" [% endblock install_shortcuts %] ; Byte-compile Python files. DetailPrint "Byte-compiling Python modules..." nsExec::ExecToLog 'py -${PY_QUALIFIER} -m compileall -q "$INSTDIR\pkgs"' WriteUninstaller $INSTDIR\uninstall.exe ; Add ourselves to Add/remove programs WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ "DisplayName" "${PRODUCT_NAME}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ "InstallLocation" "$INSTDIR" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ "DisplayIcon" "$INSTDIR\${PRODUCT_ICON}" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ "NoRepair" 1 SectionEnd Section "Uninstall" SetShellVarContext all Delete $INSTDIR\uninstall.exe Delete "$INSTDIR\${PRODUCT_ICON}" RMDir /r "$INSTDIR\pkgs" ; Uninstall files [% for file, destination in ib.install_files %] Delete "[[pjoin(destination, file)]]" [% endfor %] ; Uninstall directories [% for dir, destination in ib.install_dirs %] RMDir /r "[[pjoin(destination, dir)]]" [% endfor %] [% block uninstall_shortcuts %] ; Uninstall shortcuts [% if single_shortcut %] [% for scname in ib.shortcuts %] Delete "$SMPROGRAMS\[[scname]].lnk" [% endfor %] [% else %] RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}" [% endif %] [% endblock uninstall_shortcuts %] RMDir $INSTDIR DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" SectionEnd [% endblock sections %] ; Functions Function .onMouseOverSection ; Find which section the mouse is over, and set the corresponding description. FindWindow $R0 "#32770" "" $HWNDPARENT GetDlgItem $R0 $R0 1043 ; description item (must be added to the UI) [% block mouseover_messages %] StrCmp $0 ${sec_py} 0 +2 SendMessage $R0 ${WM_SETTEXT} 0 "STR:The Python interpreter. \ This is required for ${PRODUCT_NAME} to run." StrCmp $0 ${sec_app} "" +2 SendMessage $R0 ${WM_SETTEXT} 0 "STR:${PRODUCT_NAME}" [% endblock mouseover_messages %] FunctionEnd