forked from matplotlib/basemap
-
Notifications
You must be signed in to change notification settings - Fork 0
313 lines (267 loc) · 9.2 KB
/
build.yml
File metadata and controls
313 lines (267 loc) · 9.2 KB
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
name: Build
on:
push:
paths:
- ".github/workflows/**"
- "packages/basemap/**"
- "packages/basemap_data/**"
- "packages/basemap_data_hires/**"
pull_request:
paths:
- ".github/workflows/**"
- "packages/basemap/**"
- "packages/basemap_data/**"
- "packages/basemap_data_hires/**"
workflow_dispatch:
jobs:
build_data:
name: Build data packages
strategy:
matrix:
package: [basemap_data, basemap_data_hires]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Build sdist and wheels
run: |
cd packages/${{ matrix.package }}
python -m pip install build wheel
python -m build
- uses: actions/upload-artifact@v4
with:
path: |
packages/${{ matrix.package }}/dist/*.tar.gz
packages/${{ matrix.package }}/dist/*.whl
name: dist-${{ matrix.package }}
build_sdist:
name: Build basemap sdist
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Build sdist
run: |
cd packages/basemap
python -m pip install build
python -m build --sdist
- uses: actions/upload-artifact@v4
with:
path: packages/basemap/dist/*.tar.gz
name: dist-basemap-sdist
build_wheels:
name: Build basemap wheels
needs: [build_data, build_sdist]
strategy:
matrix:
os: [ubuntu-22.04, windows-2019, macos-13, macos-14]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Download data packages
uses: actions/download-artifact@v4
with:
pattern: dist-basemap_data*
path: ./data_packages/
merge-multiple: true
- name: Install data packages (Linux/macOS)
if: runner.os != 'Windows'
shell: bash
run: |
# Install the wheel data packages with wildcard
python -m pip install ./data_packages/*.whl
# Verify that the data packages can be imported
python -c "import mpl_toolkits.basemap_data; print('mpl_toolkits.basemap_data installed successfully')"
- name: Install data packages (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
# Install the wheel data packages sequentially
$wheels = Get-ChildItem -Path "./data_packages" -Filter "*.whl" -Recurse
foreach ($wheel in $wheels) {
Write-Host "Installing $($wheel.FullName)"
python -m pip install $wheel.FullName
}
# Verify that the data packages can be imported
python -c "import mpl_toolkits.basemap_data; print('mpl_toolkits.basemap_data installed successfully')"
- name: Download basemap sdist
uses: actions/download-artifact@v4
with:
name: dist-basemap-sdist
path: ./sdist/
- name: Extract sdist (Linux/macOS)
if: runner.os != 'Windows'
shell: bash
run: |
# Create extraction directory in the workspace
mkdir -p ./sdist_extract
# Extract with tar using wildcard
tar -xvf ./sdist/*.tar.gz -C ./sdist_extract
# Get the extracted directory name
EXTRACTED_DIR="$(ls -d ./sdist_extract/*/ | head -1)"
# Verify contents
ls -la "${EXTRACTED_DIR}"
# Set the environment variable
echo "SDIST_DIR=$(pwd)/${EXTRACTED_DIR}" >> $GITHUB_ENV
- name: Extract sdist (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
# Create extraction directory in the workspace
New-Item -ItemType Directory -Force -Path "sdist_extract"
# Extract with tar using the specific file path (no wildcard)
$tarball = Get-ChildItem -Path "sdist" -Filter "*.tar.gz" | Select-Object -First 1
tar -xvf $tarball.FullName -C "sdist_extract"
# Get the extracted directory name
$extractedDir = (Get-ChildItem -Path "sdist_extract" -Directory | Select-Object -First 1).FullName
# Verify contents
Get-ChildItem "$extractedDir"
# Set the environment variable
echo "SDIST_DIR=$extractedDir" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Build wheels from sdist
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_ARCHS: "native"
CIBW_BUILD: "cp39* cp310* cp311* cp312* cp313*"
CIBW_BUILD_VERBOSITY: 1
CIBW_SKIP: "*-musllinux_*"
CIBW_BEFORE_ALL: "python {project}/.github/workflows/run_before_all.py"
CIBW_TEST_EXTRAS: "test"
CIBW_TEST_COMMAND: "python -m pytest {project}/packages/basemap"
CIBW_ENVIRONMENT: >-
GEOS_VERSION="3.6.5"
GEOS_DIR="$(pwd)/extern"
GEOS_NJOBS=4
PIP_PREFER_BINARY=1
PYTHONUNBUFFERED=1
LD_LIBRARY_PATH="${GEOS_DIR}/lib"
# LD_LIBRARY_PATH in environment is needed by
# auditwheel (Linux) and delocate (MacOS).
with:
package-dir: ${{ env.SDIST_DIR }}
output-dir: "dist"
# Set `package-dir` to a folder with the extracted sdist;
# otherwise, `cibuildwheel` uses `python -m pip wheel` or
# `python -m build --wheel` with the repository package
# folder and we cannot guarantee that wheels can be built
# from the sdist.
- uses: actions/upload-artifact@v4
with:
path: dist/*.whl
name: dist-basemap-wheels-${{ matrix.os }}
check:
name: Check packages
needs: [build_data, build_sdist, build_wheels]
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v4
with:
path: dist
pattern: "dist-*"
merge-multiple: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Check packages with twine
run: |
python -m pip install twine
python -m twine check dist/*.tar.gz
python -m twine check dist/*.whl
docs:
name: Build documentation
needs: [build_wheels]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Download data packages
uses: actions/download-artifact@v4
with:
path: ./data_packages/
pattern: "dist-basemap_data*"
merge-multiple: true
- name: Download basemap wheel for Linux
uses: actions/download-artifact@v4
with:
path: ./wheels/
pattern: "dist-basemap-wheels-ubuntu-*"
merge-multiple: true
- name: Install packages
run: |
# Get Python version.
IMPL=cp$(python -c "import sys; print('{0}{1}'.format(*sys.version_info[:2]))")
# Install basemap wheel matching current Python version.
WHEEL=$(find ./wheels -name "*-${IMPL}-${IMPL}*.whl" | head -1)
if [ -n "${WHEEL}" ]; then
python -m pip install "${WHEEL}"
else
echo "No matching wheel found for ${IMPL}-${IMPL}"
exit 1
fi
# Install basemap data packages.
python -m pip install ./data_packages/*.whl
- name: Install docs requirements
run: |
cd packages/basemap
python -m pip install -r requirements-doc.txt
- name: Run sphinx
run: |
cd packages/basemap
python -m sphinx doc/source public
- name: Upload docs artifacts
uses: actions/upload-artifact@v4
with:
name: docs
path: packages/basemap/public
- name: Upload github-pages artifact
uses: actions/upload-pages-artifact@v3
with:
name: github-pages
path: packages/basemap/public
pages:
name: Deploy documentation
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [docs, check]
runs-on: ubuntu-22.04
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
steps:
- name: Deploy github-pages
uses: actions/deploy-pages@v3
id: deployment
upload:
name: Upload packages
needs: [build_data, build_sdist, build_wheels, check]
runs-on: ubuntu-22.04
environment: PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
path: dist
pattern: "dist-*"
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
repository-url: ${{ secrets.PYPI_REPOSITORY_URL }}
skip-existing: true