From 98c066e822d1cbc2abbe0016f74be594b5c6e5a2 Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Mon, 22 Feb 2016 17:35:03 -0800 Subject: [PATCH] install on mac osx --- CMakeLists.txt | 6 +++++- lib/orchpy/orchpy/__init__.py | 6 ++++-- lib/orchpy/setup.py | 12 +++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7777ca8af..6a3a903dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ find_package(Protobuf REQUIRED) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") include_directories("${CMAKE_SOURCE_DIR}/include") +include_directories("/usr/local/include") set(PROTO_PATH "${CMAKE_SOURCE_DIR}/protos") @@ -63,7 +64,10 @@ set(GENERATED_PROTOBUF_FILES ${ORCHESTRA_PB_H_FILE} ${ORCHESTRA_PB_CPP_FILE} ${TYPES_GRPC_PB_H_FILE} ${TYPES_GRPC_PB_CPP_FILE}) include_directories(${GENERATED_PROTOBUF_PATH}) -link_libraries(grpc++_unsecure grpc pthread rt ${PROTOBUF_LIBRARY}) +link_libraries(grpc++_unsecure grpc pthread ${PROTOBUF_LIBRARY}) +if (UNIX AND NOT APPLE) + link_libraries(rt) +endif() add_executable(objstore src/objstore.cc ${GENERATED_PROTOBUF_FILES}) add_executable(scheduler_server src/scheduler_server.cc ${GENERATED_PROTOBUF_FILES}) diff --git a/lib/orchpy/orchpy/__init__.py b/lib/orchpy/orchpy/__init__.py index 09ae04de5..cdf0cd44e 100644 --- a/lib/orchpy/orchpy/__init__.py +++ b/lib/orchpy/orchpy/__init__.py @@ -1,6 +1,8 @@ -import os, ctypes +import os, sys, ctypes + +MACOSX = (sys.platform in ['darwin']) _orchlib_handle = ctypes.CDLL( - os.path.join(os.path.dirname(os.path.abspath(__file__)), 'liborchlib.so'), + os.path.join(os.path.dirname(os.path.abspath(__file__)), 'liborchlib.dylib' if MACOSX else 'liborchlib.so'), ctypes.RTLD_GLOBAL ) diff --git a/lib/orchpy/setup.py b/lib/orchpy/setup.py index 477a50833..c5ca2dcda 100644 --- a/lib/orchpy/setup.py +++ b/lib/orchpy/setup.py @@ -1,19 +1,23 @@ +import sys + from setuptools import setup, Extension, find_packages from Cython.Build import cythonize # because of relative paths, this must be run from inside orch/lib/orchpy/ +MACOSX = (sys.platform in ['darwin']) + setup( name = "orchestra", version = "0.1.dev0", ext_modules = cythonize([ Extension("orchpy/worker", - include_dirs = ["../../src"], + include_dirs = ["../../src", "/usr/local/include/"], sources = ["orchpy/worker.pyx"], extra_link_args=["-Iorchpy -lorchlib"], language = "c++"), Extension("orchpy/unison", - include_dirs = ["../../src/"], + include_dirs = ["../../src/", "/usr/local/include/"], sources = ["orchpy/unison.pyx"], extra_link_args=["-Iorchpy -lorchlib"], language = "c++")], @@ -21,7 +25,9 @@ setup( use_2to3=True, packages=find_packages(), package_data = { - 'orchpy': ['liborchlib.so', 'scheduler_server', 'objstore'] + 'orchpy': ['liborchlib.dylib' if MACOSX else 'liborchlib.so', + 'scheduler_server', + 'objstore'] }, zip_safe=False )