diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index 81056c44..f95192fe 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -104,6 +104,10 @@ jobs: arch: - 'x86' - 'x64' + - 'arm64' + exclude: + - py: '3.8' + arch: 'arm64' runs-on: 'windows-2022' env: ZSTD_WARNINGS_AS_ERRORS: '1' @@ -112,14 +116,25 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.py }} - architecture: ${{ matrix.arch }} + architecture: ${{ matrix.arch == 'arm64' && 'x64' || matrix.arch }} - uses: actions/checkout@v4 - name: Build Wheel + if: matrix.arch != 'arm64' run: | python -m pip wheel -w dist . + - name: Build Wheel + if: matrix.arch == 'arm64' + shell: bash + run: | + python -m pip install cibuildwheel + export CIBW_ARCHS=ARM64 + export CIBW_BUILD=cp$(echo ${{ matrix.py }} | tr -d .)-* + export CIBW_BUILD_VERBOSITY=1 + cibuildwheel --output-dir dist --arch ARM64 + - name: Upload Wheel uses: actions/upload-artifact@v4 with: diff --git a/setup.py b/setup.py index 921f3839..61156754 100755 --- a/setup.py +++ b/setup.py @@ -34,6 +34,27 @@ if sys.version_info[0:2] >= (3, 13): MINIMUM_CFFI_VERSION = "1.17" +ext_suffix = os.environ.get("SETUPTOOLS_EXT_SUFFIX") +if ext_suffix: + import sysconfig + # setuptools._distutils.command.build_ext doesn't use + # SETUPTOOLS_EXT_SUFFIX like setuptools.command.build_ext does. + # Work around the issue so that cross-compilation can work + # properly. + sysconfig.get_config_vars()["EXT_SUFFIX"] = ext_suffix + try: + # Older versions of python didn't have EXT_SUFFIX, and setuptools + # sets its own value, but since we've already set one, we don't + # want setuptools to overwrite it. + import setuptools._distutils.compat.py39 as py39compat + except ImportError: + try: + import setuptools._distutils.py39compat as py39compat + except ImportError: + pass + if py39compat: + py39compat.add_ext_suffix = lambda vars: None + try: import cffi