Skip to content

Commit e33f37b

Browse files
authored
Merge pull request #38 from nulijiazaizhong/main
Fixed a serious issue – the wrong option
2 parents 7bfd75a + ee9d6de commit e33f37b

File tree

1 file changed

+21
-56
lines changed

1 file changed

+21
-56
lines changed

main.nsi

Lines changed: 21 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ InstallDir "C:\ETS2LA"
1313
!define SOURCEFORGE_URL "https://git.code.sf.net/p/eurotrucksimulator2-laneassist/code"
1414
!define CNB_URL "https://cnb.cool/ETS2LA-CN/Euro-Truck-Simulator-2-Lane-Assist.git"
1515

16-
!define MIRROR_NAME_ALIYUN "Aliyun PyPi Mirror"
17-
!define MIRROR_URL_ALIYUN "https://mirrors.aliyun.com/pypi/simple/"
18-
!define MIRROR_NAME_USTC "USTC PyPi Mirror"
19-
!define MIRROR_URL_USTC "https://mirrors.ustc.edu.cn/pypi/simple/"
2016

2117
# Installer Information
2218
Name "ETS2LA"
@@ -64,8 +60,7 @@ Var RadioGitHub
6460
Var RadioSourceForge
6561
Var RadioCNB
6662
Var PyPiMirrorSelection
67-
Var PyPiUSTCMirrorSelection
68-
Var PyPiNoMirrorSelection
63+
Var pip_mirror_opts
6964

7065
# Shortcuts
7166
Page custom ShortcutSelectionPage ShortcutSelectionPageLeave
@@ -121,25 +116,16 @@ Function SelectMirrorPage
121116
Pop $RadioSourceForge
122117
${NSD_CreateRadioButton} 0 75u 100% 12u "CNB"
123118
Pop $RadioCNB
124-
125-
# PyPI mirror options
126-
${NSD_CreateLabel} 0 95u 100% 12u "PyPI Mirror:"
119+
# Create a label for PyPi mirror selection
120+
${NSD_CreateLabel} 0 95u 100% 12u "PyPi Mirror:"
127121
Pop $0
128-
129-
# Toggle to enable/disable Aliyun mirror
130-
${NSD_CreateRadioButton} 10u 110u 100% 12u "${MIRROR_NAME_ALIYUN}"
122+
# Create a ComboBox for PyPi mirrors
123+
${NSD_CreateComboBox} 0 110u 100% 12u ""
131124
Pop $PyPiMirrorSelection
132-
133-
# Toggle to enable/disable USTC mirror
134-
${NSD_CreateRadioButton} 10u 125u 100% 12u "${MIRROR_NAME_USTC}"
135-
Pop $PyPiUSTCMirrorSelection
136-
137-
# No mirror option
138-
${NSD_CreateRadioButton} 10u 140u 100% 12u "No Mirror (Default PyPI)"
139-
Pop $PyPiNoMirrorSelection
140-
141-
# Set default selection (No Mirror)
142-
${NSD_SetState} $PyPiNoMirrorSelection ${BST_CHECKED}
125+
${NSD_CB_AddString} $PyPiMirrorSelection "Default (pypi.org)"
126+
${NSD_CB_AddString} $PyPiMirrorSelection "Aliyun"
127+
${NSD_CB_AddString} $PyPiMirrorSelection "USTC (China)"
128+
SendMessage $PyPiMirrorSelection ${CB_SETCURSEL} 2 0 # Default to USTC
143129

144130
# Set default selection (GitLab)
145131
${NSD_SetState} $RadioGitLab ${BST_CHECKED}
@@ -169,17 +155,7 @@ Function SelectMirrorPageLeave
169155
${EndIf}
170156
${EndIf}
171157

