Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,34 @@ jobs:
PYMSBUILD_LAYOUT_DIR: ${{ runner.temp }}/layout
TEST_MSIX_DIR: ${{ runner.temp }}/test_msix

- name: 'Upload build output'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: packages
path: ${{ runner.temp }}/dist

test:
name: 'Test (${{ matrix.runner }})'
needs: build
strategy:
fail-fast: false
matrix:
runner:
- windows-latest
- windows-11-vs2026-arm
runs-on: ${{ matrix.runner }}

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: 'Download build output'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: packages
path: ${{ runner.temp }}/dist

- name: 'Register unsigned MSIX'
run: |
$msix = dir "${env:PYMSBUILD_DIST_DIR}\*.msix" `
Expand Down
31 changes: 15 additions & 16 deletions src/_native/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,25 +233,24 @@ PyObject *broadcast_settings_change(PyObject *, PyObject *, PyObject *) {
return Py_GetConstant(Py_CONSTANT_NONE);
}

typedef enum {
CPU_X86 = 0,
CPU_X86_64 = 9,
CPU_ARM = 5,
CPU_ARM64 = 12,
CPU_UNKNOWN = 0xffff
} CpuArchitecture;
// We load IsWow64Process2 dynamically to avoid breaking on earlier OS than we
// officially support. If the API doesn't exist, then we assume -64.
typedef BOOL (*PIsWow64Process2)(HANDLE, USHORT*, USHORT*);

PyObject *get_processor_architecture(PyObject *, PyObject *, PyObject *) {
SYSTEM_INFO system_info;
GetNativeSystemInfo(&system_info);

switch (system_info.wProcessorArchitecture) {
case CPU_X86: return PyUnicode_FromString("-32");
case CPU_X86_64: return PyUnicode_FromString("-64");
case CPU_ARM: return PyUnicode_FromString("-arm");
case CPU_ARM64: return PyUnicode_FromString("-arm64");
default: return PyUnicode_FromString("-64"); // x86-64
USHORT dummy, machine = IMAGE_FILE_MACHINE_AMD64;
HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
if (kernel32) {
PIsWow64Process2 isWow64Process2 = (PIsWow64Process2)GetProcAddress(kernel32, "IsWow64Process2");
if (!isWow64Process2 || !isWow64Process2(0, &dummy, &machine)) {
machine = IMAGE_FILE_MACHINE_AMD64;
}
}
switch (machine) {
case IMAGE_FILE_MACHINE_I386: return PyUnicode_FromString("-32");
case IMAGE_FILE_MACHINE_ARM64: return PyUnicode_FromString("-arm64");
}
return PyUnicode_FromString("-64");
}

}