-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
225 lines (203 loc) · 9.18 KB
/
wheels.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# Workflow to build wheels for upload to PyPI.
# Inspired by numpy's cibuildwheel config https://github.com/numpy/numpy/blob/main/.github/workflows/wheels.yml
#
# In an attempt to save CI resources, wheel builds do
# not run on each push but only weekly and for releases.
# Wheel builds can be triggered from the Actions page
# (if you have the permissions) on a commit to main.
#
# Alternatively, you can add labels to the pull request in order to trigger wheel
# builds.
# The label(s) that trigger builds are:
# - Build
name: Wheel builder
on:
schedule:
# 3:27 UTC every day
- cron: "27 3 * * *"
push:
pull_request:
types: [labeled, opened, synchronize, reopened]
paths-ignore:
- "doc/**"
- "web/**"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build_sdist:
name: Build sdist
if: >-
(github.event_name == 'schedule') ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'Build')) ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && ( ! endsWith(github.ref, 'dev0')))
runs-on: ubuntu-22.04
env:
IS_PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
outputs:
sdist_file: ${{ steps.save-path.outputs.sdist_name }}
pandas_tests_loc: ${{ steps.save-tests-path.outputs.pandas_tests_loc }}
steps:
- name: Checkout pandas
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build sdist
run: |
python -m pip install build wheel setuptools-scm
python -m build --sdist
- name: Build pandas_tests
run: |
cd pandas
# we want to place the pandas_tests wheel in the same
# dist directory as the sdist
python -m build --wheel --outdir ../dist --no-isolation
- uses: actions/upload-artifact@v4
with:
name: sdist-and-tests
path: ./dist/*
- name: Sanity check built files
run: |
ls ./dist
- name: Output sdist name
id: save-path
shell: bash -el {0}
run: echo "sdist_name=$(ls ./dist/*.tar.gz)" >> "$GITHUB_OUTPUT"
- name: Output pandas_tests location
id: save-tests-path
shell: bash -el {0}
run: echo "pandas_tests_loc=$(ls ./dist/*.whl)" >> "$GITHUB_OUTPUT"
build_wheels:
needs: build_sdist
name: Build wheel for ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
if: >-
(github.event_name == 'schedule') ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'Build')) ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && ( ! endsWith(github.ref, 'dev0')))
runs-on: ${{ matrix.buildplat[0] }}
strategy:
fail-fast: false
matrix:
# GitHub Actions doesn't support pairing matrix values together, let's improvise
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
buildplat:
- [ubuntu-22.04, manylinux_x86_64]
- [ubuntu-22.04, musllinux_x86_64]
- [macos-12, macosx_x86_64]
# Note: M1 images on Github Actions start from macOS 14
- [macos-14, macosx_arm64]
- [windows-2022, win_amd64]
# TODO: support PyPy?
python: [["cp39", "3.9"], ["cp310", "3.10"], ["cp311", "3.11"], ["cp312", "3.12"]]
env:
IS_PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
steps:
- name: Checkout pandas
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download sdist and pandas_tests
uses: actions/download-artifact@v4
with:
name: sdist-and-tests
path: ./dist
# The sdist will be corrupted by cibuildwheel/macOS sometimes somehow
# (I think this is a Github Actions bug)
- name: Unzip sdist (macOS)
if: ${{ startsWith(matrix.buildplat[1], 'macosx') }}
run: |
tar -xzf ${{ needs.build_sdist.outputs.sdist_file }} -C ./dist
- name: Output new sdist name (macOS)
id: save-path2
if: ${{ matrix.buildplat[1] == 'macosx_*' }}
shell: bash -el {0}
run: echo "sdist_name=./dist/$(cd ./dist && ls -d */)" >> "$GITHUB_ENV"
- name: Build normal wheels
if: ${{ (env.IS_SCHEDULE_DISPATCH != 'true' || env.IS_PUSH == 'true') }}
uses: pypa/[email protected]
with:
package-dir: ${{ startsWith(matrix.buildplat[1], 'macosx') && env.sdist_name || needs.build_sdist.outputs.sdist_file }}
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
# Note: Since the sdist is the project directory, it does not contain the tests
# We need to manually install tests from the host. This isn't ideal since it breaks
# isolation but should be no big deal
# (On Linux, need to prefix with /host, since we run builds in a container and the root directory is
# mounted to host)
CIBW_BEFORE_TEST: >
pip install ${{ startsWith(matrix.buildplat[0], 'ubuntu') && '/host'|| '' }}${{ github.workspace }}/${{ needs.build_sdist.outputs.pandas_tests_loc }}
- name: Build nightly wheels (with NumPy pre-release)
if: ${{ (env.IS_SCHEDULE_DISPATCH == 'true' && env.IS_PUSH != 'true') }}
uses: pypa/[email protected]
with:
package-dir: ./dist/${{ startsWith(matrix.buildplat[1], 'macosx') && env.sdist_name || needs.build_sdist.outputs.sdist_file }}
env:
# The nightly wheels should be build with the NumPy 2.0 pre-releases
# which requires the additional URL.
CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
CIBW_PRERELEASE_PYTHONS: True
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
- name: Set up Python
uses: mamba-org/setup-micromamba@v1
with:
environment-name: wheel-env
# Use a fixed Python, since we might have an unreleased Python not
# yet present on conda-forge
create-args: >-
python=3.11
anaconda-client
wheel
cache-downloads: true
cache-environment: true
- name: Validate wheel RECORD
shell: bash -el {0}
run: for whl in $(ls wheelhouse); do wheel unpack wheelhouse/$whl -d /tmp; done
# Testing on windowsservercore instead of GHA runner to fail on missing DLLs
- name: Test Windows Wheels
if: ${{ matrix.buildplat[1] == 'win_amd64' }}
shell: pwsh
run: |
$TST_CMD = @"
python -m pip install hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0;
python -m pip install `$(Get-Item pandas\wheelhouse\*.whl);
python -m pip install `$(Get-Item pandas\dist\pandas_tests*.whl);
python -c `'import pandas as pd; pd.test(extra_args=[`\"--no-strict-data-files`\", `\"-m not clipboard and not single_cpu and not slow and not network and not db`\"])`';
"@
# add rc to the end of the image name if the Python version is unreleased
docker pull python:${{ matrix.python[1] == '3.12' && '3.12-rc' || format('{0}-windowsservercore', matrix.python[1]) }}
docker run --env PANDAS_CI='1' -v ${PWD}:C:\pandas python:${{ matrix.python[1] == '3.12' && '3.12-rc' || format('{0}-windowsservercore', matrix.python[1]) }} powershell -Command $TST_CMD
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
path: ./wheelhouse/*.whl
- name: Upload wheels & sdist
if: ${{ success() && (env.IS_SCHEDULE_DISPATCH == 'true' || env.IS_PUSH == 'true') }}
shell: bash -el {0}
env:
PANDAS_STAGING_UPLOAD_TOKEN: ${{ secrets.PANDAS_STAGING_UPLOAD_TOKEN }}
PANDAS_NIGHTLY_UPLOAD_TOKEN: ${{ secrets.PANDAS_NIGHTLY_UPLOAD_TOKEN }}
# trigger an upload to
# https://anaconda.org/scientific-python-nightly-wheels/pandas
# for cron jobs or "Run workflow" (restricted to main branch).
# Tags will upload to
# https://anaconda.org/multibuild-wheels-staging/pandas
# The tokens were originally generated at anaconda.org
run: |
source ci/upload_wheels.sh
set_upload_vars
upload_wheels