Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #120

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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