]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/installer/setup/install.nsh
Install complete Python instead of subset. Fixes #7485 and #7405.
[lyx.git] / development / Win32 / packaging / installer / setup / install.nsh
1 /*
2
3 install.nsh
4
5 Installation of program files, dictionaries and external components
6
7 */
8
9 #--------------------------------
10 # Program files
11
12 Var PythonCompileFile
13 Var PythonCompileReturn
14 Var DownloadResult
15
16 Section -ProgramFiles SecProgramFiles
17
18   # Install and register the core LyX files
19   
20   # The macros are defined in filelists.nsh
21   # the parameters are COMMAND DIRECTORY that form command '${COMMAND} "${DIRECTORY}files"  
22   
23   # Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
24   # $PLUGINSDIR is automatically deleted when the installer exits.
25   InitPluginsDir
26   
27   # Binaries
28   SetOutPath "$INSTDIR\bin"
29   !insertmacro FileListLyXBin File "${FILES_LYX}\bin\"
30   !insertmacro FileListQtBin File "${FILES_QT}\bin\"
31   !insertmacro FileListDll File "${FILES_DEPS}\bin\"
32   !insertmacro FileListMSVC File "${FILES_MSVC}\"
33   !insertmacro FileListNetpbmBin File "${FILES_NETPBM}\"
34   !insertmacro FileListDTLBin File "${FILES_DTL}\"
35   !insertmacro FileListDvipostBin File "${FILES_DVIPOST}\"
36   !insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
37   !insertmacro FileListPDFToolsBin File "${FILES_PDFTOOLS}\"
38   !insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
39   
40   # Resources
41   SetOutPath "$INSTDIR"
42   # recursively copy all files under Resources
43   File /r "${FILES_LYX}\Resources"
44   
45   # Python
46   SetOutPath "$INSTDIR"
47   # recursively copy all files under Python
48   File /r "${FILES_PYTHON}"
49   # add MSVC runtimes
50   SetOutPath "$INSTDIR\python"
51   !insertmacro FileListMSVC File "${FILES_MSVC}\"
52   
53   
54   # Compile all Pyton files to byte-code
55   # The user using the scripts may not have write access
56   FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
57   FileWrite $PythonCompileFile "import compileall$\r$\n"
58   FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
59   FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
60   FileClose $PythonCompileFile
61   DetailPrint $(TEXT_CONFIGURE_PYTHON)
62   nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
63   Pop $PythonCompileReturn # Return value
64   Delete "$INSTDIR\compilepy.py"
65   
66   # Components of ImageMagick
67   SetOutPath "$INSTDIR\imagemagick"
68   !insertmacro FileListImageMagick File "${FILES_IMAGEMAGICK}\"
69   !insertmacro FileListMSVC File "${FILES_MSVC}\"
70   
71   # Components of Ghostscript
72   SetOutPath "$INSTDIR\ghostscript"
73   !insertmacro FileListGhostscript File "${FILES_GHOSTSCRIPT}\"
74   !insertmacro FileListMSVC File "${FILES_MSVC}\"
75   
76   # Create uninstaller
77   WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
78
79 SectionEnd
80
81 #--------------------------------
82 # Support code for file downloads
83
84 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
85
86   # Downloads a file
87   
88   # RET = Return value (OK if succesful)
89   # ID = Name of the download in settings.nsh
90   # FILENAME = Location to store file
91   # APPEND = Filename to append to server location in settings.nsh
92
93   # Try first time
94   NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
95   Pop ${RET} # Return value (OK if succesful)
96
97   ${If} ${RET} != "OK"
98     # Download failed, try again (usally we get a different mirror)
99     NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
100     Pop ${RET}
101   ${EndIf}
102
103 !macroend
104
105 #--------------------------------
106 # Extenral components
107
108 Var PathAllUsers
109 Var PathCurrentUser
110
111 !macro EXTERNAL COMPONENT
112
113   # Download/Install the component
114   
115   ${If} $Setup${COMPONENT} == ${TRUE}
116   
117     StrCpy $Path${COMPONENT} "" ;A new one will be installed
118   
119     !ifndef BUNDLESETUP_${COMPONENT}
120       !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
121     !else
122       !insertmacro EXTERNAL_INSTALL ${COMPONENT}
123     !endif
124     
125   ${EndIf}
126
127 !macroend
128
129 !macro EXTERNAL_RUNINSTALLER COMPONENT
130
131   # Run the installer application of the component that does the actual installation.
132
133   install_${COMPONENT}:
134       
135     ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
136     
137     # Updates the path environment variable of the instaler process to the latest system value
138     ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
139     ReadRegStr $PathCurrentUser HKCU "Environment" Path
140     System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
141
142     Call Search${COMPONENT}
143     
144     ${If} $Path${COMPONENT} == ""  
145       MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
146     ${EndIf}
147       
148     Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
149      
150 !macroend
151
152 !macro EXTERNAL_DOWNLOAD COMPONENT
153
154   download_${COMPONENT}:
155
156     !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
157  
158     ${If} $DownloadResult != "OK"
159       # Download failed
160       MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
161       Goto noinstall_${COMPONENT}
162     ${EndIf}
163       
164     !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
165       
166   noinstall_${COMPONENT}:
167
168 !macroend
169
170 !macro EXTERNAL_INSTALL COMPONENT
171
172   # Extract
173   File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
174     
175   !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
176     
177 !macroend
178
179
180 # Sections for external components
181
182 Section -LaTeX ExternalLaTeX
183   !insertmacro EXTERNAL LaTeX
184 SectionEnd
185
186 Function InitExternal
187
188   # Get sizes of external component installers
189   
190   SectionGetSize ${ExternalLaTeX} $SizeLaTeX
191   
192   # Add download size
193   
194   !ifndef BUNDLESETUP_MIKTEX
195     IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
196   !endif
197
198 FunctionEnd