Skip to content

Commit

Permalink
Merge pull request #120 from rheiland/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
MathCancer authored Jul 19, 2022
2 parents 6d99270 + 30d7f30 commit 3c3744f
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions beta/setup_libroadrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def reminder_dynamic_link_path_linux():
print("\n* To make this permanent, add this line to the bottom of the respective shell startup file, e.g., .bashrc, .bash_profile, or .zshenv in your home directory.")
print("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")

# print("--------- print reminder!!!!!!!!!!!!!!\n\n")
if os.path.exists(os.path.join(os.path.dirname(os.path.dirname(__file__)), "addons", "libRoadrunner", "roadrunner")):
print('\nlibroadrunner already installed.\n')

Expand All @@ -40,22 +39,19 @@ def reminder_dynamic_link_path_linux():
rr_file = ""
url = ""

mac_silicon = False
if os_type.lower() == 'darwin':
reminder_dynamic_link_path_macos()
if "ARM64" in platform.uname().version:
# pass
# reminder_dynamic_link_path()
# print('... for the arm64 processor.')
# url = "https://github.com/PhysiCell-Tools/intracellular_libs/raw/main/ode/libs/macos12_arm64/libroadrunner_c_api.dylib"
rr_file = "roadrunner_macos_arm64.tar.gz"
url = "https://github.com/PhysiCell-Tools/intracellular_libs/raw/main/ode/roadrunner_macos_arm64.tar.gz"
mac_silicon = True
else:
rr_file = "roadrunner-osx-10.9-cp36m.tar.gz"
url = "https://sourceforge.net/projects/libroadrunner/files/libroadrunner-1.4.18/" + rr_file + "/download"
# url = "https://raw.github.com/PhysiCell-Tools/intracellular_libs/blob/main/ode/libs/macos/roadrunner-osx-10.9-cp36m.tar.gz"

# rr_file = "roadrunner-osx-10.9-cp36m.tar.gz"
# url = "https://github.com/PhysiCell-Tools/intracellular_libs/raw/main/ode/libs/macos/roadrunner-osx-10.9-cp36m.tar.gz"
elif os_type.lower().startswith("win"):
rr_file = "roadrunner-win64-vs14-cp35m.zip"
url = "https://sourceforge.net/projects/libroadrunner/files/libroadrunner-1.4.18/" + rr_file + "/download"
Expand All @@ -67,11 +63,12 @@ def reminder_dynamic_link_path_linux():
print("Your operating system seems to be unsupported. Please submit a ticket at https://sourceforge.net/p/physicell/tickets/ ")
sys.exit(1)

# print("-------- past if block...")
# reminder_dynamic_link_path()
# fname = url.split('/')[-2]
fname = url.split('/')[-1]
print("fname = ",fname)
print("url=",url)
if mac_silicon:
fname = url.split('/')[-1]
else:
fname = url.split('/')[-2]
print("fname=",fname)

# home = os.path.expanduser("~")
print('libRoadRunner will now be installed into this location:')
Expand Down Expand Up @@ -115,8 +112,13 @@ def reminder_dynamic_link_path_linux():
if os_type.lower().startswith("win"):
rrlib_dir = my_file[:-4]
else: # darwin or linux
rrlib_dir = my_file[:-7]
rrlib_dir = my_file[:-6]
if mac_silicon:
# idx_end = my_file.rindex('/')
# rrlib_dir = my_file[:idx_end]
rrlib_dir = my_file[:-7]
# rrlib_dir = my_file
else:
rrlib_dir = my_file[:-7]
print('rrlib_dir = ',rrlib_dir)

def download_cb(blocknum, blocksize, totalsize):
Expand All @@ -133,12 +135,10 @@ def download_cb(blocknum, blocksize, totalsize):

urllib.request.urlretrieve(url, my_file, download_cb)

# sys.exit(-1)

new_dir_name = "roadrunner"
os.chdir(dir_name)
print('installing (uncompressing) the file...')
if os_type.lower().startswith("win"): # on Windows
if os_type.lower().startswith("win"):
try:
with zipfile.ZipFile(rr_file) as zf:
zf.extractall('.')
Expand All @@ -148,23 +148,24 @@ def download_cb(blocknum, blocksize, totalsize):
exit(1)
else: # Darwin or Linux
try:
print("-- attempt to extract from the tar file...", rr_file)
print("untarring ",rr_file)
tar = tarfile.open(rr_file)
tar.extractall()
tar.close()
if 'darwin' in os_type.lower():
if "ARM64" in platform.uname().version: # on the new Mac M1, arm64 processor
# if False:
# print("--- TODO: rename ARM64 lib dir")
# sys.exit(-1)
pass # it already uncompresses and creates the 'roadrunner' dir
if mac_silicon:
os.rename("roadrunner_macos_arm64", new_dir_name)
else:
os.rename("roadrunner-osx-10.9-cp36m", new_dir_name)
else:
os.rename("libroadrunner", new_dir_name)
except:
print('error untarring the file')
exit(1)
if mac_silicon:
print()
# pass
else:
print('error untarring the file')
exit(1)

print('Done.\n')

Expand Down

0 comments on commit 3c3744f

Please sign in to comment.