|
| 1 | +on: |
| 2 | + workflow_call: |
| 3 | + |
| 4 | +jobs: |
| 5 | + build_wheels: |
| 6 | + name: Build wheel for py${{ matrix.python-version }} ${{ matrix.os.platform_id }} ${{ matrix.os.macos_version }} |
| 7 | + runs-on: ${{ matrix.os.name }} |
| 8 | + |
| 9 | + strategy: |
| 10 | + # Ensure that a wheel builder finishes even if another fails |
| 11 | + # list of github vm: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + python-version: ["3.9", "3.10", "3.11", "3.12"] |
| 15 | + |
| 16 | + os: |
| 17 | + - name: "ubuntu-latest" |
| 18 | + platform: "linux" |
| 19 | + platform_id: "manylinux_x86_64" |
| 20 | + |
| 21 | + - name: "macos-13" |
| 22 | + platform: "macos" |
| 23 | + macos_version: "13" |
| 24 | + platform_id: "macosx_x86_64" |
| 25 | + |
| 26 | + - name: "macos-13" |
| 27 | + platform: "macos" |
| 28 | + macos_version: "13" |
| 29 | + platform_id: "macosx_arm64" |
| 30 | + |
| 31 | + - name: "macos-14" |
| 32 | + platform: "macos" |
| 33 | + macos_version: "14" |
| 34 | + platform_id: "macosx_x86_64" |
| 35 | + |
| 36 | + - name: "macos-14" |
| 37 | + platform: "macos" |
| 38 | + macos_version: "14" |
| 39 | + platform_id: "macosx_arm64" |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: Checkout |
| 43 | + uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Setup Python |
| 46 | + uses: actions/setup-python@v5 |
| 47 | + with: |
| 48 | + python-version: ${{ matrix.python-version }} |
| 49 | + |
| 50 | + # - name: Install dependencies [linux] |
| 51 | + # if: matrix.os.platform == 'linux' |
| 52 | + # run: sudo apt-get install -y libldap-common |
| 53 | + # shell: bash |
| 54 | + |
| 55 | + - name: Install poetry |
| 56 | + run: pipx install poetry==1.8.3 --python $(which python3) |
| 57 | + shell: bash |
| 58 | + |
| 59 | + - name: Test poetry |
| 60 | + run: | |
| 61 | + poetry run python --version |
| 62 | +
|
| 63 | + - name: Convert python version to cpXYZ |
| 64 | + run: | |
| 65 | + version=${{ matrix.python-version }} |
| 66 | + cp_version="cp${version//.}" |
| 67 | + echo "python_cp_version=$cp_version" >> $GITHUB_ENV |
| 68 | +
|
| 69 | + - name: Build wheels [macos-x86_64] |
| 70 | + if: ${{matrix.os.platform_id == 'macosx_x86_64'}} |
| 71 | + env: |
| 72 | + CIBW_BUILD: ${{ env.python_cp_version }}-${{ matrix.os.platform_id }} |
| 73 | + CIBW_ARCHS: x86_64 |
| 74 | + CIBW_ARCHS_MACOS: x86_64 |
| 75 | + CIBW_PLATFORM: macos |
| 76 | + CIBW_SKIP: "pp* *-musllinux_* *_i686* *_s390* *arm64*" |
| 77 | + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" |
| 78 | + CIBW_BUILD_VERBOSITY: 3 |
| 79 | + CMAKE_OSX_ARCHITECTURES: x86_64 |
| 80 | + CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # do not run delocate-wheel before the re-tag |
| 81 | + CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.macos_version }}.0" |
| 82 | + ARCHFLAGS: -arch x86_64 |
| 83 | + run: | |
| 84 | + echo "Building wheel ${CIBW_BUILD}" |
| 85 | + poetry run python --version |
| 86 | + poetry install |
| 87 | + cat ./pyproject.toml |
| 88 | + poetry run python -m cibuildwheel --output-dir wheelhouse |
| 89 | + echo "step 1" |
| 90 | + ls -l wheelhouse |
| 91 | + poetry run wheel tags --platform-tag macosx_${{ matrix.os.macos_version }}_0_x86_64 ./wheelhouse/*.whl |
| 92 | + rm -f ./wheelhouse/*arm64.whl |
| 93 | + echo "step 2" |
| 94 | + ls -l wheelhouse |
| 95 | + poetry run delocate-wheel --require-archs x86_64 -v ./wheelhouse/*.whl |
| 96 | + echo "step 3" |
| 97 | + ls -l wheelhouse |
| 98 | + poetry run python -m zipfile --list wheelhouse/*.whl |
| 99 | + mkdir ./dist |
| 100 | + cp wheelhouse/*.whl ./dist/ |
| 101 | +
|
| 102 | + # there is an error with the tagging of wheels for macosx-arm64 |
| 103 | + # see note: https://cibuildwheel.readthedocs.io/en/stable/faq/ |
| 104 | + # see here: https://gist.github.com/anderssonjohan/49f07e33fc5cb2420515a8ac76dc0c95#file-build-pendulum-wheels-yml-L39-L53 |
| 105 | + - name: Build wheels [macos-arm64] |
| 106 | + if: ${{matrix.os.platform_id == 'macosx_arm64'}} |
| 107 | + env: |
| 108 | + CIBW_BUILD: ${{ env.python_cp_version }}-${{ matrix.os.platform_id }} |
| 109 | + CIBW_ARCHS: arm64 |
| 110 | + CIBW_ARCHS_MACOS: arm64 |
| 111 | + CIBW_PLATFORM: macos |
| 112 | + CIBW_SKIP: "pp* *-musllinux_* *_i686* *x86_64* *_s390*" |
| 113 | + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" |
| 114 | + CIBW_BUILD_VERBOSITY: 3 |
| 115 | + CMAKE_OSX_ARCHITECTURES: arm64 |
| 116 | + CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # do not run delocate-wheel before the re-tag |
| 117 | + CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.macos_version }}.0" |
| 118 | + ARCHFLAGS: -arch arm64 |
| 119 | + run: | |
| 120 | + echo "Building wheel ${CIBW_BUILD}" |
| 121 | + poetry run python --version |
| 122 | + poetry install |
| 123 | + cat ./pyproject.toml |
| 124 | + poetry run python -m cibuildwheel --output-dir wheelhouse |
| 125 | + echo "step 1" |
| 126 | + ls -l wheelhouse |
| 127 | + poetry run wheel tags --platform-tag macosx_${{ matrix.os.macos_version }}_0_arm64 ./wheelhouse/*.whl |
| 128 | + rm -f ./wheelhouse/*x86_64.whl |
| 129 | + echo "step 2" |
| 130 | + ls -l wheelhouse |
| 131 | + poetry run delocate-wheel --require-archs arm64 -v ./wheelhouse/*.whl |
| 132 | + echo "step 3" |
| 133 | + ls -l wheelhouse |
| 134 | + poetry run python -m zipfile --list wheelhouse/*.whl |
| 135 | + mkdir ./dist |
| 136 | + cp wheelhouse/*.whl ./dist/ |
| 137 | +
|
| 138 | + - name: publish wheels (dry run) [macos] |
| 139 | + if: matrix.os.platform == 'macos' |
| 140 | + run: | |
| 141 | + ls -l ./ |
| 142 | + ls -l ./dist |
| 143 | + poetry publish --dry-run --no-interaction -vvv --username=__token__ --password=${{ secrets.PYPI_TOKEN }} |
| 144 | +
|
| 145 | + - name: publish wheels (on publishing) [macos] |
| 146 | + if: ${{ matrix.os.platform == 'macos' && startsWith(github.ref, 'refs/tags/') }} |
| 147 | + run: | |
| 148 | + ls -l ./ |
| 149 | + ls -l ./dist |
| 150 | + poetry publish --no-interaction -vvv --username=__token__ --password=${{ secrets.PYPI_TOKEN }} |
| 151 | +
|
| 152 | + - name: Build wheels [linux] |
| 153 | + if: matrix.os.name == 'ubuntu-latest' |
| 154 | + env: |
| 155 | + CIBW_BUILD: ${{ env.python_cp_version }}-${{ matrix.os.platform_id }} |
| 156 | + CIBW_ARCHS: x86_64 |
| 157 | + CIBW_PLATFORM: linux |
| 158 | + CIBW_SKIP: "pp* *musllinux_* *_i686* *_s390*" |
| 159 | + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" |
| 160 | + CIBW_BUILD_VERBOSITY: 3 |
| 161 | + run: | |
| 162 | + echo "Building wheel ${CIBW_BUILD}" |
| 163 | + poetry run python --version |
| 164 | + poetry add cibuildwheel |
| 165 | + # poetry install |
| 166 | + cat ./pyproject.toml |
| 167 | + poetry run python -m cibuildwheel --output-dir ./wheelhouse |
| 168 | + ls -l ./wheelhouse |
| 169 | + poetry run python -m zipfile --list ./wheelhouse/*.whl |
| 170 | + mkdir ./dist |
| 171 | + cp wheelhouse/*.whl ./dist/ |
| 172 | +
|
| 173 | + - name: publish wheels (dry run) [linux] |
| 174 | + if: matrix.os.platform == 'linux' |
| 175 | + run: | |
| 176 | + ls -l ./ |
| 177 | + ls -l ./dist |
| 178 | + poetry publish --dry-run --no-interaction -vvv --username=__token__ --password=${{ secrets.PYPI_TOKEN }} |
| 179 | +
|
| 180 | + - name: publish wheels (on publishing) [linux] |
| 181 | + if: ${{ matrix.os.platform == 'linux' && startsWith(github.ref, 'refs/tags/') }} |
| 182 | + run: | |
| 183 | + ls -l ./ |
| 184 | + ls -l ./dist |
| 185 | + poetry publish --no-interaction -vvv --username=__token__ --password=${{ secrets.PYPI_TOKEN }} |
| 186 | +
|
0 commit comments