From 58feec8cdaa858fb09ff23b7af608474f29f4416 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 11 Nov 2021 19:59:35 +1100 Subject: [PATCH] Only prefer command line tools SDK on macOS over the default --- setup.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index 75b87ba97f4..9a6e7a72a58 100755 --- a/setup.py +++ b/setup.py @@ -532,16 +532,24 @@ def build_extensions(self): _add_directory(include_dirs, "/usr/X11/include") # SDK install path - sdk_path = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" - if not os.path.exists(sdk_path): - try: - sdk_path = ( - subprocess.check_output(["xcrun", "--show-sdk-path"]) - .strip() - .decode("latin1") - ) - except Exception: - sdk_path = None + try: + sdk_path = ( + subprocess.check_output(["xcrun", "--show-sdk-path"]) + .strip() + .decode("latin1") + ) + except Exception: + sdk_path = None + if ( + not sdk_path + or sdk_path + == "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" + ): + commandlinetools_sdk_path = ( + "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" + ) + if os.path.exists(commandlinetools_sdk_path): + sdk_path = commandlinetools_sdk_path if sdk_path: _add_directory(library_dirs, os.path.join(sdk_path, "usr", "lib")) _add_directory(include_dirs, os.path.join(sdk_path, "usr", "include"))