From 6411b5f65d5938b96f319adb4e0d5f0ab76ed423 Mon Sep 17 00:00:00 2001 From: jimreesman Date: Thu, 11 Feb 2016 10:17:13 -0500 Subject: [PATCH] detect OS X, and query sysconfig for libdir --- setup.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/setup.py b/setup.py index 82b5a85d6..8f9b35dcc 100644 --- a/setup.py +++ b/setup.py @@ -466,6 +466,19 @@ class build(_build): if sys.version_info >= (3, 0): cmake_extra_arch += ['-DPYTHON3=yes'] + log.info("Detected platform: %s" % sys.platform) + if sys.platform == "darwin": + # build on OS X + inc_dir = get_python_inc() + cmake_extra_arch += ['-DPYTHON_INCLUDE_DIR={inc}'.format(inc=inc_dir)] + + # by default, cmake will choose the system python lib in /usr/lib + # this checks the sysconfig and will correctly pick up a brewed python lib + # e.g. in /usr/local/Cellar + py_ver = get_python_version() + py_lib = os.path.join(get_config_var('LIBDIR'), 'libpython'+py_ver+'.dylib') + cmake_extra_arch += ['-DPYTHON_LIBRARY={lib}'.format(lib=py_lib)] + if platform_arch == '64bit' and sys.platform == "win32": # 64bit build on Windows