Переглянути джерело

Fix MACOSX_DEPLOYMENT_TARGET mismatch

Bo Yang 6 роки тому
батько
коміт
9afc16d290
2 змінених файлів з 7 додано та 2 видалено
  1. 0 1
      kokoro/macos/python_cpp/build.sh
  2. 7 1
      python/setup.py

+ 0 - 1
kokoro/macos/python_cpp/build.sh

@@ -9,5 +9,4 @@ cd $(dirname $0)/../../..
 source kokoro/macos/prepare_build_macos_rc
 source kokoro/macos/prepare_build_macos_rc
 g++ --version
 g++ --version
 
 
-export MACOSX_DEPLOYMENT_TARGET=10.9
 ./tests.sh python_cpp
 ./tests.sh python_cpp

+ 7 - 1
python/setup.py

@@ -190,7 +190,13 @@ if __name__ == '__main__':
     # C++ projects must now migrate to libc++ and are recommended to set a
     # C++ projects must now migrate to libc++ and are recommended to set a
     # deployment target of macOS 10.9 or later, or iOS 7 or later.
     # deployment target of macOS 10.9 or later, or iOS 7 or later.
     if sys.platform == 'darwin':
     if sys.platform == 'darwin':
-      os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
+      mac_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
+      if mac_target and (pkg_resources.parse_version(mac_target) <
+                       pkg_resources.parse_version('10.9.0')):
+        os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
+        os.environ['_PYTHON_HOST_PLATFORM'] = re.sub(
+            r'macosx-[0-9]+\.[0-9]+-(.+)', r'macosx-10.9-\1',
+            util.get_platform())
 
 
     # https://github.com/Theano/Theano/issues/4926
     # https://github.com/Theano/Theano/issues/4926
     if sys.platform == 'win32':
     if sys.platform == 'win32':