From 5667a08c3af1c3d41e28236e8544033c3408993f Mon Sep 17 00:00:00 2001 From: Omar Valsson <omar.valsson@gmail.com> Date: Thu, 21 Feb 2019 16:05:24 +0100 Subject: [PATCH] Fix for problem with compiling the PYTHON interface in Mac OS 10.14 and higher. Sets the deployment target to 10.9 when compiling on version 10.9 and above. The fix is taken from https://github.com/pandas-dev/pandas/pull/24274/files GB: removed whitespace change and merged. Closes #445 Thanks @valsson --- python/setup.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/python/setup.py b/python/setup.py index f4a3c4553..3e9df6f9a 100644 --- a/python/setup.py +++ b/python/setup.py @@ -29,6 +29,13 @@ import os import os.path import sys from shutil import copyfile +import platform +from distutils.sysconfig import get_config_var +from distutils.version import LooseVersion + + +def is_platform_mac(): + return sys.platform == 'darwin' if os.getenv("plumed_macports") is not None: copyfile("../VERSION","VERSION") @@ -52,6 +59,19 @@ if defaultkernel is not None: extra_compile_args.append("-D__PLUMED_DEFAULT_KERNEL=" + os.path.abspath(defaultkernel)) print( "Hardcoded PLUMED_KERNEL " + os.path.abspath(defaultkernel)) +# Fixes problem with compiling the PYTHON interface in Mac OS 10.14 and higher. +# Sets the deployment target to 10.9 when compiling on version 10.9 and above, +# overriding distutils behaviour to target the Mac OS version python was built for. +# This can be overridden by setting MACOSX_DEPLOYMENT_TARGET before compiling the +# python interface. +# This fix is taken from https://github.com/pandas-dev/pandas/pull/24274/files +if is_platform_mac(): + if 'MACOSX_DEPLOYMENT_TARGET' not in os.environ: + current_system = LooseVersion(platform.mac_ver()[0]) + python_target = LooseVersion(get_config_var('MACOSX_DEPLOYMENT_TARGET')) + if python_target < '10.9' and current_system >= '10.9': + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9' + def readme(): with open('README.rst') as f: return f.read() -- GitLab