-
Notifications
You must be signed in to change notification settings - Fork 398
287 lines (247 loc) · 8.2 KB
/
build.yml
File metadata and controls
287 lines (247 loc) · 8.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
permissions:
contents: read
on:
push:
paths:
- "**"
pull_request:
paths:
- "**"
workflow_dispatch:
jobs:
build_data:
name: Build data
strategy:
matrix:
package: [basemap_data, basemap_data_hires]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Build data sdist and wheel
run: |
cd data/${{ matrix.package }}
python -m pip install build wheel
python -m build
- name: Upload data sdist and wheel
uses: actions/upload-artifact@v4
with:
path: |
data/${{ matrix.package }}/dist/*.tar.gz
data/${{ matrix.package }}/dist/*.whl
name: dist-${{ matrix.package }}
build_sdist:
name: Build sdist
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Build basemap sdist
run: |
python -m pip install build
python -m build --sdist
- name: Upload basemap sdist
uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz
name: dist-basemap-sdist
build_wheels:
name: Build wheels
needs: [build_sdist]
strategy:
matrix:
os: [ubuntu-22.04, windows-2022, macos-13, macos-14]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Download basemap sdist
uses: actions/download-artifact@v4
with:
name: dist-basemap-sdist
path: ./sdist/
- name: Extract basemap 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 basemap 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 basemap wheels from sdist
uses: pypa/cibuildwheel@ee63bf16da6cddfb925f542f2c7b59ad50e93969 # 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_BEFORE_TEST: "python -m pip install {project}/data/basemap_data {project}/data/basemap_data_hires"
CIBW_TEST_EXTRAS: "test"
CIBW_TEST_COMMAND: "python -m pytest {project}/test"
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.
- name: Upload basemap wheels
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:
- name: Download basemap and data packages
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 docs
needs: [check]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- 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 wheels for Linux
uses: actions/download-artifact@v4
with:
path: ./wheels/
pattern: "dist-basemap-wheels-ubuntu-*"
merge-multiple: true
- name: Install basemap and data packages
run: |
# Get Python version.
IMPL=cp$(python -c "import sys; print('{0}{1}'.format(*sys.version_info[:2]))")
# Install data packages.
python -m pip install ./data_packages/*.whl
# 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
- name: Install docs requirements
run: |
python -m pip install -r dep/requirements-doc.txt
- name: Run sphinx
run: |
python -m sphinx -j auto doc/source public
- name: Upload docs artifacts
uses: actions/upload-artifact@v4
with:
name: docs
path: public
- name: Upload github-pages artifact
uses: actions/upload-pages-artifact@v3
with:
name: github-pages
path: public
pages:
name: Deploy docs
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [docs]
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@v4
id: deployment
upload:
name: Upload packages
needs: [check]
runs-on: ubuntu-22.04
environment: PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download basemap and data packages
uses: actions/download-artifact@v4
with:
path: dist
pattern: "dist-*"
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
with:
password: ${{ secrets.PYPI_TOKEN }}
repository-url: ${{ secrets.PYPI_REPOSITORY_URL }}
skip-existing: true