1
+ /*
2
+
3
+ WinPython launcher template script
4
+
5
+ Copyright © 2012 Pierre Raybaut
6
+ Licensed under the terms of the MIT License
7
+ (see winpython/__init__.py for details)
8
+
9
+ */
10
+
11
+ ; ================================================================
12
+ ; These lines are automatically replaced when creating launchers:
13
+ ; (see winpython/make.py)
14
+ !addincludedir " "
15
+
16
+ !define COMMAND " "
17
+ !define PARAMETERS " "
18
+ !define WORKDIR " "
19
+ !define PREPATH " "
20
+ !define POSTPATH " "
21
+ !define SETTINGSDIR " "
22
+ !define SETTINGSNAME " "
23
+
24
+ ; prefered command (if it is a file)
25
+ !define BETTERCOMMAND " "
26
+ !define BETTERWORKDIR " "
27
+ !define BETTERPARAMETERS " "
28
+
29
+ Icon " "
30
+ OutFile " "
31
+ ; ================================================================
32
+
33
+ # Standard NSIS plugins
34
+ !include " WordFunc.nsh"
35
+ !include " FileFunc.nsh"
36
+ !include " TextReplace.nsh"
37
+
38
+ # Custom NSIS plugins
39
+ !include " ReplaceInFileWithTextReplace.nsh"
40
+ !include " EnumIni.nsh"
41
+
42
+ SilentInstall silent
43
+ AutoCloseWindow true
44
+ ShowInstDetails nevershow
45
+ RequestExecutionLevel user
46
+
47
+ Section " "
48
+ Call Execute
49
+ SectionEnd
50
+
51
+ Function Execute
52
+ ; prefered command (if it is a file)
53
+ StrCmp " ${BETTERCOMMAND}" " " no_better_workdir
54
+ StrCpy $R8 " ${BETTERCOMMAND}"
55
+ IfFileExists $R8 do_better_workdircheck
56
+ Goto no_better_workdir
57
+
58
+ do_better_workdircheck:
59
+ StrCpy $R8 " ${BETTERWORKDIR}"
60
+ IfFileExists $R8 do_better_workdir
61
+ Goto no_better_workdir
62
+
63
+ do_better_workdir:
64
+ StrCmp ${BETTERWORKDIR} " " 0 betterworkdir
65
+ System::Call " kernel32::GetCurrentDirectory(i ${NSIS_MAX_STRLEN}, t .r0)"
66
+ SetOutPath $0
67
+ Goto end_workdir
68
+ betterworkdir:
69
+ SetOutPath " ${BETTERWORKDIR}"
70
+ Goto end_workdir
71
+
72
+ no_better_workdir:
73
+ ; normal workdir
74
+ StrCmp ${WORKDIR} " " 0 workdir
75
+ System::Call " kernel32::GetCurrentDirectory(i ${NSIS_MAX_STRLEN}, t .r0)"
76
+ SetOutPath $0
77
+ Goto end_workdir
78
+ workdir:
79
+ SetOutPath " ${WORKDIR}"
80
+ end_workdir:
81
+
82
+ ; ================================================================
83
+ ; Settings directory HOME (will affect $PROFILE)
84
+ IfFileExists " $EXEDIR\settings\*.*" 0 end_settings
85
+ System::Call ' Kernel32::SetEnvironmentVariableA(t, t) i("HOME", "$EXEDIR\settings").r0'
86
+ StrCmp " ${SETTINGSDIR}" " " end_settings
87
+ CreateDirectory " $EXEDIR\settings\${SETTINGSDIR}"
88
+
89
+ end_settings:
90
+ ; ================================================================
91
+
92
+
93
+ ; WinPython settings
94
+ IfFileExists " $EXEDIR\settings\*.*" 0 winpython_settings_profile
95
+ StrCpy $R6 " $EXEDIR\settings\winpython.ini"
96
+ Goto winpython_settings_continue
97
+ winpython_settings_profile:
98
+ StrCpy $R6 " $PROFILE\winpython.ini"
99
+ winpython_settings_continue:
100
+ IfFileExists $R6 winpython_settings_done
101
+ ClearErrors
102
+ FileOpen $0 $R6 w
103
+ IfErrors winpython_settings_done
104
+ FileWrite $0 " [debug]$\r$\n state = disabled"
105
+ FileWrite $0 " $\r$\n "
106
+ FileWrite $0 " $\r$\n [environment]"
107
+ FileWrite $0 " $\r$\n ## <?> Uncomment lines to override environment variables"
108
+ FileWrite $0 " $\r$\n #PATH = "
109
+ FileWrite $0 " $\r$\n #PYTHONPATH = "
110
+ FileWrite $0 " $\r$\n #PYTHONSTARTUP = "
111
+ FileClose $0
112
+ winpython_settings_done:
113
+
114
+
115
+ ; Debug state
116
+ IfFileExists $R6 0 no_debug
117
+ ReadINIStr $R7 $R6 " debug" " state"
118
+ StrCmp $R7 " " no_debug
119
+ StrCmp $R7 " disabled" no_debug
120
+ StrCpy $R7 " enabled"
121
+ System::Call ' Kernel32::SetEnvironmentVariableA(t, t) i("WINPYDEBUG", "True").r0'
122
+ no_debug:
123
+
124
+
125
+ ; ================================================================
126
+ ; NO PATH Environment variables
127
+ ReadEnvStr $R0 " PATH"
128
+
129
+ ; ================================================================
130
+
131
+
132
+ ; Command line parameters
133
+ ${GetParameters} $R1
134
+ StrCmp " ${PARAMETERS}" " " end_param 0
135
+ StrCpy $R1 " ${PARAMETERS} $R1"
136
+ end_param:
137
+
138
+ ; prefered command (if it is a file)
139
+ StrCmp " ${BETTERCOMMAND}" " " no_better_command
140
+ StrCpy $R8 " ${BETTERCOMMAND}"
141
+ IfFileExists $R8 do_better_command
142
+ Goto no_better_command
143
+
144
+ do_better_command:
145
+ Exec ' "${BETTERCOMMAND}" $R1'
146
+ Goto end_of_command
147
+
148
+ no_better_command:
149
+ Exec ' "${COMMAND}" $R1'
150
+
151
+ end_of_command:
152
+ FunctionEnd
0 commit comments