Skip to content

Commit

Permalink
update build_pip.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuminjie committed Apr 22, 2020
1 parent 7774a5a commit 7499e25
Showing 1 changed file with 48 additions and 70 deletions.
118 changes: 48 additions & 70 deletions build_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,75 +6,53 @@

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/*'])

def copy_library(so, pyd):

# change to script's folder
os.chdir(os.path.dirname(os.path.abspath(__file__)))

# replace new libraries
linux = './openseespy/opensees/linux/'
win = './openseespy/opensees/win/'

if os.path.exists(pyd):
if os.path.exists(win+'opensees.pyd'):
os.remove(win+'opensees.pyd')
shutil.copy(pyd, win)

if os.path.exists(so):
if os.path.exists(linux+'opensees.so'):
os.remove(linux+'opensees.so')
shutil.copy(so, linux)

# get dependent library for linux
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]+' to '+linux+'lib/')
shutil.copy(line[i:j], linux+'lib/')


def build_pip():

# clean folders
subprocess.run(['rm', '-fr', 'build', 'dist', 'openseespy.egg-info'])

# update tools
subprocess.run(['python3.7', '-m', 'pip', 'install', '--upgrade',
'setuptools', 'wheel', 'twine'])

# compile wheel
subprocess.run(['python3.7', 'setup.py', 'bdist_wheel'])

def upload_pip():
# upload
subprocess.run(['python3.7', '-m', 'twine', 'upload', 'dist/*'])
subprocess.run(['rm', '-fr', 'build', 'dist', 'openseespy.egg-info'])

0 comments on commit 7499e25

Please sign in to comment.