172-
${NSD_GetState} $PyPiMirrorSelection $0
173-
${If} $0 == ${BST_CHECKED}
174-
StrCpy $PyPi "AliyunMirror"
175-
${Else}
176-
${NSD_GetState} $PyPiUSTCMirrorSelection $0
177-
${If} $0 == ${BST_CHECKED}
178-
StrCpy $PyPi "USTCMirror"
179-
${Else}
180-
StrCpy $PyPi "Pypi"
181-
${EndIf}
182-
${EndIf}
158+
SendMessage $PyPiMirrorSelection ${CB_GETCURSEL} 0 0 $PyPi
183159
FunctionEnd
184160

185161
# Scam page def
@@ -380,35 +356,24 @@ Section "Download" SEC03
380356
${EndIf}
381357

382358
# Install python requirements
383-
${If} $PyPi == "Pypi"
384-
385-
DetailPrint $(PythonRequirements)
386-
nsExec::ExecToLog '"$INSTDIR\system\python\python.exe" -m pip install --verbose --no-warn-script-location --no-cache-dir wheel setuptools poetry requests'
387-
DetailPrint $(PythonTakesLong)
388-
nsExec::ExecToLog '"$INSTDIR\system\python\python.exe" -m pip install --verbose --no-warn-script-location --no-cache-dir -r "$INSTDIR\app\requirements.txt"'
389-
390-
${ElseIf} $PyPi == "AliyunMirror"
391-
392-
DetailPrint $(PythonRequirements)
393-
nsExec::ExecToLog '"$INSTDIR\system\python\python.exe" -m pip install --verbose --no-warn-script-location --index-url ${MIRROR_URL_ALIYUN} --no-cache-dir wheel setuptools poetry requests'
394-
DetailPrint $(PythonTakesLong)
395-
nsExec::ExecToLog '"$INSTDIR\system\python\python.exe" -m pip install --verbose --no-warn-script-location --index-url ${MIRROR_URL_ALIYUN} --no-cache-dir -r "$INSTDIR\app\requirements.txt"'
396-
397-
${ElseIf} $PyPi == "USTCMirror"
398-
399-
DetailPrint $(PythonRequirements)
400-
nsExec::ExecToLog '"$INSTDIR\system\python\python.exe" -m pip install --verbose --no-warn-script-location --index-url ${MIRROR_URL_USTC} --no-cache-dir wheel setuptools poetry requests'
401-
DetailPrint $(PythonTakesLong)
402-
nsExec::ExecToLog '"$INSTDIR\system\python\python.exe" -m pip install --verbose --no-warn-script-location --index-url ${MIRROR_URL_USTC} --no-cache-dir -r "$INSTDIR\app\requirements.txt"'
403-
359+
StrCpy $pip_mirror_opts ""
360+
${If} $PyPi == "1" # Aliyun
361+
StrCpy $pip_mirror_opts '--index-url https://mirrors.aliyun.com/pypi/simple/'
362+
${ElseIf} $PyPi == "2" # USTC
363+
StrCpy $pip_mirror_opts '--index-url https://mirrors.ustc.edu.cn/pypi/simple'
404364
${EndIf}
365+
366+
DetailPrint $(PythonRequirements)
367+
nsExec::ExecToLog '"$INSTDIR\system\python\python.exe" -m pip install --verbose --no-warn-script-location $pip_mirror_opts --no-cache-dir wheel setuptools poetry requests'
368+
DetailPrint $(PythonTakesLong)
369+
nsExec::ExecToLog '"$INSTDIR\system\python\python.exe" -m pip install --verbose --no-warn-script-location $pip_mirror_opts --no-cache-dir -r "$INSTDIR\app\requirements.txt"'
405370
SectionEnd
406371

407372
Section "Executables" SEC04
408373
SetOutPath "$INSTDIR"
409374
File /r "executables\*.*"
410375
File /r "executables\*"
411-
376+
412377
SetOutPath "$INSTDIR\system"
413378
File /r "img\favicon.ico"
414379

0 commit comments

Comments
 (0)