template.nsi 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. ; Definitions will be added above
  2. SetCompressor lzma
  3. RequestExecutionLevel admin
  4. ; Modern UI installer stuff
  5. !include "MUI2.nsh"
  6. !define MUI_ABORTWARNING
  7. !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
  8. ; UI pages
  9. !insertmacro MUI_PAGE_WELCOME
  10. !insertmacro MUI_PAGE_COMPONENTS
  11. !insertmacro MUI_PAGE_DIRECTORY
  12. !insertmacro MUI_PAGE_INSTFILES
  13. !insertmacro MUI_PAGE_FINISH
  14. !insertmacro MUI_LANGUAGE "English"
  15. ; MUI end ------
  16. Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
  17. OutFile "${INSTALLER_NAME}"
  18. InstallDir "$PROGRAMFILES${BITNESS}\${PRODUCT_NAME}"
  19. ShowInstDetails show
  20. Section -SETTINGS
  21. SetOutPath "$INSTDIR"
  22. SetOverwrite ifnewer
  23. SectionEnd
  24. Section "Python ${PY_VERSION}" sec_py
  25. File "python-${PY_VERSION}${ARCH_TAG}.msi"
  26. DetailPrint "Installing Python ${PY_MAJOR_VERSION}, ${BITNESS} bit"
  27. ExecWait 'msiexec /i "$INSTDIR\python-${PY_VERSION}${ARCH_TAG}.msi" \
  28. /qb ALLUSERS=1 TARGETDIR="$COMMONFILES${BITNESS}\Python\${PY_MAJOR_VERSION}"'
  29. Delete $INSTDIR\python-${PY_VERSION}${ARCH_TAG}.msi
  30. SectionEnd
  31. ;PYLAUNCHER_INSTALL
  32. ;------------------
  33. Section "!${PRODUCT_NAME}" sec_app
  34. SectionIn RO
  35. SetShellVarContext all
  36. File ${PRODUCT_ICON}
  37. SetOutPath "$INSTDIR\pkgs"
  38. File /r "pkgs\*.*"
  39. SetOutPath "$INSTDIR"
  40. ;INSTALL_FILES
  41. ;INSTALL_DIRECTORIES
  42. ;INSTALL_SHORTCUTS
  43. ; Byte-compile Python files.
  44. DetailPrint "Byte-compiling Python modules..."
  45. nsExec::ExecToLog 'py -${PY_QUALIFIER} -m compileall -q "$INSTDIR\pkgs"'
  46. WriteUninstaller $INSTDIR\uninstall.exe
  47. ; Add ourselves to Add/remove programs
  48. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  49. "DisplayName" "${PRODUCT_NAME}"
  50. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  51. "UninstallString" '"$INSTDIR\uninstall.exe"'
  52. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  53. "InstallLocation" "$INSTDIR"
  54. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  55. "DisplayIcon" "$INSTDIR\${PRODUCT_ICON}"
  56. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  57. "NoModify" 1
  58. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  59. "NoRepair" 1
  60. SectionEnd
  61. Section "Uninstall"
  62. SetShellVarContext all
  63. Delete $INSTDIR\uninstall.exe
  64. Delete "$INSTDIR\${PRODUCT_ICON}"
  65. RMDir /r "$INSTDIR\pkgs"
  66. ;UNINSTALL_FILES
  67. ;UNINSTALL_DIRECTORIES
  68. ;UNINSTALL_SHORTCUTS
  69. RMDir $INSTDIR
  70. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
  71. SectionEnd
  72. ; Functions
  73. Function .onMouseOverSection
  74. ; Find which section the mouse is over, and set the corresponding description.
  75. FindWindow $R0 "#32770" "" $HWNDPARENT
  76. GetDlgItem $R0 $R0 1043 ; description item (must be added to the UI)
  77. StrCmp $0 ${sec_py} 0 +2
  78. SendMessage $R0 ${WM_SETTEXT} 0 "STR:The Python interpreter. \
  79. This is required for ${PRODUCT_NAME} to run."
  80. ;
  81. ;PYLAUNCHER_HELP
  82. ;------------------
  83. StrCmp $0 ${sec_app} "" +2
  84. SendMessage $R0 ${WM_SETTEXT} 0 "STR:${PRODUCT_NAME}"
  85. FunctionEnd