installer.nsi 3.82 KB
Newer Older
1 2 3 4 5
;---------------------------------
;General
!include MUI2.nsh

# define name of installer
6
OutFile "Puzzlestream-inst.exe"
7 8
 
# For removing Start Menu shortcut in Windows 7
9
RequestExecutionLevel user
10 11 12 13
 
;--------------------------------
;Folder selection page
!define MUI_PRODUCT "Puzzlestream"
14
InstallDir "$PROFILE\AppData\Local\Programs\${MUI_PRODUCT}"
15 16 17 18

# MUI configuration
!define MUI_COMPONENTSPAGE_SMALLDESC ;No value
!define MUI_INSTFILESPAGE_COLORS "323232 FFFFFF" ;Two colors
19 20
!define MUI_ICON ".\python-windows\Lib\site-packages\puzzlestream\icons\Puzzlestream.ico"
!define MUI_UNICON ".\python-windows\Lib\site-packages\puzzlestream\icons\Puzzlestream.ico"
21
!define MUI_WELCOMEPAGE_TITLE "Puzzlestream installer"
22
!define MUI_WELCOMEPAGE_TEXT "Puzzlestream is an interactive analysis enviroment for Python, providing a fast and simple way from raw data to meaningful results and visualisations. By organising your code in modules, Puzzlestream gives you an instantaneous overview of your project's structure - however complicated it may be. Highly interactive graphical interfaces support you in gaining an intuition for your data, asking the right questions and finding the corresponding answers.$\r$\n$\r$\nPlease click $\"next$\" to proceed with the installation."
23 24
!define MUI_LICENSEPAGE_TEXT_TOP "Please agree to the Puzzlestream license (MIT):"

25
Name "Puzzlestream"
26
!insertmacro MUI_PAGE_WELCOME
27
!insertmacro MUI_PAGE_LICENSE "..\LICENSE.txt"
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
; !insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

# start default section
Section
    # copy files
    SetOutPath "$INSTDIR\python-windows\"
    File /nonfatal /a /r "python-windows\"

    # set the installation directory as the destination for the following actions
    SetOutPath $INSTDIR

    # copy main .exe and main .py
    File "Puzzlestream.exe"
 
    # create the uninstaller
    WriteUninstaller "$INSTDIR\uninstall.exe"

    # create start menu folder
    CreateDirectory "$SMPrograms\Puzzlestream"

    # start menu entry for uninstaller
    CreateShortCut "$SMPROGRAMS\Puzzlestream\Uninstall.lnk" "$INSTDIR\uninstall.exe"

    # start menu entry for software
    CreateShortCut "$SMPROGRAMS\Puzzlestream\Puzzlestream.lnk" "$INSTDIR\Puzzlestream.exe"

    # register
60
    WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Puzzlestream" \
61
                     "DisplayName" "Puzzlestream"
62
    WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Puzzlestream" \
63 64 65 66 67 68 69 70 71 72 73 74 75
                    "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
SectionEnd
 
# uninstaller section start
Section "uninstall"
    # delete the installation directory
    RMDIR /r $INSTDIR
 
    # remove the link from the start menu
    Delete "$SMPROGRAMS\Puzzlestream\Puzzlestream.lnk"
    Delete "$SMPROGRAMS\Puzzlestream\Uninstall.lnk"

    # unregister
76
    DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Puzzlestream"
77 78 79 80 81
# uninstaller section end
SectionEnd

Function .onInit
 
82
  ReadRegStr $R0 HKCU \
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" \
  "UninstallString"
  StrCmp $R0 "" done
 
  MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
  "${PROGRAM_NAME} is already installed. $\n$\nClick `OK` to remove the \
  previous version or `Cancel` to cancel this upgrade." \
  IDOK uninst
  Abort
 
;Run the uninstaller
uninst:
  ClearErrors
  ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
 
  IfErrors no_remove_uninstaller done
    ;You can either use Delete /REBOOTOK in the uninstaller or add some code
    ;here to remove the uninstaller. Use a registry key to check
    ;whether the user has chosen to uninstall. If you are using an uninstaller
    ;components page, make sure all sections are uninstalled.
  no_remove_uninstaller:
 
done:
 
FunctionEnd