Skip to content

Commit 31c6b0d

Browse files
committed
Update EnergyPlus installation to allow installing in Buildings containing version number (maint_10.0.x)
This integrates changes from #4544
1 parent 6a51a71 commit 31c6b0d

File tree

1 file changed

+32
-24
lines changed
  • Buildings/Resources/src/ThermalZones/EnergyPlus_9_6_0

1 file changed

+32
-24
lines changed

Buildings/Resources/src/ThermalZones/EnergyPlus_9_6_0/install.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
###########################################################################
2121
# List of all spawn versions and commits that are supported
2222
# by the Buildings library
23+
# build_type is either custom or builds
2324
spawn_dists = [
24-
{"version": "0.4.3",
25-
"commit": "7048a72798"}
25+
{"version": "0.5.0",
26+
"commit": "ab07bde9bb",
27+
"build_type": "custom"}
2628
]
2729
###########################################################################
2830

@@ -33,7 +35,7 @@ def log(msg):
3335
def get_bin_directory():
3436
file_path = os.path.dirname(os.path.realpath(__file__))
3537
return os.path.abspath(
36-
os.path.join(file_path, "..", "..", "..", "..", "Resources", "bin")
38+
os.path.join(file_path, os.pardir, os.pardir, os.pardir, os.pardir, "Resources", "bin")
3739
)
3840

3941

@@ -136,10 +138,11 @@ def replace_table_in_mo(html, varType, moFile, spawn_dir):
136138

137139
mo_name = os.path.join(
138140
os.path.dirname(os.path.realpath(__file__)),
139-
"..",
140-
"..",
141-
"..",
142-
"..",
141+
os.pardir,
142+
os.pardir,
143+
os.pardir,
144+
os.pardir,
145+
"Obsolete",
143146
"ThermalZones",
144147
"EnergyPlus_{}".format(energyPlus_version_dash),
145148
moFile,
@@ -174,8 +177,8 @@ def _getEnergyPlusVersion(spawn_dir):
174177
spawn_name = "spawn-{}-{}".format(version, commit[0:10])
175178
idd = os.path.abspath( \
176179
os.path.join(__file__, \
177-
os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, \
178-
"Buildings", "Resources", "bin", spawn_dir, "linux64", "etc", "Energy+.idd"))
180+
os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, \
181+
"Resources", "bin", spawn_dir, "linux64", "etc", "Energy+.idd"))
179182

180183
prefix="!IDD_Version "
181184
with open(idd, 'r') as f:
@@ -187,31 +190,34 @@ def _getEnergyPlusVersion(spawn_dir):
187190

188191
raise ValueError("Failed to find EnergyPlus version.")
189192

190-
def update_version_in_modelica_files(spawn_dir, spawn_exe):
193+
def update_version_in_modelica_files(spawn_dir, spawn_exe, build_type):
191194
import os
192195
import re
193196

194197
energyPlus_version = _getEnergyPlusVersion(spawn_dir)
195198
ep_package = "EnergyPlus_{}".format(energyPlus_version).replace('.', '_')
196199

197200
for rel_file in [\
198-
os.path.join("Buildings", "ThermalZones", ep_package, "Building.mo"),
199-
os.path.join("Buildings", "ThermalZones", ep_package, "package.mo"),
200-
os.path.join("Buildings", "ThermalZones", ep_package, "UsersGuide.mo"),
201-
os.path.join("Buildings", "Resources", "Scripts", "travis", "pyfmi", "runSpawnFromOtherDirectory.py")
201+
os.path.join("Obsolete", "ThermalZones", ep_package, "Building.mo"),
202+
os.path.join("Obsolete", "ThermalZones", ep_package, "package.mo"),
203+
os.path.join("Obsolete", "ThermalZones", ep_package, "UsersGuide.mo"),
204+
os.path.join("Resources", "Scripts", "travis", "pyfmi", "runSpawnFromOtherDirectory.py")
202205
]:
203206
# Path to Building.mo
204207
abs_file = os.path.abspath( \
205208
os.path.join(__file__, \
206-
os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, \
209+
os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, \
207210
rel_file))
208211

