Skip to content

Commit

Permalink
add mac
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuminjie committed Oct 13, 2020
1 parent cc5ada1 commit 390e530
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
52 changes: 44 additions & 8 deletions openseespy-pip/build_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import os.path
import sys
import glob


def copy_library(so, pyd):
Expand Down Expand Up @@ -38,6 +39,41 @@ def copy_library(so, pyd):
shutil.copy(line[i:j], linux+'lib/')


def copy_mac_library(so):

mac = './openseespy/opensees/mac/'
if os.path.exists(so):
if os.path.exists(mac+'opensees.so'):
os.remove(mac+'opensees.so')
for f in glob.glob(mac+'lib/*.dylib'):
os.remove(f)

shutil.copy(so, mac)

# get dependent library for linux
p = subprocess.run(
["otool", "-L", 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 '+mac+'lib/')
shutil.copy(line[i:j], mac+'lib/')
lib_name = line[i:j].split('/')
lib_name = lib_name[-1]
print('changing rpath from '+line[i:j]+' to lib/'+lib_name)
subprocess.run(
['install_name_tool', '-change', line[i:j],
'lib/'+lib_name, mac+'opensees.so']
)

if os.path.exists(mac+'lib/Python'):
os.remove(mac+'lib/Python')


def build_pip():

print('==============================================================')
Expand All @@ -49,16 +85,16 @@ def build_pip():
subprocess.run(['rm', '-fr', 'build', 'dist', 'openseespy.egg-info'])

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

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


def upload_pip():
# upload
subprocess.run(['python', '-m', 'twine', 'upload', 'dist/*'])
subprocess.run(['python3', '-m', 'twine', 'upload', 'dist/*'])


def clean_pip():
Expand All @@ -67,17 +103,17 @@ def clean_pip():

def upload_pip_test():
# upload
subprocess.run(['python', '-m', 'twine', 'upload',
subprocess.run(['python3', '-m', 'twine', 'upload',
'--repository', 'testpypi', 'dist/*'])


def install_pip_test():
subprocess.run(['python', '-m', 'pip', 'uninstall', '-y', 'openseespy'])
subprocess.run(['python', '-m', 'pip', 'install', '--pre', '--no-cache-dir', '--index-url',
subprocess.run(['python3', '-m', 'pip', 'uninstall', '-y', 'openseespy'])
subprocess.run(['python3', '-m', 'pip', 'install', '--pre', '--no-cache-dir', '--index-url',
'https://test.pypi.org/simple/', 'openseespy'])


def install_pip():
subprocess.run(['python', '-m', 'pip', 'uninstall', '-y', 'openseespy'])
subprocess.run(['python', '-m', 'pip', 'install',
subprocess.run(['python3', '-m', 'pip', 'uninstall', '-y', 'openseespy'])
subprocess.run(['python3', '-m', 'pip', 'install',
'--pre', '--no-cache-dir', 'openseespy'])
3 changes: 3 additions & 0 deletions openseespy-pip/copy_mac.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from build_pip import copy_mac_library

copy_mac_library('../../opensees/SRC/interpreter/opensees.so')

0 comments on commit 390e530

Please sign in to comment.