下面是重现该问题的演示文件。我预计
CMAKE_SYSTEM_PROCESSOR
的值应该是 arm64
。然而,它是x86_64
。请参阅 Buildwheels 部分中的第 1233 行,该行对应于 message("CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
文件中的命令 CMakeLists.txt
main.cpp
#include <iostream>
int main() {
std::cout << "hello\n";
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.25)
project(hello)
set(CMAKE_CXX_STANDARD 17)
message("CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
add_executable(hello main.cpp)
build-wheel.yml
name: build-wheels
on:
push:
jobs:
build_wheels:
name: Build wheel
runs-on: macos-14
steps:
- uses: actions/checkout@v3
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_15.4.app
- name: Install Homebrew and packages
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew update
brew install ninja
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: cp38-macosx_arm64
CIBW_BUILD_VERBOSITY: 2
CIBW_ENVIRONMENT_MACOS: >
CC=gcc-14
CXX=g++-14
MACOSX_DEPLOYMENT_TARGET=13.0
pyproject.toml
[build-system]
requires = ["scikit-build-core>=0.9.0"]
build-backend = "scikit_build_core.build"
[project]
name = "hello"
version = "0.0.1dev0"
requires-python = ">=3.8"
dependencies = []
classifiers = [
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
[tool.scikit-build]
wheel.expand-macos-universal-tags = true
cmake.version = ">=3.25"
cmake.build-type = "Release"
cmake.verbose = true
logging.level = "INFO"
[tool.cibuildwheel]
build = "*"
skip = "cp3{6,7}-*"
如果我直接使用下面的工作流程文件构建程序。我得到了
CMAKE_SYSTEM_PROCESSOR
的正确值,即arm64
。请参阅Build部分中的第29行。
build.yml
name: build
on:
push:
jobs:
build:
name: Build
runs-on: macos-14
steps:
- uses: actions/checkout@v3
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_15.4.app
- name: Install Homebrew and packages
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew update
brew install ninja
- name: "Build"
run: |
rm -rf build && mkdir build && cd build
cmake -DCMAKE_C_COMPILER=gcc-14 \
-DCMAKE_CXX_COMPILER=g++-14 \
-DCMAKE_BUILD_TYPE=Release \
-GNinja ..
ninja
找到解决方案。这是由于 python 3.8 https://cibuildwheel.pypa.io/en/stable/faq/#macos-building-cpython-38-wheels-on-arm64