Skip to content

Commit 29c0062

Browse files
committed
ENH: detect Python x64 on Windows arm64 cross builds
1 parent 51c6910 commit 29c0062

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

‎.github/workflows/debug.yml‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# SPDX-FileCopyrightText: 2021 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
name: debug
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
- release-*
12+
pull_request:
13+
branches:
14+
- main
15+
- release-*
16+
17+
permissions: {}
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
test:
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
include:
30+
- os: windows-11-arm
31+
python: '3.14'
32+
architecture: x64
33+
- os: windows-11-arm
34+
python: '3.14'
35+
architecture: arm64
36+
- os: windows-latest
37+
python: '3.14'
38+
- os: windows-latest
39+
python: '3.14'
40+
architecture: x86
41+
42+
steps:
43+
- uses: actions/checkout@v7
44+
with:
45+
persist-credentials: false
46+
47+
- uses: actions/setup-python@v7
48+
with:
49+
python-version: ${{ matrix.python }}
50+
architecture: ${{ matrix.architecture }}
51+
allow-prereleases: true
52+
53+
- run: python -m pip install .
54+
55+
- run: |
56+
import platform
57+
import mesonpy
58+
print('interpreter:', mesonpy._windows_interpreter_arch())
59+
print('platform:', platform.machine().lower())
60+
shell: python

‎mesonpy/__init__.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,18 @@ def _showwarning(message: Union[Warning, str], category: Type[Warning], filename
256256
_log(f'{style.WARNING}meson-python: warning:{style.RESET} {message}')
257257

258258

259+
def _windows_interpreter_arch() -> str:
260+
"""Return the Windows architecture for which the Python interpreter has been compiled."""
261+
match sysconfig.get_platform():
262+
case 'win32':
263+
return 'x86'
264+
case 'win-amd64':
265+
return 'amd64'
266+
case 'win-arm64':
267+
return 'arm64'
268+
raise ValueError
269+
270+
259271
class _clicounter:
260272
def __init__(self, total: int) -> None:
261273
self._total = total
@@ -846,6 +858,13 @@ def __init__(self,
846858
self._meson_cross_file.write_text(cross_file_data, encoding='utf-8')
847859
self._meson_args['setup'].extend(('--cross-file', os.fspath(self._meson_cross_file)))
848860

861+
elif sys.platform == 'win32':
862+
arch = _windows_interpreter_arch()
863+
nativearch = platform.machine().lower()
864+
865+
if arch != nativearch:
866+
pass
867+
849868
# write the native file
850869
native_file_data = textwrap.dedent(f'''
851870
[binaries]

0 commit comments

Comments
 (0)