source: orange/install-scripts/install3.nsi @ 10911:f84e907548ae

Revision 10911:f84e907548ae, 8.5 KB checked in by Ales Erjavec <ales.erjavec@…>, 22 months ago (diff)

Added Orange.egg info directory to the windows install package.

This is required for setuptools based addons.

Line 
1Name "Orange"
2Icon OrangeInstall.ico
3UninstallIcon OrangeInstall.ico
4licensedata license.txt
5licensetext "Acknowledgments and License Agreement"
6
7OutFile ${OUTFILENAME}
8
9!include "LogicLib.nsh"
10
11!ifdef COMPLETE
12    !macro installmodule modulename installfile checkfile
13        ${Unless} ${FileExists} ${checkfile}
14            File ${PARTY}\${installfile}
15            ExecWait $DESKTOP\${installfile}
16            Delete $DESKTOP\${installfile}
17        ${EndUnless}
18    !macroend
19!else
20    Var MissingModules
21    !macro installmodule modulename installfile checkfile
22        ${Unless} ${FileExists} ${checkfile}
23        ${AndUnless} modulename == ""
24            ${If} $MissingModules == ""
25                StrCpy $MissingModules ${modulename}
26            ${Else}
27                StrCpy $MissingModules "$MissingModules, ${modulename}"
28            ${EndIf}
29        ${EndUnless}
30    !macroend
31!endif
32
33!include "${PARTY}\names.inc"
34
35AutoCloseWindow true
36ShowInstDetails nevershow
37
38Var PythonDir
39Var AdminInstall
40Var SITEDIR
41
42Page license
43Page instfiles
44
45!define SHELLFOLDERS \
46  "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
47 
48
49Section Uninstall
50    MessageBox MB_YESNO "Are you sure you want to remove Orange?$\r$\n$\r$\nThis won't remove any 3rd party software possibly installed with Orange, such as Python or Qt,$\r$\n$\r$\nbut make sure you have not left any of your files in Orange's directories!" /SD IDYES IDNO abort
51    RmDir /R "$INSTDIR"
52    ${If} $AdminInstall = 0
53        SetShellVarContext all
54    ${Else}
55        SetShellVarContext current     
56    ${Endif}
57    RmDir /R "$SMPROGRAMS\Orange"
58
59    ReadRegStr $0 HKCU "${SHELLFOLDERS}" AppData
60    StrCmp $0 "" 0 +2
61      ReadRegStr $0 HKLM "${SHELLFOLDERS}" "Common AppData"
62    StrCmp $0 "" +2 0
63      RmDir /R "$0\Orange"
64   
65    ReadRegStr $PythonDir HKLM Software\Python\PythonCore\${NPYVER}\InstallPath ""
66    ${If} $PythonDir != ""
67        DeleteRegKey HKLM "SOFTWARE\Python\PythonCore\${NPYVER}\PythonPath\Orange"
68        DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Orange"
69    ${Else}
70        DeleteRegKey HKCU "SOFTWARE\Python\PythonCore\${NPYVER}\PythonPath\Orange"
71        DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Orange"
72    ${Endif}
73   
74    Delete "$DESKTOP\Orange Canvas.lnk"
75
76    DeleteRegKey HKEY_CLASSES_ROOT ".ows"
77    DeleteRegKey HKEY_CLASSES_ROOT "OrangeCanvas"
78
79    MessageBox MB_OK "Orange has been succesfully removed from your system.$\r$\nPython and other applications need to be removed separately.$\r$\n$\r$\nYou may now continue without rebooting your machine." /SD IDOK
80  abort:
81SectionEnd
82
83
84!macro GetPythonDir
85    ${If} $AdminInstall == 0
86        ReadRegStr $PythonDir HKCU Software\Python\PythonCore\${NPYVER}\InstallPath ""
87        StrCmp $PythonDir "" 0 trim_backslash
88        ReadRegStr $PythonDir HKLM Software\Python\PythonCore\${NPYVER}\InstallPath ""
89        StrCmp $PythonDir "" return
90        MessageBox MB_OK "Please ask the administrator to install Orange$\r$\n(this is because Python was installed by him, too)."
91        Quit
92    ${Else}
93        ReadRegStr $PythonDir HKLM Software\Python\PythonCore\${NPYVER}\InstallPath ""
94        StrCmp $PythonDir "" 0 trim_backslash
95        ReadRegStr $PythonDir HKCU Software\Python\PythonCore\${NPYVER}\InstallPath ""
96        StrCmp $PythonDir "" return
97        StrCpy $AdminInstall 0
98    ${EndIf}
99
100    trim_backslash:
101    StrCpy $0 $PythonDir "" -1
102    ${If} $0 == "\"
103        StrLen $0 $PythonDir
104        IntOp $0 $0 - 1
105        StrCpy $PythonDir $PythonDir $0 0
106    ${EndIf}
107
108    return:
109!macroend
110       
111!ifdef COMPLETE
112
113Section ""
114        StrCmp $PythonDir "" 0 have_python
115
116        SetOutPath $DESKTOP
117        StrCpy $0 ""
118        askpython:
119            MessageBox MB_YESNOCANCEL "Orange installer will first launch installation of Python ${NPYVER}.$\r$\nWould you like it to install automatically?$\r$\n(Press No for Custom installation of Python, Cancel to cancel installation of Orange." /SD IDYES IDYES installsilently IDNO installpython
120                MessageBox MB_YESNO "Orange cannot run without Python.$\r$\nAbort the installation?" IDNO askpython
121                    Quit
122        installsilently:
123            StrCpy $0 "/Qb-"
124        installpython:
125            File ${PARTY}\${NAME_PYTHON}
126            ${If} $AdminInstall == 1
127                ExecWait 'msiexec.exe /i "$DESKTOP\${NAME_PYTHON}" ALLUSERS=1 $0' $0
128            ${Else}
129                ExecWait 'msiexec.exe /i "$DESKTOP\${NAME_PYTHON}" $0' $0
130            ${EndIf}
131            Delete "$DESKTOP\${NAME_PYTHON}"
132       
133            !insertMacro GetPythonDir
134            StrCmp $PythonDir "" 0 have_python
135                MessageBox MB_OK "Python installation failed.$\r$\nOrange installation cannot continue."
136                Quit
137
138        have_python:
139
140        IfFileExists $PythonDir\lib\site-packages\PythonWin have_pythonwin
141            MessageBox MB_YESNO "Do you want to install PythonWin (recommended)?$\r$\n(Orange installation will continue afterwards.)" /SD IDYES IDNO have_pythonwin
142            IfFileExists "$SysDir\${NAME_MFC}" have_mfc
143                SetOutPath $SysDir
144                File ${PARTY}\${NAME_MFC}
145            have_mfc:
146            SetOutPath $DESKTOP
147            File ${PARTY}\${NAME_PYTHONWIN}
148            ExecWait "$DESKTOP\${NAME_PYTHONWIN}"
149            Delete "$DESKTOP\${NAME_PYTHONWIN}"
150           
151        have_pythonwin:
152
153        MessageBox MB_OK "Installation will check for various needed libraries$\r$\nand launch their installers if needed."
154        SetOutPath $DESKTOP
155        !insertMacro modules
156SectionEnd
157!endif
158
159
160Section ""
161    ReadRegStr $0 HKCU "${SHELLFOLDERS}" AppData
162    StrCmp $0 "" 0 +2
163      ReadRegStr $0 HKLM "${SHELLFOLDERS}" "Common AppData"
164    StrCmp $0 "" not_installed_before 0
165
166    IfFileExists "$0\Orange" 0 not_installed_before
167        ask_remove_old:
168        MessageBox MB_YESNOCANCEL "Another version of Orange has been found on the computer.$\r$\nDo you want to keep the existing settings for canvas and widgets?$\r$\n$\r$\nYou can usually safely answer 'Yes'; in case of problems, re-run this installation." /SD IDYES IDYES not_installed_before IDNO remove_old_settings
169            MessageBox MB_YESNO "Abort the installation?" IDNO ask_remove_old
170                Quit
171
172        remove_old_settings:
173        RmDir /R "$0\Orange"
174
175    not_installed_before:
176
177    StrCpy $SITEDIR "$PythonDir\lib\site-packages"
178   
179    IfFileExists "$SITEDIR\orange\orngEnviron.py" 0 no_old_orange_conflict
180        Rename "$SITEDIR\orange" "$SITEDIR\orange-old-backup"
181       
182    no_old_orange_conflict:
183
184    SetOutPath "$SITEDIR\Orange.egg-info"
185    File /r "${ORANGEDIR}.egg-info\*"
186   
187    StrCpy $INSTDIR  "$PythonDir\lib\site-packages\Orange"
188    SetOutPath "$INSTDIR"
189    File /r /x .hg ${ORANGEDIR}\*
190
191    CreateDirectory "$SMPROGRAMS\Orange"
192    CreateShortCut "$SMPROGRAMS\Orange\Orange for Beginners.lnk" "$INSTDIR\doc\ofb\default.htm"
193    CreateShortCut "$SMPROGRAMS\Orange\Orange Modules Reference.lnk" "$INSTDIR\doc\modules\default.htm"
194    CreateShortCut "$SMPROGRAMS\Orange\Orange Reference Guide.lnk" "$INSTDIR\doc\reference\default.htm"
195
196    CreateShortCut "$SMPROGRAMS\Orange\Orange.lnk" "$INSTDIR"
197    CreateShortCut "$SMPROGRAMS\Orange\Uninstall Orange.lnk" "$INSTDIR\uninst.exe"
198
199    SetOutPath $INSTDIR\OrangeCanvas
200    CreateShortCut "$DESKTOP\Orange Canvas.lnk" "$PythonDir\pythonw.exe" "$INSTDIR\OrangeCanvas\orngCanvas.pyw" $INSTDIR\OrangeCanvas\icons\orange.ico 0
201    CreateShortCut "$SMPROGRAMS\Orange\Orange Canvas.lnk" "$PythonDir\pythonw.exe" "$INSTDIR\OrangeCanvas\orngCanvas.pyw" $INSTDIR\OrangeCanvas\icons\orange.ico 0
202
203    WriteRegStr SHELL_CONTEXT "SOFTWARE\Python\PythonCore\${NPYVER}\PythonPath\Orange" "" "$INSTDIR\orng"
204    WriteRegStr SHELL_CONTEXT "Software\Microsoft\Windows\CurrentVersion\Uninstall\Orange" "DisplayName" "Orange (remove only)"
205    WriteRegStr SHELL_CONTEXT "Software\Microsoft\Windows\CurrentVersion\Uninstall\Orange" "UninstallString" '"$INSTDIR\uninst.exe"'
206
207    WriteRegStr HKEY_CLASSES_ROOT ".ows" "" "OrangeCanvas"
208    WriteRegStr HKEY_CLASSES_ROOT "OrangeCanvas\DefaultIcon" "" "$INSTDIR\OrangeCanvas\icons\OrangeOWS.ico"
209    WriteRegStr HKEY_CLASSES_ROOT "OrangeCanvas\Shell\Open\Command\" "" '$PythonDir\python.exe $INSTDIR\OrangeCanvas\orngCanvas.pyw "%1"'
210
211    WriteUninstaller "$INSTDIR\uninst.exe"
212
213SectionEnd 
214
215Function .onInit
216    StrCpy $AdminInstall 1
217
218    UserInfo::GetAccountType
219    Pop $1
220    SetShellVarContext all
221    ${If} $1 != "Admin"
222        SetShellVarContext current
223        StrCpy $AdminInstall 0
224    ${Else}
225        SetShellVarContext all
226        StrCpy $AdminInstall 1
227    ${EndIf}
228
229    !insertMacro GetPythonDir
230
231    !ifndef COMPLETE
232        StrCmp $PythonDir "" 0 have_python
233            MessageBox MB_OK "Please install Python first (www.python.org)$\r$\nor download Orange distribution that includes Python."
234            Quit
235        have_python:
236
237        !insertMacro modules
238        StrCmp $MissingModules "" continueinst
239            MessageBox MB_YESNO "Missing module(s): $MissingModules$\r$\n$\r$\nWithout these modules you can still scripts in Orange, but Orange Canvas will not work without them.$\r$\nYou can download and install them later or obtain the Orange installation that includes them.$\r$\n$\r$\nContinue with installation?" /SD IDYES IDYES continueinst
240            Quit
241
242        continueinst:
243    !endif
244FunctionEnd
245
246
247Function .onInstSuccess
248    MessageBox MB_OK "Orange has been successfully installed." /SD IDOK
249FunctionEnd
Note: See TracBrowser for help on using the repository browser.