-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
140 lines (127 loc) · 5.49 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import setuptools
from os import path
from setuptools.command.install import install
import accim
class PostInstallCommand(install):
"""Post-installation for installation mode."""
messages = []
def run(self):
install.run(self)
# PUT YOUR POST-INSTALL SCRIPT HERE or CALL A FUNCTION
import os
import shutil
# Creating a dictionary with IDD paths, IDD backups paths and the first line to modify
dict_lines = {
'EnergyPlus 23.2.0': [r"C:\EnergyPlusV23-2-0\Energy+.idd", r"C:\EnergyPlusV23-2-0\Energy+_backup.idd", 84284],
'EnergyPlus 23.1.0': [r"C:\EnergyPlusV23-1-0\Energy+.idd", r"C:\EnergyPlusV23-1-0\Energy+_backup.idd", 83101],
'EnergyPlus 22.2.0': [r"C:\EnergyPlusV22-2-0\Energy+.idd", r"C:\EnergyPlusV22-2-0\Energy+_backup.idd", 82643],
'EnergyPlus 22.1.0': [r"C:\EnergyPlusV22-1-0\Energy+.idd", r"C:\EnergyPlusV22-1-0\Energy+_backup.idd", 81925],
'EnergyPlus 9.6.0': [r"C:\EnergyPlusV9-6-0\Energy+.idd", r"C:\EnergyPlusV9-6-0\Energy+_backup.idd", 81798],
'EnergyPlus 9.5.0': [r"C:\EnergyPlusV9-5-0\Energy+.idd", r"C:\EnergyPlusV9-5-0\Energy+_backup.idd", 80493],
'EnergyPlus 9.4.0': [r"C:\EnergyPlusV9-4-0\Energy+.idd", r"C:\EnergyPlusV9-4-0\Energy+_backup.idd", 80526],
'EnergyPlus 9.3.0': [r"C:\EnergyPlusV9-3-0\Energy+.idd", r"C:\EnergyPlusV9-3-0\Energy+_backup.idd", 80397],
'EnergyPlus 9.2.0': [r"C:\EnergyPlusV9-2-0\Energy+.idd", r"C:\EnergyPlusV9-2-0\Energy+_backup.idd", 79641],
'EnergyPlus 9.1.0': [r"C:\EnergyPlusV9-1-0\Energy+.idd", r"C:\EnergyPlusV9-1-0\Energy+_backup.idd", 79116],
'EnergyPlus 9.0.0': [r"C:\EnergyPlusV9-0-0\Energy+.idd", r"C:\EnergyPlusV9-0-0\Energy+_backup.idd", 78635],
}
new_lines_no = 7500
# global messages
# messages = []
# Iterating through EnergyPlus versions
for i in dict_lines:
# Renaming the original IDD file to keep it as a backup
try:
os.rename(dict_lines[i][0], dict_lines[i][1])
except FileExistsError:
message = f'The file Energy+_backup.idd already exists, therefore this script has already been run for {i}.'
print(message)
PostInstallCommand.messages.append(message)
os.remove(dict_lines[i][0])
# os.rename(dict_lines[i][1], dict_lines[i][0])
shutil.copy(dict_lines[i][1], dict_lines[i][0])
# continue
except FileNotFoundError:
message = f'The file Energy+.idd has not been found, therefore {i} is not installed at default path.'
print(message)
PostInstallCommand.messages.append(message)
continue
# Reading the content of the IDD
with open(dict_lines[i][1], 'r') as file:
data = file.readlines()
# Making amendments in variable data
data[dict_lines[i][2]] = data[dict_lines[i][2]].replace(';', ',')
for j in range(503, new_lines_no + 1):
if j == 503:
line = dict_lines[i][2] + 1
if j == new_lines_no:
data.insert(line, f'A{j};\n')
else:
data.insert(line, f'A{j},\n')
line = line + 1
# Overwriting the IDD with the amendments in variable data
with open(dict_lines[i][0], 'w') as file:
file.writelines(data)
message = f"{i}'s IDD has been correctly modified. {new_lines_no} lines have been added to the object EnergyManagementSystem:Program."
print(message)
PostInstallCommand.messages.append(message)
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setuptools.setup(
name='accim',
version=accim.__version__,
description='Transforms PMV-based into adaptive setpoint temperature EnergyPlus building energy models',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/dsanchez-garcia/accim',
author='Daniel Sánchez-García',
author_email='[email protected]',
license='MIT License',
classifiers=[
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Topic :: Scientific/Engineering'
],
packages=setuptools.find_packages(),
package_data={
'': [
'*.csv',
'*.idf',
'*.epw',
'*.eso',
'*.jpg',
'*.png',
'*.xlsx',
'*.xls',
'*.ipynb'
]
},
python_requires='<3.10',
install_requires=[
'scikit-learn',
'eppy>=0.5.63',
'pycountry',
# 'geopy',
'matplotlib<=3.7',
'pandas',
'datapackage',
'unidecode',
# 'shutil',
# 'glob'
],
# scripts=['bin/addAccis.py'],
keywords=[
'adaptive thermal comfort',
'building energy model',
'building performance simulation',
'energy efficiency'
],
cmdclass={
'install': PostInstallCommand
}
)
# print('IDD modifications:')
# print(PostInstallCommand.messages, sep='\n')