37 lines · python
1import subprocess2 3 4def getRoot(config):5 if not config.parent:6 return config7 return getRoot(config.parent)8 9 10root = getRoot(config)11 12if root.target_os not in ["Darwin"]:13 config.unsupported = True14 15 16def get_product_version():17 try:18 version_process = subprocess.run(19 ["sw_vers", "-productVersion"],20 check=True,21 stdout=subprocess.PIPE,22 stderr=subprocess.PIPE,23 )24 version_string = version_process.stdout.decode("utf-8").split("\n")[0]25 version_split = version_string.split(".")26 return (int(version_split[0]), int(version_split[1]))27 except:28 return (0, 0)29 30 31macos_version_major, macos_version_minor = get_product_version()32if config.apple_platform == "osx":33 if macos_version_major > 10 and macos_version_minor > 11:34 config.available_features.add("mac-os-10-11-or-higher")35 else:36 config.available_features.add("mac-os-10-10-or-lower")37