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
4 changes: 2 additions & 2 deletions addons/libRoadrunner/src/librr_intracellular.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
// #define STATIC_RRC
// #include "rrc_api.h"
// #include "rrc_types.h"
#include "../roadrunner/include/rr/C/rrc_api.h"
#include "../roadrunner/include/rr/C/rrc_types.h"
#include "../roadrunner/include/rr/rrc_api.h"
#include "../roadrunner/include/rr/rrc_types.h"
// #include "rrc_utilities.h"
extern "C" rrc::RRHandle createRRInstance();
// #endif
Expand Down
92 changes: 24 additions & 68 deletions beta/setup_libroadrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import platform
import urllib.request
import urllib.error
import os
import sys
import tarfile
Expand All @@ -29,12 +30,8 @@ def reminder_dynamic_link_path_linux():

os_type = platform.system()

# Old:
# if os.path.exists(os.path.join(os.path.dirname(os.path.dirname(__file__)), "addons", "libRoadrunner", "roadrunner")):

# 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")):
if os.path.exists(os.path.join(os.path.dirname(os.path.dirname(__file__)), "addons", "libRoadrunner", "roadrunner","include","rr","rrc_api.h")):
print('\nlibroadrunner already installed.\n')

# regardless, let's remind the user about the env var requirement!
Expand All @@ -51,45 +48,31 @@ 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
# 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
rr_file = "roadrunner_macos_arm64.zip"
url = "https://github.com/PhysiCell-Tools/intracellular_libs/raw/main/ode/" + rr_file
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/" + rr_file
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/" + rr_file
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"
rr_file = "roadrunner_ubuntu_24.zip"
url = "https://github.com/PhysiCell-Tools/intracellular_libs/raw/main/ode/" + rr_file
else:
print("Your operating system seems to be unsupported. Please submit a ticket at https://sourceforge.net/p/physicell/tickets/ ")
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(' - Press ENTER to confirm the location')
# print(' - Press CTL-C to abort the installation')
# print(' - Or specify a different location below\n')
prompt_str = '[' + dir_name + '] >>> '
try:
# response = input(prompt_str)
Expand All @@ -116,21 +99,16 @@ def reminder_dynamic_link_path_linux():
exit(1)

print('Beginning download of libroadrunner into ' + dir_name + ' ...')
print(url)
print("url=" ,url)

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]
rrlib_dir = my_file[:-4]
# if os_type.lower().startswith("win"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we clear out these 4 commented lines?

# rrlib_dir = my_file[:-4]
# else: # darwin or linux
# rrlib_dir = my_file[:-4]
print('rrlib_dir = ',rrlib_dir)

def download_cb(blocknum, blocksize, totalsize):
Expand All @@ -154,38 +132,16 @@ def download_cb(blocknum, blocksize, totalsize):
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)
print(f'unzipping (uncompressing) {rr_file}')
with zipfile.ZipFile(rr_file) as zf:
zf.extractall('.')
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")
print('error unzipping the file')
exit(1)

print('Done.\n')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also clean up the downloaded zip file for the user?

30 changes: 7 additions & 23 deletions sample_projects_intracellular/ode/ode_energy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ 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_CFLAGS := -I${LIBRR_DIR}\include\rr
LIBRR_LIBS := ${LIBRR_DIR}\lib
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
OSFLAG += -D AMD64
Expand All @@ -31,37 +27,23 @@ ifeq ($(OS),Windows_NT)
OSFLAG += -D IA32
endif
else
# @echo remember
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OSFLAG += -D LINUX
OMP_LIB :=
# LIBRR_DIR := $(shell pwd)/intracellular_libs/roadrunner
LIBRR_DIR := ./addons/libRoadrunner/roadrunner
LIBRR_CFLAGS := -I${LIBRR_DIR}/include/rr/C
LIBRR_CFLAGS := -I${LIBRR_DIR}/include/rr
LIBRR_LIBS := ${LIBRR_DIR}/lib
endif
ifeq ($(UNAME_S),Darwin)
# @echo remember
OSFLAG += -D OSX
LIBRR_DIR := ./addons/libRoadrunner/roadrunner
LIBRR_CFLAGS := -I${LIBRR_DIR}/include/rr/C
LIBRR_CFLAGS := -I${LIBRR_DIR}/include/rr
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 @@ -99,6 +81,8 @@ all: libRoadrunner main.cpp $(ALL_OBJECTS)
$(COMPILE_COMMAND) $(OMP_LIB) -o $(PROGRAM_NAME) $(ALL_OBJECTS) main.cpp -L$(LIBRR_LIBS) -lroadrunner_c_api
@echo
@echo created $(PROGRAM_NAME)
@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

name:
Expand Down
Loading