Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion addons/libRoadrunner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ FetchContent_Declare(
FetchContent_MakeAvailable(roadrunner)

target_include_directories(libRoadrunner
PUBLIC ${roadrunner_SOURCE_DIR}/include/rr/C)
PUBLIC ${roadrunner_SOURCE_DIR}/include/rr)
target_link_directories(libRoadrunner PUBLIC ${roadrunner_SOURCE_DIR}/lib)
target_link_libraries(libRoadrunner PUBLIC roadrunner_c_api)
target_compile_definitions(libRoadrunner PUBLIC ADDON_ROADRUNNER)
Expand Down
119 changes: 43 additions & 76 deletions beta/setup_libroadrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import urllib.request
import os
import sys
import tarfile
import zipfile

def reminder_dynamic_link_path_macos():
Expand All @@ -27,15 +26,12 @@ 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")

os_type = platform.system()

# Old:
# if os.path.exists(os.path.join(os.path.dirname(os.path.dirname(__file__)), "addons", "libRoadrunner", "roadrunner")):
os_type = platform.system() # can test that it downloads correct OS .zip by overriding this value

# New: July 2023 - trying to be smarter about deciding whether to (re)download libRR
# NOTE: needs to be tested cross-platform!
if os.path.exists(os.path.join(os.path.dirname(os.path.dirname(__file__)), "addons", "libRoadrunner", "roadrunner","include","rr","C","rrc_api.h")):
print('\nlibroadrunner already installed.\n')
if os.path.exists(os.path.join(os.path.dirname(os.path.dirname(__file__)), "addons", "libRoadrunner", "roadrunner","include","rr","rrc_api.h")):
print('\nNote: libroadrunner is already installed so we will not re-install it. \nIf you want to force a re-install, delete the "roadrunner" directory in /addons/libRoadrunner then re-compile.\n')

# regardless, let's remind the user about the env var requirement!
if os_type.lower() == 'darwin':
Expand All @@ -55,38 +51,31 @@ def reminder_dynamic_link_path_linux():
if os_type.lower() == 'darwin':
reminder_dynamic_link_path_macos()
if "ARM64" in platform.uname().version:
# pass
# 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"
rr_file = "roadrunner_macos_arm64.zip"
url = "https://github.com/PhysiCell-Tools/intracellular_libs/raw/main/ode/roadrunner_macos_arm64.zip"
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"
rr_file = "roadrunner_macos_x86_64.zip"
url = "https://github.com/PhysiCell-Tools/intracellular_libs/raw/main/ode/roadrunner_macos_x86_64.zip"
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"
rr_file = "roadrunner_win_x86_64.zip"
url = "https://github.com/PhysiCell-Tools/intracellular_libs/raw/main/ode/roadrunner_win_x86_64.zip"
elif os_type.lower().startswith("linux"):
reminder_dynamic_link_path_linux()
rr_file = "cpplibroadrunner-1.3.0-linux_x86_64.tar.gz"
url = "https://sourceforge.net/projects/libroadrunner/files/libroadrunner-1.3/" + rr_file + "/download"
# the following "manylinux" seems to work on more flavors/releases of Linux than the roadrunner_ubuntu_24.zip which still exists on github.com/PhysiCell-Tools/intracellular_libs
rr_file = "roadrunner_manylinux.zip"
url = "https://github.com/PhysiCell-Tools/intracellular_libs/raw/main/ode/roadrunner_manylinux.zip"
else:
print("Your operating system seems to be unsupported. Please submit a ticket at https://sourceforge.net/p/physicell/tickets/ ")
print("Your operating system seems to be unsupported. Please create an issue on the PhysiCell GitHub repo or reach out on our Slack channel.")
sys.exit(1)

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

# home = os.path.expanduser("~")
print('libRoadRunner will now be installed into this location:')
# dir_name = os.path.join(home, 'libroadrunner')
dir_name = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'addons', 'libRoadrunner')
print(dir_name + '\n')
print(f'Will create {dir_name} if it does not exist.')
# print(' - Press ENTER to confirm the location')
# print(' - Press CTL-C to abort the installation')
# print(' - Or specify a different location below\n')
Expand Down Expand Up @@ -121,17 +110,8 @@ def reminder_dynamic_link_path_linux():
my_file = os.path.join(dir_name, fname)
print('my_file = ',my_file)

if os_type.lower().startswith("win"):
rrlib_dir = my_file[:-4]
else: # darwin or linux
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)
# rrlib_dir = my_file[:-4] # assume all are .zip
# print('rrlib_dir = ',rrlib_dir)

def download_cb(blocknum, blocksize, totalsize):
readsofar = blocknum * blocksize
Expand All @@ -148,44 +128,31 @@ def download_cb(blocknum, blocksize, totalsize):
urllib.request.urlretrieve(url, my_file, download_cb)

