detect OS X, and query sysconfig for libdir

This commit is contained in:
jimreesman 2016-02-11 10:17:13 -05:00
parent c9090bfdfb
commit 6411b5f65d
1 changed files with 13 additions and 0 deletions

View File

@ -466,6 +466,19 @@ class build(_build):
if sys.version_info >= (3, 0): if sys.version_info >= (3, 0):
cmake_extra_arch += ['-DPYTHON3=yes'] 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": if platform_arch == '64bit' and sys.platform == "win32":
# 64bit build on Windows # 64bit build on Windows