This repository has been archived by the owner on Dec 14, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
MakeDistro.py
371 lines (294 loc) · 17.5 KB
/
MakeDistro.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
from __future__ import print_function
import subprocess,os,shutil,sys
if not os.path.exists('_deps'):
os.mkdir('_deps')
def InstallPrereqs():
""" Get the requirements for CoolProp """
#Collect the source for Cython and put in _deps/cython-master
import urllib,zipfile
print('getting cython sources')
urllib.urlretrieve('https://github.com/cython/cython/archive/master.zip', filename = 'master.zip')
with zipfile.ZipFile('master.zip', 'r') as myzip:
myzip.extractall(path='_deps')
os.remove('master.zip')
for python_install in PYTHONVERSIONS:
for cwd in ['_deps/cython-master']:
print(subprocess.check_output([python_install, 'setup.py', 'install'], cwd = cwd))
def PYPI():
path_32bit = "c:\\Miniconda32bit\\Scripts\\"
path_64bit = 'c:\\Miniconda\\Scripts\\'
envs = ['py27','py33','py34']
# Build all the wheels
for env in envs:
for path in [path_64bit, path_32bit]:
# Actually build the wheel now
subprocess.check_call(path+'activate '+env+' '+'&& python --version && python setup.py bdist_wheel upload',cwd=os.path.join('wrappers','Python'),stdout = sys.stdout, shell = True)
# If we get this far, all the wheels built
subprocess.call(['python','setup.py','sdist','upload'],cwd=os.path.join('wrappers','Python'))
def Source():
print(subprocess.check_output(['python','setup.py','sdist','--dist-dir=../../dist_temp/Python'],shell=True,cwd=os.path.join('wrappers','Python')))
def DLL_and_Excel():
print('DLL and Excel')
""" Build a DLL using __stdcall calling convention """
subprocess.check_output(['BuildDLL'],shell=True,cwd=os.path.join('wrappers','Excel'))
subprocess.check_output(['BuildDLLx64'],shell=True,cwd=os.path.join('wrappers','Excel'))
#Collect the zip file and p
try:
os.makedirs(os.path.join('dist_temp','Excel and DLL'))
except os.error:
pass
shutil.copy2(os.path.join('CoolProp','CoolProp.h'),os.path.join('dist_temp','Excel and DLL','CoolProp.h'))
shutil.copy2(os.path.join('wrappers','Excel','CoolProp.dll'),os.path.join('dist_temp','Excel and DLL','CoolProp.dll'))
shutil.copy2(os.path.join('wrappers','Excel','CoolProp_x64.dll'),os.path.join('dist_temp','Excel and DLL','CoolProp_x64.dll'))
shutil.copy2(os.path.join('wrappers','Excel','CoolProp.xlam'),os.path.join('dist_temp','Excel and DLL','CoolProp.xlam'))
shutil.copy2(os.path.join('wrappers','Excel','CoolProp.xla'),os.path.join('dist_temp','Excel and DLL','CoolProp.xla'))
shutil.copy2(os.path.join('wrappers','Excel','TestExcel.xlsx'),os.path.join('dist_temp','Excel and DLL','TestExcel.xlsx'))
shutil.copy2(os.path.join('wrappers','Excel','README.rst'),os.path.join('dist_temp','Excel and DLL','README.rst'))
def Octave():
print('Octave')
try:
os.makedirs(os.path.join('dist_temp','Octave'))
os.makedirs(os.path.join('dist_temp','Octave','3.6.4'))
except os.error: pass
subprocess.check_output(['OctaveBuilder.bat'],shell=True,cwd=os.path.join('wrappers','Octave'))
shutil.copy2(os.path.join('wrappers','Octave','3.6.4','CoolProp.oct'),os.path.join('dist_temp','Octave','3.6.4','CoolProp.oct'))
shutil.copy2(os.path.join('wrappers','Octave','example.m'),os.path.join('dist_temp','Octave','example.m'))
shutil.copy2(os.path.join('wrappers','Octave','README.rst'),os.path.join('dist_temp','Octave','README.rst'))
def Csharp():
print('C#')
try:
os.makedirs(os.path.join('dist_temp','C#'))
except os.error: pass
subprocess.check_output(['BuildCsharpDLL.bat'],shell=True,cwd=os.path.join('wrappers','C#'))
shutil.copy2(os.path.join('wrappers','C#','readme.txt'),os.path.join('dist_temp','C#','readme.txt'))
shutil.copy2(os.path.join('wrappers','C#','Csharp.7z'),os.path.join('dist_temp','C#','Csharp.7z'))
def MATLAB():
print('MATLAB')
try:
os.makedirs(os.path.join('dist_temp','MATLAB'))
except os.error: pass
process = subprocess.Popen(['C:\\MATLAB_32bit\\bin\\matlab','-wait','-nodesktop','-nosplash','-nojvm','-r','"MATLABBuilder; quit"'],shell=True,cwd=os.path.join('wrappers','MATLAB'))
process.wait()
process = subprocess.Popen(['matlab','-nojvm','-nodesktop','-nosplash','-wait','-r','"MATLABBuilder; quit"'],shell=True,cwd=os.path.join('wrappers','MATLAB'))
process.wait()
shutil.copy2(os.path.join('wrappers','MATLAB','PropsSI.mexw32'),os.path.join('dist_temp','MATLAB','PropsSI.mexw32'))
shutil.copy2(os.path.join('wrappers','MATLAB','PropsSI.mexw64'),os.path.join('dist_temp','MATLAB','PropsSI.mexw64'))
shutil.copy2(os.path.join('wrappers','MATLAB','Props.mexw32'),os.path.join('dist_temp','MATLAB','Props.mexw32'))
shutil.copy2(os.path.join('wrappers','MATLAB','Props.mexw64'),os.path.join('dist_temp','MATLAB','Props.mexw64'))
shutil.copy2(os.path.join('wrappers','MATLAB','HAProps.mexw32'),os.path.join('dist_temp','MATLAB','HAProps.mexw32'))
shutil.copy2(os.path.join('wrappers','MATLAB','HAProps.mexw64'),os.path.join('dist_temp','MATLAB','HAProps.mexw64'))
shutil.copy2(os.path.join('wrappers','MATLAB','README.rst'),os.path.join('dist_temp','MATLAB','README.rst'))
shutil.copy2(os.path.join('wrappers','MATLAB','MATLAB_sample.m'),os.path.join('dist_temp','MATLAB','example.m'))
def Labview():
print('Labview')
import CoolProp
version = CoolProp.__version__
try:
os.makedirs(os.path.join('dist_temp','Labview'))
except os.error: pass
process = subprocess.Popen(['BuildDLL.bat'],shell=True,cwd=os.path.join('wrappers','Labview'))
process.wait()
shutil.copy2(os.path.join('wrappers','Labview','CoolProp.dll'),os.path.join('dist_temp','Labview','CoolProp.dll'))
shutil.copy2(os.path.join('wrappers','Labview','CoolProp.llb'),os.path.join('dist_temp','Labview','CoolProp.llb'))
shutil.copy2(os.path.join('wrappers','Labview','CoolProp.vi'),os.path.join('dist_temp','Labview','CoolProp.vi'))
shutil.copy2(os.path.join('wrappers','Labview','README.rst'),os.path.join('dist_temp','Labview','README.rst'))
def EES():
print('EES')
import CoolProp
version = CoolProp.__version__
try:
os.makedirs(os.path.join('dist_temp','EES'))
except os.error: pass
subprocess.check_output('BuildDLF.bat',shell=True,cwd=os.path.join('wrappers','EES'))
#Make an installer using InnoSetup
subprocess.call(['C:\Program Files (x86)\Inno Setup 5\Compil32.exe','/cc','BuildInnoInstaller.iss'],cwd=os.path.join('wrappers','EES'))
shutil.copy2(os.path.join('wrappers','EES','Output','SetupCOOLPROP_EES.exe'),os.path.join('dist_temp','EES','SetupCOOLPROP_EES.exe'))
shutil.copy2(os.path.join('wrappers','EES','CoolProp.htm'),os.path.join('dist_temp','EES','CoolProp.htm'))
shutil.copy2(os.path.join('wrappers','EES','README.rst'),os.path.join('dist_temp','EES','README.rst'))
def Javascript():
print('Javascript')
import CoolProp
version = CoolProp.__version__
try:
os.makedirs(os.path.join('dist_temp','Javascript'))
except os.error: pass
subprocess.check_output('python build.py',shell=True,cwd=os.path.join('wrappers','Javascript'))
shutil.copy2(os.path.join('wrappers','Javascript','index.html'),os.path.join('dist_temp','Javascript','index.html'))
shutil.copy2(os.path.join('wrappers','Javascript','coolprop.js'),os.path.join('dist_temp','Javascript','coolprop.js'))
shutil.copy2(os.path.join('wrappers','Javascript','README.rst'),os.path.join('dist_temp','Javascript','README.rst'))
def Java():
print('Java')
import CoolProp
version = CoolProp.__version__
try:
os.makedirs(os.path.join('dist_temp','Java','win32'))
except os.error as E: print(E)
try:
os.makedirs(os.path.join('dist_temp','Java','x64'))
except os.error as E: print(E)
subprocess.check_output('build_win32.bat',shell=True,cwd=os.path.join('wrappers','Java'))
subprocess.check_output('build_x64.bat',shell=True,cwd=os.path.join('wrappers','Java'))
subprocess.check_call(['7z','a','-r','dist_temp/Java/sources.zip','wrappers/Java/*.java'])
shutil.copy2(os.path.join('wrappers','Java','win32','CoolProp.dll'),os.path.join('dist_temp','Java','win32','CoolProp.dll'))
shutil.copy2(os.path.join('wrappers','Java','x64','CoolProp.dll'),os.path.join('dist_temp','Java','x64','CoolProp.dll'))
shutil.copy2(os.path.join('wrappers','Java','README.rst'),os.path.join('dist_temp','Java','README.rst'))
def Python():
print('Python')
subprocess.call(['python','setup.py','install'],shell=True,cwd=os.path.join('wrappers','Python'))
path_32bit = "c:\\Miniconda32bit\\Scripts\\"
path_64bit = 'c:\\Miniconda\\Scripts\\'
envs = ['py27','py33','py34']
# Build all the installers
for env in envs:
for path in [path_64bit, path_32bit]:
# Install cython and pip if needed
subprocess.check_call(path+'conda install -n '+env+' Cython pip',cwd=os.path.join('wrappers','Python'),stdout = sys.stdout, shell = True)
# Install wheel package using pip
subprocess.check_call(path+'activate '+env+' '+'&& pip install wheel && deactivate',cwd=os.path.join('wrappers','Python'),stdout = sys.stdout, shell = True)
# Build the installer
subprocess.check_call([path+'activate',env,'&&','python','setup.py','bdist','--format=wininst','--dist-dir=../../dist_temp/Python'],shell=True,cwd=os.path.join('wrappers','Python'),stdout=sys.stdout)
def Maple():
print('Maple')
try:
os.makedirs(os.path.join('dist_temp','Maple'))
except os.error: pass
process = subprocess.check_output(['BuildDLLx64.bat'],shell=True,cwd=os.path.join('wrappers','Maple'))
listing = ['Analysis of a Refrigeration Cycle with CoolProp.mw','sample_file.mw','CoolProp_x64.dll']
for file in listing:
shutil.copy2(os.path.join('wrappers','Maple',file),os.path.join('dist_temp','Maple',file))
def Mathematica():
print('Mathematica')
try:
os.makedirs(os.path.join('dist_temp','Mathematica'))
except os.error: pass
process = subprocess.check_output(['BuildDLL.bat'],shell=True,cwd=os.path.join('wrappers','Mathematica'))
listing = ['README.rst','example.nb','CoolProp.dll']
for file in listing:
shutil.copy2(os.path.join('wrappers','Mathematica',file),os.path.join('dist_temp','Mathematica',file))
def Scilab():
print('Scilab')
try:
os.makedirs(os.path.join('dist_temp','Scilab'))
except os.error: pass
process = subprocess.check_output(['BuildDLL.bat'],shell=True,cwd=os.path.join('wrappers','Scilab'))
listing = ['README.rst','sample.sce','CoolProp_x64.dll','CoolProp.dll']
for file in listing:
shutil.copy2(os.path.join('wrappers','Scilab',file),os.path.join('dist_temp','Scilab',file))
def LibreOffice():
print('LibreOffice')
try:
os.makedirs(os.path.join('dist_temp','LibreOffice'))
except os.error: pass
shutil.copy2(os.path.join('wrappers','Excel','CoolProp.dll'),os.path.join('dist_temp','LibreOffice','CoolProp.dll'))
shutil.copy2(os.path.join('wrappers','LibreOffice','TestLibreOffice.ods'),os.path.join('dist_temp','LibreOffice','TestLibreOffice.ods'))
def MathCAD():
print('MathCAD')
try:
os.makedirs(os.path.join('dist_temp','MathCAD','Prime'))
except os.error: pass
process = subprocess.check_output(['BuildDLL.bat'],shell=True,cwd=os.path.join('wrappers','MathCAD'))
process = subprocess.check_output(['BuildDLL.bat'],shell=True,cwd=os.path.join('wrappers','MathCAD','Prime'))
shutil.copy2(os.path.join('wrappers','MathCAD','CoolPropMathcadWrapper.dll'),os.path.join('dist_temp','MathCAD','CoolPropMathcadWrapper.dll'))
shutil.copy2(os.path.join('wrappers','MathCAD','CoolPropFluidProperties.xmcd'),os.path.join('dist_temp','MathCAD','CoolPropFluidProperties.xmcd'))
shutil.copy2(os.path.join('wrappers','MathCAD','README.rst'),os.path.join('dist_temp','MathCAD','README.rst'))
shutil.copy2(os.path.join('wrappers','MathCAD','Prime','CoolPropMathcadWrapper.dll'),os.path.join('dist_temp','MathCAD','Prime','CoolPropMathcadWrapper.dll'))
shutil.copy2(os.path.join('wrappers','MathCAD','Prime','CoolPropFluidProperties.mcdx'),os.path.join('dist_temp','MathCAD','Prime','CoolPropFluidProperties.xmcd'))
shutil.copy2(os.path.join('wrappers','MathCAD','Prime','README.rst'),os.path.join('dist_temp','MathCAD','Prime','README.rst'))
# def Modelica():
# print('Modelica')
# try:
# os.makedirs(os.path.join('dist_temp','Modelica'))
# except os.error: pass
#
# process = subprocess.Popen(['BuildLIB-VS2008.bat'],shell=True,cwd=os.path.join('wrappers','Modelica')); process.wait()
# process = subprocess.Popen(['BuildLIB-VS2010.bat'],shell=True,cwd=os.path.join('wrappers','Modelica')); process.wait()
#
# shutil.copy2(os.path.join('wrappers','Modelica','README.rst'),os.path.join('dist_temp','Modelica','README.rst'))
# #shutil.copy2(os.path.join('wrappers','Modelica','src_modelica','CoolProp2Modelica.mo'),os.path.join('dist_temp','Modelica','CoolProp2Modelica.mo'))
# shutil.copy2(os.path.join('wrappers','Modelica','src','CoolPropLib.h'),os.path.join('dist_temp','Modelica','CoolPropLib.h'))
# shutil.copytree(os.path.join('wrappers','Modelica','bin','VS2008'),os.path.join('dist_temp','Modelica','VS2008'))
# shutil.copytree(os.path.join('wrappers','Modelica','bin','VS2010'),os.path.join('dist_temp','Modelica','VS2010'))
def UploadSourceForge():
#Rename folder to version number
import CoolProp
try:
shutil.copytree('dist_temp',CoolProp.__version__)
except WindowsError: pass
call_str = ['pscp','README.txt','ibell,[email protected]:/home/pfs/project/c/co/coolprop/CoolProp/']
print('Calling: '+' '.join(call_str))
subprocess.check_output(call_str,shell=True)
call_str = ['pscp','-r','-v',CoolProp.__version__,'ibell,[email protected]:/home/pfs/project/c/co/coolprop/CoolProp/']
print('Calling: '+' '.join(call_str))
subprocess.check_output(call_str,shell=True)
####### DOCUMENTATION STUFF ################
def Doxygen():
# Open Doxyfile, and update the version number in the file
lines = open('Doxyfile','r').readlines()
import CoolProp
for i in range(len(lines)):
if lines[i].startswith('PROJECT_NUMBER'):
line = lines[i].split('=')[0]+' = '+CoolProp.__version__+'\n'
lines[i]=line
break
open('Doxyfile','w').write(''.join(lines))
subprocess.check_output(['doxygen','Doxyfile'],shell=True)
def RunExamples():
subprocess.check_call(['run_examples.bat'],shell=True,cwd='Web/examples',stdout= sys.stdout)
def BuildDocs():
# Inject the revision number into the docs main pages for the link
lines = open('Web/_templates/index.html','r').readlines()
import CoolProp
languages = ['Python','Modelica','Labview','MATLAB','EES','Octave','Excel','C#','Java','Javascript','MathCAD','Maple','Mathematica','Scilab']
for i in range(len(lines)):
if (lines[i].find('http://sourceforge.net/projects/coolprop/files/CoolProp/') > -1
and any([lines[i].find(a) > -1 for a in languages])
):
oldVersion = lines[i].split('http://sourceforge.net/projects/coolprop/files/CoolProp/')[1].split('/',1)[0]
lines[i] = lines[i][:].replace(oldVersion,CoolProp.__version__)
open('Web/_templates/index.html','w').write(''.join(lines))
shutil.rmtree(os.path.join('Web','_build'),ignore_errors = True)
subprocess.check_output(['BuildCPDocs.bat'],shell=True,cwd='Web')
def UploadDocs():
call_str = ['pscp','-r','-v','Web/_build/html/*.*','[email protected]:/home/groups/coolprop/htdocs']
print('Calling: '+' '.join(call_str))
subprocess.check_output(call_str, shell = True)
def Superpacks():
import CoolProp
subprocess.check_call(['git','archive','-o','dist_temp/CoolProp-'+CoolProp.__version__+'-source_code.zip','HEAD'])
## Windows superpack
try:
os.mkdir(os.path.join('dist_temp','windows_superpack'))
except WindowsError:
pass
shutil.copy2(os.path.join('dist_temp/CoolProp-'+CoolProp.__version__+'-source_code.zip'),os.path.join('dist_temp','windows_superpack','CoolProp-'+CoolProp.__version__+'-source_code.zip'))
# Octave removed for now : 'Octave'
for folder in ['Excel and DLL','Python','C#','MATLAB','EES','Labview','LibreOffice','Maple','Scilab','Mathematica','Java','Javascript','MathCAD']:
shutil.copytree(os.path.join('dist_temp',folder), os.path.join('dist_temp','windows_superpack',folder))
subprocess.check_call(['7z','a','-r','dist_temp/CoolProp-'+CoolProp.__version__+'-windows_superpack.zip','dist_temp/windows_superpack/*.*'])
shutil.rmtree(os.path.join('dist_temp','windows_superpack'))
if __name__=='__main__':
# InstallPrereqs() #This is optional if you think any of the pre-reqs have been updated
Python() # This one must be first to ensure that version gets rebuild properly
## Always run the examples first. This serves as an integration test of
## CoolProp
RunExamples()
DLL_and_Excel()
Source()
Csharp()
#~ ###########~ Octave()
MATLAB()
Maple()
Mathematica()
Scilab()
EES()
LibreOffice()
Javascript()
Java()
MathCAD()
Labview()
Superpacks()
PYPI()
UploadSourceForge()
Doxygen()
BuildDocs()
UploadDocs()