[PATCH] Correctly set MACOSX_DEPLOYMENT_TARGET on arm, x86, and ppc

Currently the variable MACOSX_DEPLOYMENT_TARGET was being set to 10.7 without regard to the CPU. This does not work because building a binary that targets the Mac OS 10.7 SDK is not possible on PowerPC. This value also prevents the building of an ARM native version for ARM based Macs. So we decide with architecture to use by looking at the CPU of the computer when on Darwin (Mac OS). I would like some feedback on if this patch looks good or if there a problem I'm not seeing. Thank you. --- lib-python/2.7/distutils/sysconfig_pypy.py | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py b/lib-python/2.7/distutils/sysconfig_pypy.py index ec9f5a31db..61ab3d4f7c 100644 --- a/lib-python/2.7/distutils/sysconfig_pypy.py +++ b/lib-python/2.7/distutils/sysconfig_pypy.py @@ -75,18 +75,28 @@ def _init_posix(): g['VERSION'] = get_python_version() if sys.platform[:6] == "darwin": - import platform - if platform.machine() == 'i386': - if platform.architecture()[0] == '32bit': - arch = 'i386' - else: - arch = 'x86_64' + _, _, _, kernel_string, _, = os.uname() + begin = kernel_string.find("_") + 1 # position of the architecture string + arch = kernel_string[begin:] + arch = arch.lower() + + if "arm64" in arch: + arch = "arm64" + g['MACOSX_DEPLOYMENT_TARGET'] = '11.0' + elif "x86_64" in arch: + arch = "x86_64" + g['MACOSX_DEPLOYMENT_TARGET'] = '10.5' + elif "i386" in arch: + arch = "i386" + g['MACOSX_DEPLOYMENT_TARGET'] = '10.4' + elif "ppc" in arch: + arch = "ppc" + g['MACOSX_DEPLOYMENT_TARGET'] = '10.1' else: - # just a guess - arch = platform.machine() + raise Exception("Error in sysconfig_pypy.py: unknown architecture encountered: " + arch) + g['LDSHARED'] += ' -undefined dynamic_lookup' g['CC'] += ' -arch %s' % (arch,) - g['MACOSX_DEPLOYMENT_TARGET'] = '10.7' # pypy only: give us control over the ABI tag in a wheel name if '__pypy__' in sys.builtin_module_names: -- 2.24.3 (Apple Git-128)

Hi, On Sun, 19 Sept 2021 at 22:30, M A <teammember0x01@gmail.com> wrote:
This might need some more care. The value was bumped in the past to 10.7 because we're using important features in that version of OS X, if I remember correctly. It's not a random value we had since the start of the project, because PyPy is much older than that. You or someone else would need to dig into the hg history to figure out why it was the case, and if it's still needed. Armin On Sun, 19 Sept 2021 at 22:30, M A <teammember0x01@gmail.com> wrote:

Hi, On Sun, 19 Sept 2021 at 22:30, M A <teammember0x01@gmail.com> wrote:
This might need some more care. The value was bumped in the past to 10.7 because we're using important features in that version of OS X, if I remember correctly. It's not a random value we had since the start of the project, because PyPy is much older than that. You or someone else would need to dig into the hg history to figure out why it was the case, and if it's still needed. Armin On Sun, 19 Sept 2021 at 22:30, M A <teammember0x01@gmail.com> wrote:
participants (2)
-
Armin Rigo
-
M A