[Build] Override MACOSX_DEPLOYMENT_TARGET for gRPC Python (#37997)

CPython uses this [logic](b98602705f/cibuildwheel/macos.py (L302-L323)) to determine `MACOSX_DEPLOYMENT_TARGET` and the lowest possible value is `10.9` (Mavericks) as of today. But we need to use at least `10.14` (Mojave) to get prepared for upcoming C++17 upgrade (scheduled in 2024-11). This `10.14` version should be safe to use as i) Apple stopped supporting any versions older than 12.0 (https://endoflife.date/macos) and ii) this version is older than officially support OSX version (11.0) of gRPC Core/C++ (https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md)

Closes #37997

PiperOrigin-RevId: 691535457
pull/37207/head
Esun Kim 4 weeks ago committed by Copybara-Service
parent 84b4525fdd
commit 14ac94d923
  1. 15
      setup.py
  2. 15
      src/python/grpcio_observability/setup.py
  3. 15
      tools/distrib/python/grpcio_tools/setup.py

@ -236,6 +236,21 @@ def check_linker_need_libatomic():
return cpp_test.returncode == 0
# When building extensions for macOS on a system running macOS 10.14 or newer,
# make sure they target macOS 10.14 or newer to use C++17 stdlib properly.
# This overrides the default behavior of distutils, which targets the macOS
# version Python was built on. You can further customize the target macOS
# version by setting the MACOSX_DEPLOYMENT_TARGET environment variable before
# running setup.py.
if sys.platform == "darwin":
if "MACOSX_DEPLOYMENT_TARGET" not in os.environ:
target_ver = sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET")
if target_ver == "" or tuple(int(p) for p in target_ver.split(".")) < (
10,
14,
):
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.14"
# There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are
# entirely ignored/dropped/forgotten by distutils and its Cygwin/MinGW support.
# We use these environment variables to thus get around that without locking

@ -138,6 +138,21 @@ class BuildExt(build_ext.build_ext):
return filename
# When building extensions for macOS on a system running macOS 10.14 or newer,
# make sure they target macOS 10.14 or newer to use C++17 stdlib properly.
# This overrides the default behavior of distutils, which targets the macOS
# version Python was built on. You can further customize the target macOS
# version by setting the MACOSX_DEPLOYMENT_TARGET environment variable before
# running setup.py.
if sys.platform == "darwin":
if "MACOSX_DEPLOYMENT_TARGET" not in os.environ:
target_ver = sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET")
if target_ver == "" or tuple(int(p) for p in target_ver.split(".")) < (
10,
14,
):
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.14"
# There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are
# entirely ignored/dropped/forgotten by distutils and its Cygwin/MinGW support.
# We use these environment variables to thus get around that without locking

@ -157,6 +157,21 @@ class BuildExt(build_ext.build_ext):
build_ext.build_ext.build_extensions(self)
# When building extensions for macOS on a system running macOS 10.14 or newer,
# make sure they target macOS 10.14 or newer to use C++17 stdlib properly.
# This overrides the default behavior of distutils, which targets the macOS
# version Python was built on. You can further customize the target macOS
# version by setting the MACOSX_DEPLOYMENT_TARGET environment variable before
# running setup.py.
if sys.platform == "darwin":
if "MACOSX_DEPLOYMENT_TARGET" not in os.environ:
target_ver = sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET")
if target_ver == "" or tuple(int(p) for p in target_ver.split(".")) < (
10,
14,
):
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.14"
# There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are
# entirely ignored/dropped/forgotten by distutils and its Cygwin/MinGW support.
# We use these environment variables to thus get around that without locking

Loading…
Cancel
Save