Filter values for get_platform()
(_config_vars, osname, release, machine)
| 498 | |
| 499 | |
| 500 | def get_platform_osx(_config_vars, osname, release, machine): |
| 501 | """Filter values for get_platform()""" |
| 502 | # called from get_platform() in sysconfig and distutils.util |
| 503 | # |
| 504 | # For our purposes, we'll assume that the system version from |
| 505 | # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set |
| 506 | # to. This makes the compatibility story a bit more sane because the |
| 507 | # machine is going to compile and link as if it were |
| 508 | # MACOSX_DEPLOYMENT_TARGET. |
| 509 | |
| 510 | macver = _config_vars.get('MACOSX_DEPLOYMENT_TARGET', '') |
| 511 | if macver and '.' not in macver: |
| 512 | # Ensure that the version includes at least a major |
| 513 | # and minor version, even if MACOSX_DEPLOYMENT_TARGET |
| 514 | # is set to a single-label version like "14". |
| 515 | macver += '.0' |
| 516 | macrelease = _get_system_version() or macver |
| 517 | macver = macver or macrelease |
| 518 | |
| 519 | if macver: |
| 520 | release = macver |
| 521 | osname = "macosx" |
| 522 | |
| 523 | # Use the original CFLAGS value, if available, so that we |
| 524 | # return the same machine type for the platform string. |
| 525 | # Otherwise, distutils may consider this a cross-compiling |
| 526 | # case and disallow installs. |
| 527 | cflags = _config_vars.get(_INITPRE+'CFLAGS', |
| 528 | _config_vars.get('CFLAGS', '')) |
| 529 | if macrelease: |
| 530 | try: |
| 531 | macrelease = tuple(int(i) for i in macrelease.split('.')[0:2]) |
| 532 | except ValueError: |
| 533 | macrelease = (10, 3) |
| 534 | else: |
| 535 | # assume no universal support |
| 536 | macrelease = (10, 3) |
| 537 | |
| 538 | if (macrelease >= (10, 4)) and '-arch' in cflags.strip(): |
| 539 | # The universal build will build fat binaries, but not on |
| 540 | # systems before 10.4 |
| 541 | |
| 542 | machine = 'fat' |
| 543 | |
| 544 | archs = re.findall(r'-arch\s+(\S+)', cflags) |
| 545 | archs = tuple(sorted(set(archs))) |
| 546 | |
| 547 | if len(archs) == 1: |
| 548 | machine = archs[0] |
| 549 | elif archs == ('arm64', 'x86_64'): |
| 550 | machine = 'universal2' |
| 551 | elif archs == ('i386', 'ppc'): |
| 552 | machine = 'fat' |
| 553 | elif archs == ('i386', 'x86_64'): |
| 554 | machine = 'intel' |
| 555 | elif archs == ('i386', 'ppc', 'x86_64'): |
| 556 | machine = 'fat3' |
| 557 | elif archs == ('ppc64', 'x86_64'): |