From 29c00629b4185e75c0312122ebff123c088fc8f3 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Mon, 14 Sep 2026 23:02:03 +0200 Subject: [PATCH] ENH: detect Python x64 on Windows arm64 cross builds --- .github/workflows/debug.yml | 60 +++++++++++++++++++++++++++++++++++++ mesonpy/__init__.py | 19 ++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .github/workflows/debug.yml diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml new file mode 100644 index 000000000..a4a336438 --- /dev/null +++ b/.github/workflows/debug.yml @@ -0,0 +1,60 @@ +# SPDX-FileCopyrightText: 2021 The meson-python developers +# +# SPDX-License-Identifier: MIT + +name: debug + +on: + push: + branches: + - main + - release-* + pull_request: + branches: + - main + - release-* + +permissions: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: windows-11-arm + python: '3.14' + architecture: x64 + - os: windows-11-arm + python: '3.14' + architecture: arm64 + - os: windows-latest + python: '3.14' + - os: windows-latest + python: '3.14' + architecture: x86 + + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + + - uses: actions/setup-python@v7 + with: + python-version: ${{ matrix.python }} + architecture: ${{ matrix.architecture }} + allow-prereleases: true + + - run: python -m pip install . + + - run: | + import platform + import mesonpy + print('interpreter:', mesonpy._windows_interpreter_arch()) + print('platform:', platform.machine().lower()) + shell: python diff --git a/mesonpy/__init__.py b/mesonpy/__init__.py index a397db8a1..6860e86f7 100644 --- a/mesonpy/__init__.py +++ b/mesonpy/__init__.py @@ -256,6 +256,18 @@ def _showwarning(message: Union[Warning, str], category: Type[Warning], filename _log(f'{style.WARNING}meson-python: warning:{style.RESET} {message}') +def _windows_interpreter_arch() -> str: + """Return the Windows architecture for which the Python interpreter has been compiled.""" + match sysconfig.get_platform(): + case 'win32': + return 'x86' + case 'win-amd64': + return 'amd64' + case 'win-arm64': + return 'arm64' + raise ValueError + + class _clicounter: def __init__(self, total: int) -> None: self._total = total @@ -846,6 +858,13 @@ def __init__(self, self._meson_cross_file.write_text(cross_file_data, encoding='utf-8') self._meson_args['setup'].extend(('--cross-file', os.fspath(self._meson_cross_file))) + elif sys.platform == 'win32': + arch = _windows_interpreter_arch() + nativearch = platform.machine().lower() + + if arch != nativearch: + pass + # write the native file native_file_data = textwrap.dedent(f''' [binaries]