forked from mhscott/openseespy-pip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_pip.py
80 lines (63 loc) · 2.33 KB
/
build_pip.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
import subprocess
import shutil
import os
import os.path
import sys
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# replace new libraries
linux = './openseespy/opensees/linux/'
win = './openseespy/opensees/win/'
so = '../openseespy/SRC/interpreter/opensees.so'
pyd = '../openseespy/Win64/bin/opensees.pyd'
if os.path.exists(linux+'opensees.so'):
os.remove(linux+'opensees.so')
if os.path.exists(win+'opensees.pyd'):
os.remove(win+'opensees.pyd')
shutil.copy(so, linux)
if os.path.exists(pyd):
shutil.copy(pyd, win)
# get fortran library
p = subprocess.run(
["ldd", so], capture_output=True)
for line in p.stdout.decode('utf-8').split('\n'):
i = line.find('/')
j = line.find(' ', i)
if i < 0 or j < 0 or i >= j:
continue
print('copying '+line[i:j]+' ....')
shutil.copy(line[i:j], linux+'lib/')
# clean folders
subprocess.run(['rm', '-fr', 'build', 'dist', 'openseespy.egg-info'])
# update tools
subprocess.run(['python3.7', '-m', 'pip', 'install', '--upgrade', 'setuptools', 'wheel', 'twine', 'numpy', 'matplotlib'])
# compile wheel
subprocess.run(['python3.7', 'setup.py', 'bdist_wheel'])
# test
sys.path.append('openseespy/opensees/linux')
from opensees import *
os.chdir('tests')
exec(open('Truss.py','r').read())
exec(open('MomentCurvature.py','r').read())
exec(open('RCFramePushover.py','r').read())
exec(open('ElasticFrame.py','r').read())
exec(open('DynAnal_BeamWithQuadElements.py','r').read())
exec(open('Ex1a.Canti2D.EQ.modif.py','r').read())
exec(open('EigenAnal_twoStoreyShearFrame7.py','r').read())
exec(open('EigenAnal_twoStoreyFrame1.py','r').read())
exec(open('sdofTransient.py','r').read())
exec(open('PlanarTruss.py','r').read())
exec(open('PlanarTruss.Extra.py','r').read())
exec(open('PortalFrame2d.py','r').read())
exec(open('EigenFrame.py','r').read())
exec(open('EigenFrame.Extra.py','r').read())
exec(open('AISC25.py','r').read())
exec(open('PlanarShearWall.py','r').read())
exec(open('PinchedCylinder.py','r').read())
os.chdir('..')
print("================================================================")
print("Done with testing examples.")
print("================================================================")
# upload
if os.path.exists(pyd):
subprocess.run(['python3.7', '-m', 'twine', 'upload', 'dist/*'])
subprocess.run(['rm', '-fr', 'build', 'dist', 'openseespy.egg-info'])