Skip to content

Commit e414dcf

Browse files
authored
Merge pull request #3790 from architecture-building-systems/fix-windows-setup
Fix windows setup
2 parents 1c9b1c9 + a4e9112 commit e414dcf

File tree

3 files changed

+65
-34
lines changed

3 files changed

+65
-34
lines changed

.github/workflows/setup_build.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,17 @@ jobs:
9696
with:
9797
name: setup
9898
path: ${{ github.workspace }}\setup\Output
99-
compression-level: 0
99+
compression-level: 0
100+
101+
- name: Create Release Draft
102+
id: create_release
103+
uses: softprops/action-gh-release@v2
104+
with:
105+
draft: true
106+
name: CityEnergyAnalyst v${{ env.CEA_VERSION }}
107+
tag_name: v${{ env.CEA_VERSION }}
108+
files: ${{ github.workspace }}/setup/Output/*
109+
fail_on_unmatched_files: true
100110

101111
build_mac_dmg:
102112
runs-on: "macos-latest"

cea/config.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import re
1414
import tempfile
1515
from typing import Dict, List, Union, Any, Generator, Tuple, Optional
16+
import warnings
1617

1718
import cea.inputlocator
1819
import cea.plugin
@@ -39,7 +40,15 @@ def __init__(self, config_file: str = CEA_CONFIG):
3940
self.default_config.read(DEFAULT_CONFIG)
4041

4142
self.user_config = configparser.ConfigParser()
42-
self.user_config.read([DEFAULT_CONFIG, config_file])
43+
44+
try:
45+
self.user_config.read([DEFAULT_CONFIG, config_file])
46+
except UnicodeDecodeError as e:
47+
print(e)
48+
# Fallback to default config if user config not readable
49+
warnings.warn(f"Could not read {config_file}, using default config instead. "
50+
f"Please check that the config file is in the correct format or if it has any special characters")
51+
self.user_config.read(DEFAULT_CONFIG)
4352

4453
cea.plugin.add_plugins(self.default_config, self.user_config)
4554

setup/cityenergyanalyst.nsi

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,26 @@ FunctionEnd
7373
;--------------------------------
7474
;Installer Sections
7575

76-
Section "Base Installation" Base_Installation_Section
77-
SectionIn RO # this section is required so user is unable to uncheck
76+
Function .onInstFailed
77+
# Ensure temporary files are cleaned up
78+
DetailPrint "Installation failed, cleaning up temporary files..."
79+
80+
${If} ${FileExists} "$INSTDIR\cityenergyanalyst.tar.gz"
81+
Delete /REBOOTOK "$INSTDIR\cityenergyanalyst.tar.gz"
82+
${EndIf}
83+
84+
${If} ${FileExists} "$INSTDIR\dependencies"
85+
RMDir /r /REBOOTOK "$INSTDIR\dependencies"
86+
${EndIf}
87+
88+
${If} ${FileExists} "$INSTDIR\gui_setup.exe"
89+
Delete /REBOOTOK "$INSTDIR\gui_setup.exe"
90+
${EndIf}
91+
92+
93+
FunctionEnd
94+
95+
Function BaseInstallationSection
7896
SetOutPath "$INSTDIR"
7997

8098
File "cityenergyanalyst.tar.gz"
@@ -100,22 +118,13 @@ Section "Base Installation" Base_Installation_Section
100118
${EndIf}
101119
Delete "$INSTDIR\cityenergyanalyst.tar.gz"
102120

103-
# create cea.config file in the %userprofile% directory by calling `cea --help` and set daysim paths
104-
nsExec::ExecToLog '"$INSTDIR\dependencies\micromamba.exe" run -r "$INSTDIR\dependencies\micromamba" -n cea cea --help'
121+
# Run cea --version to check if installation was successful
122+
nsExec::ExecToLog '"$INSTDIR\dependencies\micromamba.exe" run -r "$INSTDIR\dependencies\micromamba" -n cea cea --version'
105123
Pop $0
106-
DetailPrint '"cea --help" returned $0'
124+
DetailPrint '"cea --version" returned $0'
107125
${If} "$0" != "0"
108126
Abort "Installation failed - see Details"
109127
${EndIf}
110-
#WriteINIStr "$PROFILE\cea.config" radiation daysim-bin-directory "$INSTDIR\Dependencies\Daysim"
111-
112-
# make sure qt.conf has the correct paths
113-
#DetailPrint "Updating qt.conf..."
114-
#${StrRep} $0 "$INSTDIR" "\" "/" # $0 now contains the $INSTDIR with forward slashes instead of backward slashes
115-
#WriteINIStr "$INSTDIR\Dependencies\Python\qt.conf" Paths Prefix "$0/Dependencies/Python/Library"
116-
#WriteINIStr "$INSTDIR\Dependencies\Python\qt.conf" Paths Binaries "$0/Dependencies/Python/Library/bin"
117-
#WriteINIStr "$INSTDIR\Dependencies\Python\qt.conf" Paths Libraries "$0/Dependencies/Python/Library/lib"
118-
#WriteINIStr "$INSTDIR\Dependencies\Python\qt.conf" Paths Headers "$0/Dependencies/Python/Library/include/qt"
119128

120129
# make sure jupyter has access to the ipython kernel
121130
#nsExec::ExecToLog '"$INSTDIR\cea-env-run.bat" python -m ipykernel install --prefix $INSTDIR\Dependencies\Python'
@@ -142,11 +151,9 @@ Section "Base Installation" Base_Installation_Section
142151
# create a shortcut in the $INSTDIR for launching the CEA dashboard
143152
CreateShortcut "$INSTDIR\CEA Dashboard.lnk" "$INSTDIR\dashboard\CityEnergyAnalyst-GUI.exe" "" \
144153
"$INSTDIR\cea-icon.ico" 0 SW_SHOWNORMAL "" "Launch the CEA Dashboard"
154+
FunctionEnd
145155

146-
SectionEnd
147-
148-
Section "Create Start menu shortcuts" Create_Start_Menu_Shortcuts_Section
149-
156+
Function CreateStartMenuShortcutsSection
150157
# create shortcuts in the start menu for launching the CEA console
151158
CreateDirectory '$SMPROGRAMS\${CEA_TITLE}'
152159
CreateShortCut '$SMPROGRAMS\${CEA_TITLE}\CEA Console.lnk' "$WINDIR\System32\cmd.exe" '/K "$INSTDIR\dependencies\cea-env.bat"' \
@@ -158,24 +165,18 @@ Section "Create Start menu shortcuts" Create_Start_Menu_Shortcuts_Section
158165
CreateShortcut "$SMPROGRAMS\${CEA_TITLE}\Uninstall CityEnergy Analyst.lnk" \
159166
"$INSTDIR\Uninstall_CityEnergyAnalyst_${VER}.exe" "" \
160167
"$INSTDIR\Uninstall_CityEnergyAnalyst_${VER}.exe" 0 SW_SHOWNORMAL "" "Uninstall the City Energy Analyst"
168+
FunctionEnd
161169

162-
SectionEnd
163-
164-
Section /o "Create Desktop shortcuts" Create_Desktop_Shortcuts_Section
165-
170+
Function CreateDesktopShortcutsSection
166171
# create shortcuts on the Desktop for launching the CEA console
167172
CreateShortCut '$DESKTOP\CEA Console.lnk' "$WINDIR\System32\cmd.exe" '/K "$INSTDIR\dependencies\cea-env.bat"' \
168173
"$INSTDIR\cea-icon.ico" 0 SW_SHOWNORMAL "" "Launch the CEA Console"
169174

170175
CreateShortcut "$DESKTOP\CEA Dashboard.lnk" "$INSTDIR\dashboard\CityEnergyAnalyst-GUI.exe" "" \
171176
"$INSTDIR\cea-icon.ico" 0 SW_SHOWNORMAL "" "Launch the CEA Dashboard"
177+
FunctionEnd
172178

173-
SectionEnd
174-
175-
;Uninstaller Section
176-
177-
Section "Uninstall"
178-
179+
Function un.UninstallSection
179180
; Delete the shortcuts
180181
Delete /REBOOTOK "$SMPROGRAMS\${CEA_TITLE}\CEA Console.lnk"
181182
Delete /REBOOTOK "$SMPROGRAMS\${CEA_TITLE}\CEA Dashboard.lnk"
@@ -198,10 +199,21 @@ Section "Uninstall"
198199
RMDir /R /REBOOTOK "$INSTDIR\dependencies"
199200

200201
Delete /REBOOTOK "$INSTDIR\Uninstall_CityEnergyAnalyst_${VER}.exe"
202+
FunctionEnd
201203

202-
; Change current working directory so that it can be deleted
203-
; Will only be deleted if the directory is empty
204-
SetOutPath $TEMP
205-
RMDir /REBOOTOK "$INSTDIR"
204+
Section "Base Installation" Base_Installation_Section
205+
SectionIn RO # this section is required so user is unable to uncheck
206+
Call BaseInstallationSection
207+
SectionEnd
208+
209+
Section "Create Start menu shortcuts" Create_Start_Menu_Shortcuts_Section
210+
Call CreateStartMenuShortcutsSection
211+
SectionEnd
206212

213+
Section /o "Create Desktop shortcuts" Create_Desktop_Shortcuts_Section
214+
Call CreateDesktopShortcutsSection
215+
SectionEnd
216+
217+
Section "Uninstall"
218+
Call un.UninstallSection
207219
SectionEnd

0 commit comments

Comments
 (0)