209-
# Replace the string "spawn-0.2.0-d7f1e095f3" with the current version
210212
with open (abs_file, 'r' ) as f:
211213
content = f.read()
212-
content = re.sub(r"spawn-\d+.\d+.\d+-.{10}", "{}".format(spawn_exe), content)
213-
content = re.sub(r"Spawn-light-\d+.\d+.\d+-.{10}", "{}".format(spawn_dir), content)
214-
content = re.sub(r"EnergyPlus \d+.\d+.\d+", "EnergyPlus {}".format(energyPlus_version), content)
214+
215+
# Replace spawn.s3.amazonaws.com/builds/ or spawn.s3.amazonaws.com/custom/
216+
content = re.sub(r"spawn\.s3\.amazonaws\.com/[a-zA-Z]+/", f"spawn.s3.amazonaws.com/{build_type}/", content)
217+
# Replace the string "spawn-0.2.0-d7f1e095f3" with the current version
218+
content = re.sub(r"spawn-\d+.\d+.\d+-.{10}", spawn_exe, content)
219+
content = re.sub(r"Spawn-light-\d+.\d+.\d+-.{10}", spawn_dir, content)
220+
content = re.sub(r"EnergyPlus \d+.\d+.\d+", f"EnergyPlus {energyPlus_version}", content)
215221

216222
with open(abs_file, 'w' ) as f:
217223
f.write(content)
@@ -249,7 +255,7 @@ def update_actuator_output_tables(spawn_dir, spawn_exe):
249255
# os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, ".git"))
250256
# repo = Repo(git_folder)
251257
#
252-
# # Get the old Spawn executuables
258+
# # Get the old Spawn executables
253259
# for file in glob.glob(os.path.join("Buildings", "Resources", "bin", "**/spawn-?.?.?-*"), recursive=True):
254260
# if spawn_exe in file:
255261
# # Add to git
@@ -288,17 +294,18 @@ def update_actuator_output_tables(spawn_dir, spawn_exe):
288294
on_windows = "Windows" in platform.system()
289295
install_linux = on_linux or not args.binaries_for_os_only
290296
install_windows = on_windows or not args.binaries_for_os_only
291-
update_mo_files = on_linux and not args.binaries_for_os_only
297+
update_mo_files = on_linux
292298

293299
# Build list of distributions
294300
dists = list()
295301
for spawn_dist in spawn_dists:
296302
version = spawn_dist['version']
297303
commit = spawn_dist['commit']
304+
build_type = spawn_dist['build_type']
298305
if install_linux:
299306
dists.append(
300307
{
301-
"src": "https://spawn.s3.amazonaws.com/builds/Spawn-light-{}-{}-Linux.tar.gz".format(version, commit[0:10]),
308+
"src": "https://spawn.s3.amazonaws.com/{}/Spawn-light-{}-{}-Linux.tar.gz".format(build_type, version, commit[0:10]),
302309
"des": "Spawn-light-{}-{}/linux64".format(version, commit[0:10]),
303310
"spawn_dir": "Spawn-light-{}-{}".format(version, commit[0:10]),
304311
"spawn_exe": "spawn-{}-{}".format(version, commit[0:10]),
@@ -307,7 +314,7 @@ def update_actuator_output_tables(spawn_dir, spawn_exe):
307314
if install_windows:
308315
dists.append(
309316
{
310-
"src": "https://spawn.s3.amazonaws.com/builds/Spawn-light-{}-{}-win64.zip".format(version, commit[0:10]),
317+
"src": "https://spawn.s3.amazonaws.com/{}/Spawn-light-{}-{}-win64.zip".format(build_type, version, commit[0:10]),
311318
"des": "Spawn-light-{}-{}/win64".format(version, commit[0:10]),
312319
"spawn_exe": "spawn-{}-{}".format(version, commit[0:10])
313320
}
@@ -326,7 +333,8 @@ def update_actuator_output_tables(spawn_dir, spawn_exe):
326333
print("Updating Spawn version in Modelica files.")
327334
update_version_in_modelica_files(
328335
spawn_dir = dist["spawn_dir"],
329-
spawn_exe = dist["spawn_exe"])
336+
spawn_exe = dist["spawn_exe"],
337+
build_type = build_type)
330338
# Update the table with supported output variables and actuator names
331339
if update_mo_files and 'linux' in dist['des']:
332340
print("Updating actuator and output tables.")

0 commit comments

Comments
 (0)