msys2-contrib / cpython-mingw

A friendly fork of CPython which adds support for Mingw-w64 + clang/gcc. See https://github.com/msys2-contrib/cpython-mingw/wiki for details
https://github.com/msys2-contrib/cpython-mingw/wiki
Other
38 stars 12 forks source link

sysconfig.get_platform on arm64 does not contain 'ARM' #174

Open jeremyd2019 opened 3 months ago

jeremyd2019 commented 3 months ago

From msys2/MINGW-packages#20569 cmake attempts to verify that python is targeting arm with the following:

      execute_process (COMMAND ${launcher} "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
        "import sys, sysconfig; sys.stdout.write(sysconfig.get_platform())"
        RESULT_VARIABLE result
        OUTPUT_VARIABLE platform
        ERROR_QUIET
        OUTPUT_STRIP_TRAILING_WHITESPACE)
      string(TOUPPER "${platform}" platform)
      if (result OR ((target_arm AND NOT platform MATCHES "ARM") OR
                     (NOT target_arm AND platform MATCHES "ARM")))
        # interpreter not usable or has wrong architecture

In the case of this fork, sysconfig.get_platform() returns mingw_aarch64, not mingw_arm64 or something similar. I'm not sure whether this should be patched here (probably as part of the 3.12 update), or in cmake (to check for MATCHES "ARM|AARCH" instead) but I wanted to open an issue for it here so it wouldn't be forgotten for 3.12

MehdiChinoune commented 3 months ago

CMake is already patched https://github.com/msys2/MINGW-packages/blob/f7ef8517/mingw-w64-cmake/0003-fix-find-python-on-mingw-aarch64.patch

jeremyd2019 commented 3 months ago

ok, then this issue can just be to decide if we want to take the opportunity to switch the platform to contain arm or rely on continuing to patch cmake.

lazka commented 3 months ago

If aarch64 would be removed we'd have to update the detection in meson: https://github.com/mesonbuild/meson/blob/1a458aacb407e3893b7e832a7a3f75e581c5e3f4/mesonbuild/dependencies/python.py#L196-L204

jeremyd2019 commented 3 months ago

if one or the other would have to be patched, it may be best not to change it