From 06a54018c8a9fd9a7be5f5b56414b5da9259f637 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 29 Oct 2020 11:37:42 -0400 Subject: [PATCH] fix: min macos (#2622) --- pybind11/setup_helpers.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pybind11/setup_helpers.py b/pybind11/setup_helpers.py index 8360970e..2dcbab4e 100644 --- a/pybind11/setup_helpers.py +++ b/pybind11/setup_helpers.py @@ -45,6 +45,7 @@ import shutil import sys import tempfile import threading +import platform import warnings try: @@ -177,10 +178,14 @@ class Pybind11Extension(_Extension): if MACOS and "MACOSX_DEPLOYMENT_TARGET" not in os.environ: # C++17 requires a higher min version of macOS. An earlier version - # can be set manually via environment variable if you are careful - # in your feature usage, but 10.14 is the safest setting for - # general use. - macosx_min = "-mmacosx-version-min=" + ("10.9" if level < 17 else "10.14") + # (10.12 or 10.13) can be set manually via environment variable if + # you are careful in your feature usage, but 10.14 is the safest + # setting for general use. However, never set higher than the + # current macOS version! + current_macos = tuple(int(x) for x in platform.mac_ver()[0].split(".")[:2]) + desired_macos = (10, 9) if level < 17 else (10, 14) + macos_string = ".".join(str(x) for x in min(current_macos, desired_macos)) + macosx_min = "-mmacosx-version-min=" + macos_string self.extra_compile_args.append(macosx_min) self.extra_link_args.append(macosx_min)