|
12 | 12 | import sys
|
13 | 13 | import sysconfig
|
14 | 14 | from wheel.bdist_wheel import bdist_wheel
|
| 15 | + |
15 | 16 | if sys.platform == 'win32':
|
16 | 17 | # distutils is deprecated in Python 3.10 and removed in 3.12. However, it still works because Python defines a compatibility interface as long as setuptools is installed.
|
17 | 18 | # We don't have an official alternative for distutils.ccompiler as of September 2024. See: https://github.com/pypa/setuptools/issues/2806
|
18 | 19 | # Once that issue is resolved, we can migrate to the official solution.
|
19 | 20 | # For now, restrict distutils to Windows only, where it's needed.
|
20 | 21 | import distutils.ccompiler
|
21 | 22 |
|
| 23 | +# The minimum MACOSX_DEPLOYMENT_TARGET required for the library. If not |
| 24 | +# set, the library will use the default value from python |
| 25 | +# sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET'). |
| 26 | +MACOS_DEPLOYMENT_TARGET_MIN = "10.15" |
| 27 | + |
| 28 | + |
| 29 | +def parse_version(version_string): |
| 30 | + return tuple(int(x) for x in version_string.split(".")) |
| 31 | + |
22 | 32 |
|
23 | 33 | def is_64bit():
|
24 | 34 | return sys.maxsize > 2 ** 32
|
@@ -231,11 +241,15 @@ def _build_dependencies_impl(self, build_dir, install_path, osx_arch=None):
|
231 | 241 | cmake_args.append('-DAWS_USE_LIBCRYPTO_TO_SUPPORT_ED25519_EVERYWHERE=ON')
|
232 | 242 |
|
233 | 243 | if sys.platform == 'darwin':
|
234 |
| - # build lib with same MACOSX_DEPLOYMENT_TARGET that python will ultimately |
235 |
| - # use to link everything together, otherwise there will be linker warnings. |
| 244 | + # get Python's MACOSX_DEPLOYMENT_TARGET version |
236 | 245 | macosx_target_ver = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
|
237 |
| - if macosx_target_ver and 'MACOSX_DEPLOYMENT_TARGET' not in os.environ: |
238 |
| - cmake_args.append(f'-DCMAKE_OSX_DEPLOYMENT_TARGET={macosx_target_ver}') |
| 246 | + # If MACOS_DEPLOYMENT_TARGET_MIN is set to a later version than python distribution, |
| 247 | + # override MACOSX_DEPLOYMENT_TARGET. |
| 248 | + if macosx_target_ver is None or parse_version( |
| 249 | + MACOS_DEPLOYMENT_TARGET_MIN) > parse_version(macosx_target_ver): |
| 250 | + macosx_target_ver = MACOS_DEPLOYMENT_TARGET_MIN |
| 251 | + os.environ['MACOSX_DEPLOYMENT_TARGET'] = macosx_target_ver |
| 252 | + cmake_args.append(f'-DCMAKE_OSX_DEPLOYMENT_TARGET={macosx_target_ver}') |
239 | 253 |
|
240 | 254 | if osx_arch:
|
241 | 255 | cmake_args.append(f'-DCMAKE_OSX_ARCHITECTURES={osx_arch}')
|
|
0 commit comments