diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index ae8b145d..f78f2720 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -4,7 +4,7 @@ on: workflow_call: inputs: os_json: - description: 'JSON string of OS to build on' + description: 'JSON string of runner labels to build on (ubuntu-latest=x86_64, macos-latest=arm64, macos-15-intel=x86_64, windows-latest=x86_64)' required: false type: string default: '["ubuntu-latest", "macos-latest", "macos-15-intel", "windows-latest"]' @@ -36,7 +36,7 @@ on: type: boolean default: true os_json: - description: 'JSON string of OS to build on' + description: 'JSON string of runner labels to build on (ubuntu-latest=x86_64, macos-latest=arm64, macos-15-intel=x86_64, windows-latest=x86_64)' required: false default: '["ubuntu-latest", "macos-latest", "macos-15-intel", "windows-latest"]' python_json: @@ -46,7 +46,7 @@ on: jobs: build-sdist: - name: Build source distribution + name: Build source distribution py3.12 if: inputs.build_sdist runs-on: ubuntu-latest steps: @@ -277,7 +277,7 @@ jobs: echo "::notice::Build Wheel Version (Linux py${{ matrix.python-version }}): $VERSION" build-other: - name: Build distribution on ${{ matrix.os }} + name: Build distribution on ${{ matrix.os == 'macos-latest' && 'macOS arm64 (macos-latest)' || matrix.os == 'macos-15-intel' && 'macOS x86_64 (macos-15-intel)' || matrix.os == 'windows-latest' && 'Windows x86_64 (windows-latest)' || matrix.os }} py${{ matrix.python-version }} # Filter out ubuntu-latest from this job since it's handled by build-linux if: inputs.build_wheels runs-on: ${{ matrix.os || 'ubuntu-latest' }} @@ -304,6 +304,30 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Configure macOS wheel architecture tag + if: runner.os == 'macOS' + shell: bash + run: | + if [[ "${{ matrix.os }}" == "macos-15-intel" ]]; then + TARGET_ARCH="x86_64" + else + TARGET_ARCH="arm64" + fi + + MACOS_VERSION="$(python - <<'PY' + import platform + ver = platform.mac_ver()[0].split(".") + major = ver[0] if ver and ver[0] else "15" + minor = ver[1] if len(ver) > 1 else "0" + print(f"{major}.{minor}") + PY + )" + + echo "ARCHFLAGS=-arch ${TARGET_ARCH}" >> "$GITHUB_ENV" + echo "CMAKE_OSX_ARCHITECTURES=${TARGET_ARCH}" >> "$GITHUB_ENV" + echo "_PYTHON_HOST_PLATFORM=macosx-${MACOS_VERSION}-${TARGET_ARCH}" >> "$GITHUB_ENV" + echo "Configured macOS wheel platform: macosx-${MACOS_VERSION}-${TARGET_ARCH}" + - name: Set up Go uses: actions/setup-go@v6 with: @@ -380,7 +404,7 @@ jobs: - name: Store the distribution packages uses: actions/upload-artifact@v6 with: - name: python-package-distributions-${{ matrix.os }}-${{ matrix.python-version }} + name: python-package-distributions-${{ matrix.os == 'macos-latest' && 'macos-arm64' || matrix.os == 'macos-15-intel' && 'macos-x86_64' || matrix.os == 'windows-latest' && 'windows-x86_64' || matrix.os }}-${{ matrix.python-version }} path: dist/ - name: Display built wheel version @@ -389,4 +413,4 @@ jobs: run: | VERSION=$(ls dist/*.whl | head -n 1 | xargs basename | cut -d- -f2) echo "Build Version: $VERSION" - echo "::notice::Build Wheel Version (${{ matrix.os }} py${{ matrix.python-version }}): $VERSION" + echo "::notice::Build Wheel Version (${{ matrix.os == 'macos-latest' && 'macOS arm64 (macos-latest)' || matrix.os == 'macos-15-intel' && 'macOS x86_64 (macos-15-intel)' || matrix.os == 'windows-latest' && 'Windows x86_64 (windows-latest)' || matrix.os }} py${{ matrix.python-version }}): $VERSION" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2179c03..e3f6d354 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ on: type: boolean default: true os_json: - description: 'JSON string of OS to build on (Manual only)' + description: 'JSON string of runner labels to build on (Manual only; ubuntu-latest=x86_64, macos-latest=arm64, macos-15-intel=x86_64, windows-latest=x86_64)' required: false type: string default: '["ubuntu-latest", "macos-latest", "macos-15-intel", "windows-latest"]' diff --git a/setup.py b/setup.py index 0482e229..f36e526a 100644 --- a/setup.py +++ b/setup.py @@ -271,6 +271,9 @@ def build_extension(self, ext): if sys.platform == "darwin": cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15") + target_arch = os.environ.get("CMAKE_OSX_ARCHITECTURES") + if target_arch: + cmake_args.append(f"-DCMAKE_OSX_ARCHITECTURES={target_arch}") elif sys.platform == "win32": cmake_args.extend(["-G", "MinGW Makefiles"])