|
| 1 | +# Workflow to build wheels for upload to PyPI. |
| 2 | +# Inspired by numpy's cibuildwheel config https://github.com/numpy/numpy/blob/main/.github/workflows/wheels.yml |
| 3 | +# |
| 4 | +# In an attempt to save CI resources, wheel builds do |
| 5 | +# not run on each push but only weekly and for releases. |
| 6 | +# Wheel builds can be triggered from the Actions page |
| 7 | +# (if you have the perms) on a commit to master. |
| 8 | +# |
| 9 | +# Alternatively, you can add labels to the pull request in order to trigger wheel |
| 10 | +# builds. |
| 11 | +# The label(s) that trigger builds are: |
| 12 | +# - Build |
| 13 | +name: Wheel builder |
| 14 | + |
| 15 | +on: |
| 16 | + schedule: |
| 17 | + # ┌───────────── minute (0 - 59) |
| 18 | + # │ ┌───────────── hour (0 - 23) |
| 19 | + # │ │ ┌───────────── day of the month (1 - 31) |
| 20 | + # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) |
| 21 | + # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) |
| 22 | + # │ │ │ │ │ |
| 23 | + - cron: "27 3 */1 * *" |
| 24 | + push: |
| 25 | + pull_request: |
| 26 | + types: [labeled, opened, synchronize, reopened] |
| 27 | + workflow_dispatch: |
| 28 | + |
| 29 | +concurrency: |
| 30 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 31 | + cancel-in-progress: true |
| 32 | + |
| 33 | +jobs: |
| 34 | + build_wheels: |
| 35 | + name: Build wheel for ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} |
| 36 | + if: >- |
| 37 | + github.event_name == 'schedule' || |
| 38 | + github.event_name == 'workflow_dispatch' || |
| 39 | + (github.event_name == 'pull_request' && |
| 40 | + contains(github.event.pull_request.labels.*.name, 'Build')) || |
| 41 | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && ( ! endsWith(github.ref, 'dev0'))) |
| 42 | + runs-on: ${{ matrix.buildplat[0] }} |
| 43 | + strategy: |
| 44 | + # Ensure that a wheel builder finishes even if another fails |
| 45 | + fail-fast: false |
| 46 | + matrix: |
| 47 | + # Github Actions doesn't support pairing matrix values together, let's improvise |
| 48 | + # https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 |
| 49 | + buildplat: |
| 50 | + - [ubuntu-20.04, manylinux_x86_64] |
| 51 | + - [macos-11, macosx_*] |
| 52 | + - [windows-2019, win_amd64] |
| 53 | + - [windows-2019, win32] |
| 54 | + # TODO: support PyPy? |
| 55 | + python: [["cp38", "3.8"], ["cp39", "3.9"], ["cp310", "3.10"], ["cp311", "3.11-dev"]]# "pp38", "pp39"] |
| 56 | + env: |
| 57 | + IS_32_BIT: ${{ matrix.buildplat[1] == 'win32' }} |
| 58 | + IS_PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }} |
| 59 | + IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} |
| 60 | + steps: |
| 61 | + - name: Checkout pandas |
| 62 | + uses: actions/checkout@v3 |
| 63 | + with: |
| 64 | + submodules: true |
| 65 | + # versioneer.py requires the latest tag to be reachable. Here we |
| 66 | + # fetch the complete history to get access to the tags. |
| 67 | + # A shallow clone can work when the following issue is resolved: |
| 68 | + # https://github.com/actions/checkout/issues/338 |
| 69 | + fetch-depth: 0 |
| 70 | + |
| 71 | + - name: Build wheels |
| 72 | + |
| 73 | + env: |
| 74 | + CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} |
| 75 | + CIBW_ENVIRONMENT: IS_32_BIT='${{ env.IS_32_BIT }}' |
| 76 | + # We can't test directly with cibuildwheel, since we need to have to wheel location |
| 77 | + # to mount into the docker image |
| 78 | + CIBW_TEST_COMMAND_LINUX: "python {project}/ci/test_wheels.py" |
| 79 | + CIBW_TEST_COMMAND_MACOS: "python {project}/ci/test_wheels.py" |
| 80 | + CIBW_TEST_REQUIRES: hypothesis==6.52.1 pytest>=6.2.5 pytest-xdist pytest-asyncio>=0.17 |
| 81 | + CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "python ci/fix_wheels.py {wheel} {dest_dir}" |
| 82 | + CIBW_ARCHS_MACOS: x86_64 universal2 |
| 83 | + CIBW_BUILD_VERBOSITY: 3 |
| 84 | + |
| 85 | + # Used to push the built wheels |
| 86 | + - uses: actions/setup-python@v3 |
| 87 | + with: |
| 88 | + python-version: ${{ matrix.python[1] }} |
| 89 | + |
| 90 | + - name: Test wheels (Windows 64-bit only) |
| 91 | + if: ${{ matrix.buildplat[1] == 'win_amd64' }} |
| 92 | + shell: cmd |
| 93 | + run: | |
| 94 | + python ci/test_wheels.py wheelhouse |
| 95 | +
|
| 96 | + - uses: actions/upload-artifact@v3 |
| 97 | + with: |
| 98 | + name: ${{ matrix.python[0] }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }} |
| 99 | + path: ./wheelhouse/*.whl |
| 100 | + |
| 101 | + - name: Upload wheels |
| 102 | + if: success() |
| 103 | + shell: bash |
| 104 | + env: |
| 105 | + PANDAS_STAGING_UPLOAD_TOKEN: ${{ secrets.PANDAS_STAGING_UPLOAD_TOKEN }} |
| 106 | + PANDAS_NIGHTLY_UPLOAD_TOKEN: ${{ secrets.PANDAS_NIGHTLY_UPLOAD_TOKEN }} |
| 107 | + run: | |
| 108 | + source ci/upload_wheels.sh |
| 109 | + set_upload_vars |
| 110 | + # trigger an upload to |
| 111 | + # https://anaconda.org/scipy-wheels-nightly/pandas |
| 112 | + # for cron jobs or "Run workflow" (restricted to main branch). |
| 113 | + # Tags will upload to |
| 114 | + # https://anaconda.org/multibuild-wheels-staging/pandas |
| 115 | + # The tokens were originally generated at anaconda.org |
| 116 | + upload_wheels |
| 117 | + build_sdist: |
| 118 | + name: Build sdist |
| 119 | + if: >- |
| 120 | + github.event_name == 'schedule' || |
| 121 | + github.event_name == 'workflow_dispatch' || |
| 122 | + (github.event_name == 'pull_request' && |
| 123 | + contains(github.event.pull_request.labels.*.name, 'Build')) || |
| 124 | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && ( ! endsWith(github.ref, 'dev0'))) |
| 125 | + runs-on: ubuntu-latest |
| 126 | + env: |
| 127 | + IS_PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }} |
| 128 | + IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} |
| 129 | + steps: |
| 130 | + - name: Checkout pandas |
| 131 | + uses: actions/checkout@v3 |
| 132 | + with: |
| 133 | + submodules: true |
| 134 | + # versioneer.py requires the latest tag to be reachable. Here we |
| 135 | + # fetch the complete history to get access to the tags. |
| 136 | + # A shallow clone can work when the following issue is resolved: |
| 137 | + # https://github.com/actions/checkout/issues/338 |
| 138 | + fetch-depth: 0 |
| 139 | + # Used to push the built wheels |
| 140 | + - uses: actions/setup-python@v3 |
| 141 | + with: |
| 142 | + # Build sdist on lowest supported Python |
| 143 | + python-version: '3.8' |
| 144 | + - name: Build sdist |
| 145 | + run: | |
| 146 | + pip install build |
| 147 | + python -m build --sdist |
| 148 | + - name: Test the sdist |
| 149 | + run: | |
| 150 | + # TODO: Don't run test suite, and instead build wheels from sdist |
| 151 | + # by splitting the wheel builders into a two stage job |
| 152 | + # (1. Generate sdist 2. Build wheels from sdist) |
| 153 | + # This tests the sdists, and saves some build time |
| 154 | + python -m pip install dist/*.gz |
| 155 | + pip install hypothesis==6.52.1 pytest>=6.2.5 pytest-xdist pytest-asyncio>=0.17 |
| 156 | + cd .. # Not a good idea to test within the src tree |
| 157 | + python -c "import pandas; print(pandas.__version__); |
| 158 | + pandas.test(extra_args=['-m not clipboard and not single_cpu', '--skip-slow', '--skip-network', '--skip-db', '-n=2']); |
| 159 | + pandas.test(extra_args=['-m not clipboard and single_cpu', '--skip-slow', '--skip-network', '--skip-db'])" |
| 160 | + - uses: actions/upload-artifact@v3 |
| 161 | + with: |
| 162 | + name: sdist |
| 163 | + path: ./dist/* |
| 164 | + |
| 165 | + - name: Upload sdist |
| 166 | + if: success() |
| 167 | + shell: bash |
| 168 | + env: |
| 169 | + PANDAS_STAGING_UPLOAD_TOKEN: ${{ secrets.PANDAS_STAGING_UPLOAD_TOKEN }} |
| 170 | + PANDAS_NIGHTLY_UPLOAD_TOKEN: ${{ secrets.PANDAS_NIGHTLY_UPLOAD_TOKEN }} |
| 171 | + run: | |
| 172 | + source ci/upload_wheels.sh |
| 173 | + set_upload_vars |
| 174 | + # trigger an upload to |
| 175 | + # https://anaconda.org/scipy-wheels-nightly/pandas |
| 176 | + # for cron jobs or "Run workflow" (restricted to main branch). |
| 177 | + # Tags will upload to |
| 178 | + # https://anaconda.org/multibuild-wheels-staging/pandas |
| 179 | + # The tokens were originally generated at anaconda.org |
| 180 | + upload_wheels |
0 commit comments