[Build] Override MACOSX_DEPLOYMENT_TARGET for gRPC Python (#37997) · grpc/grpc@14ac94d (original) (raw)
File tree
3 files changed
lines changed
- src/python/grpcio_observability
- tools/distrib/python/grpcio_tools
3 files changed
lines changed
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -236,6 +236,21 @@ def check_linker_need_libatomic(): | ||
| 236 | 236 | return cpp_test.returncode == 0 |
| 237 | 237 | |
| 238 | 238 | |
| 239 | +# When building extensions for macOS on a system running macOS 10.14 or newer, | |
| 240 | +# make sure they target macOS 10.14 or newer to use C++17 stdlib properly. | |
| 241 | +# This overrides the default behavior of distutils, which targets the macOS | |
| 242 | +# version Python was built on. You can further customize the target macOS | |
| 243 | +# version by setting the MACOSX_DEPLOYMENT_TARGET environment variable before | |
| 244 | +# running setup.py. | |
| 245 | +if sys.platform == "darwin": | |
| 246 | +if "MACOSX_DEPLOYMENT_TARGET" not in os.environ: | |
| 247 | +target_ver = sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET") | |
| 248 | +if target_ver == "" or tuple(int(p) for p in target_ver.split(".")) < ( | |
| 249 | +10, | |
| 250 | +14, | |
| 251 | + ): | |
| 252 | +os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.14" | |
| 253 | + | |
| 239 | 254 | # There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are |
| 240 | 255 | # entirely ignored/dropped/forgotten by distutils and its Cygwin/MinGW support. |
| 241 | 256 | # We use these environment variables to thus get around that without locking |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -138,6 +138,21 @@ def get_ext_filename(self, ext_name): | ||
| 138 | 138 | return filename |
| 139 | 139 | |
| 140 | 140 | |
| 141 | +# When building extensions for macOS on a system running macOS 10.14 or newer, | |
| 142 | +# make sure they target macOS 10.14 or newer to use C++17 stdlib properly. | |
| 143 | +# This overrides the default behavior of distutils, which targets the macOS | |
| 144 | +# version Python was built on. You can further customize the target macOS | |
| 145 | +# version by setting the MACOSX_DEPLOYMENT_TARGET environment variable before | |
| 146 | +# running setup.py. | |
| 147 | +if sys.platform == "darwin": | |
| 148 | +if "MACOSX_DEPLOYMENT_TARGET" not in os.environ: | |
| 149 | +target_ver = sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET") | |
| 150 | +if target_ver == "" or tuple(int(p) for p in target_ver.split(".")) < ( | |
| 151 | +10, | |
| 152 | +14, | |
| 153 | + ): | |
| 154 | +os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.14" | |
| 155 | + | |
| 141 | 156 | # There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are |
| 142 | 157 | # entirely ignored/dropped/forgotten by distutils and its Cygwin/MinGW support. |
| 143 | 158 | # We use these environment variables to thus get around that without locking |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -157,6 +157,21 @@ def new_compile(obj, src, ext, cc_args, extra_postargs, pp_opts): | ||
| 157 | 157 | build_ext.build_ext.build_extensions(self) |
| 158 | 158 | |
| 159 | 159 | |
| 160 | +# When building extensions for macOS on a system running macOS 10.14 or newer, | |
| 161 | +# make sure they target macOS 10.14 or newer to use C++17 stdlib properly. | |
| 162 | +# This overrides the default behavior of distutils, which targets the macOS | |
| 163 | +# version Python was built on. You can further customize the target macOS | |
| 164 | +# version by setting the MACOSX_DEPLOYMENT_TARGET environment variable before | |
| 165 | +# running setup.py. | |
| 166 | +if sys.platform == "darwin": | |
| 167 | +if "MACOSX_DEPLOYMENT_TARGET" not in os.environ: | |
| 168 | +target_ver = sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET") | |
| 169 | +if target_ver == "" or tuple(int(p) for p in target_ver.split(".")) < ( | |
| 170 | +10, | |
| 171 | +14, | |
| 172 | + ): | |
| 173 | +os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.14" | |
| 174 | + | |
| 160 | 175 | # There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are |
| 161 | 176 | # entirely ignored/dropped/forgotten by distutils and its Cygwin/MinGW support. |
| 162 | 177 | # We use these environment variables to thus get around that without locking |