new_dir_name = "roadrunner"
print(f"chdir to {dir_name}")
os.chdir(dir_name)
print('installing (uncompressing) the file...')
if os_type.lower().startswith("win"):
try:
with zipfile.ZipFile(rr_file) as zf:
zf.extractall('.')
os.rename("roadrunner-win64-vs14-cp35m", new_dir_name)
except:
print('error unzipping the file')
exit(1)
else: # Darwin or Linux
try:
print("untarring ",rr_file)
tar = tarfile.open(rr_file)
tar.extractall()
tar.close()
if 'darwin' in os_type.lower():
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:
if mac_silicon:
print()
# pass
else:
print('error untarring the file')
exit(1)

print('Done.\n')

# # LIBRR_DIR := /Users/heiland/libroadrunner/roadrunner-osx-10.9-cp36m
# print("Replace the following variables in your PhysiCell Makefile with these:\n")
# #print("LIBRR_DIR := /Users/heiland/libroadrunner/roadrunner-osx-10.9-cp36m")
# print("LIBRR_DIR := " + rrlib_dir)
# if os_type == 'Windows':
# print("LIBRR_LIBS := " + rrlib_dir + "/bin\n")
# else:
# print("LIBRR_LIBS := " + rrlib_dir + "/lib\n")
try:
with zipfile.ZipFile(rr_file) as zf:
zf.extractall('.') # should create "roadrunner" directory
except:
print('error unzipping the file')
exit(1)


# Hack to maintain backwards compatibility. Originally our header path was .../include/rr/C,
# but newer releases of the libroadrunner C API seems to have dropped the "/C" directory and put everything in "/rr"
dst = "roadrunner/include/rr/C"
try:
os.remove(dst)
except FileNotFoundError:
print(f"File '{dst}' does not exist.")

try:
src = "."
os.symlink(src, dst)
print(f"Symbolic link '{dst}' created, pointing to '{src}'")
except FileExistsError:
print(f"Symlink '{dst}' already exists")
except OSError as e:
print(f"Error creating symlink: {e}")
print('Done.\n')
23 changes: 4 additions & 19 deletions sample_projects_intracellular/ode/ode_energy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ OSFLAG :=
ifeq ($(OS),Windows_NT)
OSFLAG += -D WIN32
OMP_LIB :=
# LIBRR_DIR := C:\Users\heiland\libroadrunner\roadrunner-win64-vs14-cp35m
# LIBRR_LIBS := C:\Users\heiland\libroadrunner\roadrunner-win64-vs14-cp35m/bin
# LIBRR_CFLAGS := -I${LIBRR_DIR}/include/rr/C
# CFLAGS := -march=$(ARCH) -fomit-frame-pointer -fopenmp -m64 -std=c++11 -D ADDON_ROADRUNNER
LIBRR_DIR := .\addons\libRoadrunner\roadrunner
LIBRR_CFLAGS := -I${LIBRR_DIR}\include\rr\C
LIBRR_LIBS := ${LIBRR_DIR}\lib
Expand All @@ -47,21 +43,6 @@ else
LIBRR_LIBS := ${LIBRR_DIR}/lib
endif

# Not sure if useful later or not.
# UNAME_P := $(shell uname -p)
# ifeq ($(UNAME_P),x86_64)
# OSFLAG += -D AMD64
# LIBRR_DIR := $(shell pwd)/intracellular_libs/roadrunner
# LIBRR_CFLAGS := -I${LIBRR_DIR}/include/rr/C
# # CFLAGS := -march=$(ARCH) -fomit-frame-pointer -fopenmp -m64 -std=c++11 -D LIBROADRUNNER
# CFLAGS := -march=$(ARCH) -fomit-frame-pointer -fopenmp -m64 -std=c++11 -D ADDON_ROADRUNNER
# endif
# ifneq ($(filter %86,$(UNAME_P)),)
# OSFLAG += -D IA32
# endif
# ifneq ($(filter arm%,$(UNAME_P)),)
# OSFLAG += -D ARM
# endif
endif

COMPILE_COMMAND := $(CC) $(CFLAGS) $(LIBRR_CFLAGS)
Expand Down Expand Up @@ -100,6 +81,10 @@ all: libRoadrunner main.cpp $(ALL_OBJECTS)
@echo
@echo created $(PROGRAM_NAME)
@echo
@echo 'remember on Mac: export DYLD_LIBRARY_PATH=$$DYLD_LIBRARY_PATH:./addons/libRoadrunner/roadrunner/lib'
@echo 'remember on Linux: export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:./addons/libRoadrunner/roadrunner/lib'
@echo 'You can safely delete the downloaded .zip file in addons/libRoadrunner'
@echo

name:
@echo ""
Expand Down