From a43913b7e3b4814b28250c111bc7feba4d59c909 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Mon, 14 Sep 2026 23:02:03 +0200 Subject: [PATCH 1/4] ENH: detect Python x64 on Windows arm64 cross builds --- .github/workflows/debug.yml | 52 +++++++++++++++++++++++++++++++++++++ mesonpy/_windows.py | 36 +++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 .github/workflows/debug.yml create mode 100644 mesonpy/_windows.py diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml new file mode 100644 index 000000000..c2ad89013 --- /dev/null +++ b/.github/workflows/debug.yml @@ -0,0 +1,52 @@ +# 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: + os: + - windows-11-arm + python: + - '3.14' + architecture: + - x64 + - arm64 + + 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: python -c 'import sysconfig; print(sysconfig.get_platform())' + - run: python -c 'import platform; print(platform.machine())' + - run: python -c 'import mesonpy._windows as w; print(w.platform())' diff --git a/mesonpy/_windows.py b/mesonpy/_windows.py new file mode 100644 index 000000000..6083edaec --- /dev/null +++ b/mesonpy/_windows.py @@ -0,0 +1,36 @@ +import ctypes +from ctypes import wintypes + +kernel32 = ctypes.WinDLL('kernel32', use_last_error=True) + +IsWow64Process2 = kernel32.IsWow64Process2 +IsWow64Process2.argtypes = [ + wintypes.HANDLE, + ctypes.POINTER(wintypes.USHORT), + ctypes.POINTER(wintypes.USHORT), +] +IsWow64Process2.restype = wintypes.BOOL + +IMAGE_FILE_MACHINE_UNKNOWN = 0x0000 +IMAGE_FILE_MACHINE_AMD64 = 0x8664 +IMAGE_FILE_MACHINE_ARM64 = 0xAA64 +IMAGE_FILE_MACHINE_I386 = 0x014c + +MACHINE = { + IMAGE_FILE_MACHINE_UNKNOWN: 'unknown', # native, no WOW64 + IMAGE_FILE_MACHINE_AMD64: 'amd64', + IMAGE_FILE_MACHINE_ARM64: 'arm64', + IMAGE_FILE_MACHINE_I386: 'x86', +} + +def platform(): + handle = kernel32.GetCurrentProcess() + + process = wintypes.USHORT() + native = wintypes.USHORT() + + r = IsWow64Process2(handle, ctypes.byref(process), ctypes.byref(native)) + if not r: + raise ctypes.WinError(ctypes.get_last_error()) + + return native.value, process.value, MACHINE[native.value], MACHINE[process.value] From 658b202792495da70e2e2327cc4ea271d0675a5f Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Tue, 15 Sep 2026 21:21:47 +0200 Subject: [PATCH 2/4] debug --- .github/workflows/tests.yml | 361 ------------------------------------ 1 file changed, 361 deletions(-) delete mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 517b6d26d..000000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,361 +0,0 @@ -# SPDX-FileCopyrightText: 2021 The meson-python developers -# -# SPDX-License-Identifier: MIT - -name: tests - -on: - push: - branches: - - main - - release-* - pull_request: - branches: - - main - - release-* - paths: - # This is spelt like this to do not ignore the docs/examples/ folder. - - '**' - - '!docs/**' - - '!CHANGELOG.rst' - - '!LICENSE' - - '!LICENSES/**' - - '!README.rst' - - '!.github/workflows/docs.yml' - workflow_dispatch: - # Allow to run manually - -permissions: {} - -env: - FORCE_COLOR: 1 - PIP_DISABLE_PIP_VERSION_CHECK: 1 - -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: - os: - - ubuntu-latest - - windows-latest - - macos-latest - # GitHub Actions switched to macOS on amr64 by default. Keep - # a job running on macOS on x86-64 for a while longer. - - macos-15-intel - python: - - '3.10' - - '3.15' - meson: - - - dependencies: - - - include: - - os: ubuntu-latest - python: 'pypy-3.11' - # Test with older supported Meson version. Meson up to - # version 1.2.3 requires distutils, which has been removed - # from the stdlib in Python 3.12, thus test with Pythn 3.11. - # To avoid having too many CI jobs, combine this with tests - # with the minimum version of other dependencies. - - os: ubuntu-latest - python: '3.11' - meson: '~=0.64.0' - - os: ubuntu-latest - python: '3.11' - meson: '~=1.0.0' - - os: ubuntu-latest - python: '3.11' - meson: '~=1.1.0' - - os: ubuntu-latest - python: '3.12' - meson: '~=1.2.3' - - os: ubuntu-latest - python: '3.12' - meson: '~=1.3.0' - - os: ubuntu-latest - python: '3.12' - meson: '~=1.4.0' - - os: ubuntu-latest - python: '3.12' - meson: '~=1.5.0' - dependencies: 'packaging==23.2 pyproject-metadata==0.9.0' - - os: ubuntu-latest - python: '3.12' - meson: '~=1.6.0' - dependencies: 'pyproject-metadata==0.9.0' - - os: ubuntu-latest - python: '3.12' - meson: '~=1.7.0' - dependencies: 'packaging==23.2' - - os: ubuntu-latest - python: '3.13' - meson: '~=1.8.0' - # Test with Meson master branch. - - os: ubuntu-latest - python: '3.14' - meson: '@git+https://github.com/mesonbuild/meson.git' - - os: windows-latest - python: '3.14' - meson: '@git+https://github.com/mesonbuild/meson.git' - # Test free-threaded builds to verify the correct handling of the - # 'abi3t' stable ABI, see PEP 803. Test on Linux and Windows to cover - # the case where stable ABI extension modules use a dedicated - # filename suffix and the case where they do not. - - os: ubuntu-latest - python: '3.15t' - - os: windows-latest - python: '3.15t' - - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - persist-credentials: false - - - name: Set up target Python - uses: actions/setup-python@v7 - with: - python-version: ${{ matrix.python }} - allow-prereleases: true - - - name: Install Ninja - run: sudo apt-get install ninja-build - if: ${{ runner.os == 'Linux' }} - - - name: Install Ninja - run: brew install ninja - if: ${{ runner.os == 'macOS' }} - - - name: Install Ninja - run: python -m pip install ninja - if: ${{ runner.os == 'Windows' }} - - - name: Install Meson - run: python -m pip install "meson ${{ matrix.meson }}" - if: ${{ matrix.meson }} - - - name: Install dependencies - run: python -m pip install ${{ matrix.dependencies }} - if: ${{ matrix.dependencies }} - - - name: Install - run: python -m pip install . --group test - - - name: Run tests - run: python -m pytest --showlocals -vv --cov --cov-report=xml - - - name: Upload coverage report - uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 - if: ${{ always() }} - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - msvc: - runs-on: windows-latest - strategy: - fail-fast: false - matrix: - python: - - '3.11' - meson: - - - - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - persist-credentials: false - - - name: Set up target Python - uses: actions/setup-python@v7 - with: - python-version: ${{ matrix.python }} - - - name: Install Ninja - run: python -m pip install ninja - - - name: Setup MSVC - uses: bus1/cabuild/action/msdevshell@06ea2833eef61e9b0d0ce0d728416e617e4fb1fe # v1 - with: - architecture: x64 - - - name: Install Meson - run: python -m pip install "meson ${{ matrix.meson }}" - if: ${{ matrix.meson }} - - - name: Install - run: python -m pip install . --group test - - - name: Run tests - run: python -m pytest --showlocals -vv - - cygwin: - runs-on: windows-latest - strategy: - fail-fast: false - matrix: - python: - - '3.12' - meson: - - - - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - persist-credentials: false - - - name: Setup Cygwin - uses: cygwin/cygwin-install-action@3f0a3f9f988f7e96b8c18098ae05eaec175f5b52 # v6 - with: - packages: >- - python312 - python312-devel - python312-pip - python312-setuptools - python312-virtualenv - cmake - gcc-core - gcc-g++ - git - make - ninja - - - name: Fix git dubious ownership - # This addresses the "fatal: detected dubious ownership in - # repository" and "fatal: not in a git directory" errors - # encountered when trying to run Cygwin git in a directory not - # owned by the current user. This happens when the tests run - # Cygwin git in a directory outside the Cygwin filesystem. - run: git config --global --add safe.directory '*' - shell: C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 CHERE_INVOKING=1 C:\cygwin\bin\bash.exe -leo pipefail -o igncr {0} - - - name: Get pip cache path - id: pip-cache-path - run: echo "path=$(cygpath -w $(python -m pip cache dir))" >> $GITHUB_OUTPUT - shell: C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 CHERE_INVOKING=1 C:\cygwin\bin\bash.exe -leo pipefail -o igncr {0} - - - name: Restore cache - # Cygwin Python cannot use binary wheels from PyPI. Building - # some dependencies takes considerable time. Caching the built - # wheels speeds up the CI job quite a bit. - uses: actions/cache@v6 - with: - path: ${{ steps.pip-cache-path.outputs.path }} - key: cygwin-pip-${{ github.sha }} - restore-keys: cygwin-pip- - lookup-only: true - - - name: Install Meson - run: python -m pip install "meson ${{ matrix.meson }}" - if: ${{ matrix.meson }} - shell: C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 CHERE_INVOKING=1 C:\cygwin\bin\bash.exe -leo pipefail -o igncr {0} - - - name: Install - run: python -m pip install . --group test - shell: C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 CHERE_INVOKING=1 C:\cygwin\bin\bash.exe -leo pipefail -o igncr {0} - - - name: Run tests - run: python -m pytest --showlocals -vv - shell: C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 CHERE_INVOKING=1 C:\cygwin\bin\bash.exe -leo pipefail -o igncr {0} - - homebrew: - runs-on: macos-latest - strategy: - fail-fast: false - matrix: - python: - - '3.10' - - '3.12' - meson: - - - - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - persist-credentials: false - - - name: Install Homebrew Python - run: | - brew install --overwrite python@${{ matrix.python }} - echo /opt/homebrew/opt/python@${{ matrix.python }}/libexec/bin/ >> $GITHUB_PATH - python${{ matrix.python }} -m pip config set global.break-system-packages true - - - name: Check Python version - run: python --version | grep ${{ matrix.python }} - - - name: Install Ninja - run: brew install ninja - - - name: Install Meson - run: python -m pip install "meson ${{ matrix.meson }}" - if: ${{ matrix.meson }} - - - name: Install - run: python -m pip install . --group test - - - name: Run tests - run: python -m pytest --showlocals -vv - - mypy: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - persist-credentials: false - - - name: Setup Python - uses: actions/setup-python@v7 - with: - python-version: '3.10' - - - name: Install dependencies - run: python -m pip install . - - - name: Install mypy - run: python -m pip install mypy~=2.3.1 - - - name: Run mypy - run: mypy -p mesonpy - - pixi: - runs-on: ubuntu-24.04-arm - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - persist-credentials: false - - - uses: prefix-dev/setup-pixi@f00437f565399d418b0acc85936d12c1fb668347 # v0.10.1 - with: - pixi-version: v0.77.1 - manifest-path: .github/workflows/pixi.toml - cache: false - - - name: Run tests - working-directory: .github/workflows - run: pixi run test - - uv-sync: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - with: - persist-credentials: false - - - name: Install uv - uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0 - with: - enable-cache: false - version: "0.12.13" # Released on 2026-09-10 - - # Ensure that dependencies and dependency groups are consistent and resolvable. - - run: uv sync --all-extras --all-groups --dry-run From d917445b7a930eb32048d84c28237c89d04bcf8d Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Tue, 15 Sep 2026 21:34:49 +0200 Subject: [PATCH 3/4] foo --- .github/workflows/debug.yml | 2 +- mesonpy/_windows.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index c2ad89013..4354712a7 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -49,4 +49,4 @@ jobs: - run: python -c 'import sysconfig; print(sysconfig.get_platform())' - run: python -c 'import platform; print(platform.machine())' - - run: python -c 'import mesonpy._windows as w; print(w.platform())' + - run: python -c 'import mesonpy._windows as w; print(w.platform()); print(w.pp())' diff --git a/mesonpy/_windows.py b/mesonpy/_windows.py index 6083edaec..5ce4a6c53 100644 --- a/mesonpy/_windows.py +++ b/mesonpy/_windows.py @@ -34,3 +34,13 @@ def platform(): raise ctypes.WinError(ctypes.get_last_error()) return native.value, process.value, MACHINE[native.value], MACHINE[process.value] + + +def pp(): + import subprocess + + result = subprocess.run( + ["powershell", "-NoProfile", "-Command", "(Get-CimInstance Win32_Processor).Architecture"], + capture_output=True, text=True, check=True) + + return result From 5f77065f2657f159db39862bd2d5333bd0c18dc4 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Tue, 15 Sep 2026 21:50:32 +0200 Subject: [PATCH 4/4] debug --- .github/workflows/debug.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 4354712a7..4a3cd21a7 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -26,14 +26,19 @@ jobs: strategy: fail-fast: false matrix: - os: - - windows-11-arm - python: - - '3.14' - architecture: - - x64 - - arm64 - + 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: