34
34
run : |
35
35
cd packages/${{ matrix.package }}
36
36
python -m pip install build wheel
37
- python -m build --sdist --wheel
37
+ python -m build
38
38
39
39
- uses : actions/upload-artifact@v4
40
40
with :
43
43
packages/${{ matrix.package }}/dist/*.whl
44
44
name : dist-${{ matrix.package }}
45
45
46
- build_basemap :
47
- name : Build basemap package (${{ matrix.os }})
48
- needs : [build_data]
49
- strategy :
50
- matrix :
51
- os : [ubuntu-22.04, windows-2019, macos-13, macos-14]
52
- runs-on : ${{ matrix.os }}
46
+ build_sdist :
47
+ name : Build basemap sdist
48
+ runs-on : ubuntu-22.04
53
49
steps :
54
50
- uses : actions/checkout@v4
55
51
@@ -59,13 +55,108 @@ jobs:
59
55
python-version : " 3.9"
60
56
61
57
- name : Build sdist
62
- if : matrix.os == 'ubuntu-22.04'
63
58
run : |
64
59
cd packages/basemap
65
60
python -m pip install build
66
61
python -m build --sdist
67
62
68
- - name : Build wheels
63
+ - uses : actions/upload-artifact@v4
64
+ with :
65
+ path : packages/basemap/dist/*.tar.gz
66
+ name : dist-basemap-sdist
67
+
68
+ build_wheels :
69
+ name : Build basemap wheels
70
+ needs : [build_data, build_sdist]
71
+ strategy :
72
+ matrix :
73
+ os : [ubuntu-22.04, windows-2019, macos-13, macos-14]
74
+ runs-on : ${{ matrix.os }}
75
+ steps :
76
+ - uses : actions/checkout@v4
77
+
78
+ - name : Set up Python
79
+ uses : actions/setup-python@v5
80
+ with :
81
+ python-version : " 3.9"
82
+
83
+ - name : Download data packages
84
+ uses : actions/download-artifact@v4
85
+ with :
86
+ pattern : dist-basemap_data*
87
+ path : ./data_packages/
88
+ merge-multiple : true
89
+
90
+ - name : Install data packages (Linux/macOS)
91
+ if : runner.os != 'Windows'
92
+ shell : bash
93
+ run : |
94
+ # Install the wheel data packages with wildcard
95
+ python -m pip install ./data_packages/*.whl
96
+
97
+ # Verify that the data packages can be imported
98
+ python -c "import mpl_toolkits.basemap_data; print('mpl_toolkits.basemap_data installed successfully')"
99
+
100
+ - name : Install data packages (Windows)
101
+ if : runner.os == 'Windows'
102
+ shell : pwsh
103
+ run : |
104
+ # Install the wheel data packages sequentially
105
+ $wheels = Get-ChildItem -Path "./data_packages" -Filter "*.whl" -Recurse
106
+ foreach ($wheel in $wheels) {
107
+ Write-Host "Installing $($wheel.FullName)"
108
+ python -m pip install $wheel.FullName
109
+ }
110
+
111
+ # Verify that the data packages can be imported
112
+ python -c "import mpl_toolkits.basemap_data; print('mpl_toolkits.basemap_data installed successfully')"
113
+
114
+ - name : Download basemap sdist
115
+ uses : actions/download-artifact@v4
116
+ with :
117
+ name : dist-basemap-sdist
118
+ path : ./sdist/
119
+
120
+ - name : Extract sdist (Linux/macOS)
121
+ if : runner.os != 'Windows'
122
+ shell : bash
123
+ run : |
124
+ # Create extraction directory in the workspace
125
+ mkdir -p ./sdist_extract
126
+
127
+ # Extract with tar using wildcard
128
+ tar -xvf ./sdist/*.tar.gz -C ./sdist_extract
129
+
130
+ # Get the extracted directory name
131
+ EXTRACTED_DIR="$(ls -d ./sdist_extract/*/ | head -1)"
132
+
133
+ # Verify contents
134
+ ls -la "${EXTRACTED_DIR}"
135
+
136
+ # Set the environment variable
137
+ echo "SDIST_DIR=$(pwd)/${EXTRACTED_DIR}" >> $GITHUB_ENV
138
+
139
+ - name : Extract sdist (Windows)
140
+ if : runner.os == 'Windows'
141
+ shell : pwsh
142
+ run : |
143
+ # Create extraction directory in the workspace
144
+ New-Item -ItemType Directory -Force -Path "sdist_extract"
145
+
146
+ # Extract with tar using the specific file path (no wildcard)
147
+ $tarball = Get-ChildItem -Path "sdist" -Filter "*.tar.gz" | Select-Object -First 1
148
+ tar -xvf $tarball.FullName -C "sdist_extract"
149
+
150
+ # Get the extracted directory name
151
+ $extractedDir = (Get-ChildItem -Path "sdist_extract" -Directory | Select-Object -First 1).FullName
152
+
153
+ # Verify contents
154
+ Get-ChildItem "$extractedDir"
155
+
156
+ # Set the environment variable
157
+ echo "SDIST_DIR=$extractedDir" | Out-File -FilePath $env:GITHUB_ENV -Append
158
+
159
+ - name : Build wheels from sdist
69
160
70
161
env :
71
162
CIBW_ARCHS : " native"
@@ -85,19 +176,22 @@ jobs:
85
176
# LD_LIBRARY_PATH in environment is needed by
86
177
# auditwheel (Linux) and delocate (MacOS).
87
178
with :
88
- package-dir : " packages/basemap"
89
- output-dir : " packages/basemap/dist"
179
+ package-dir : ${{ env.SDIST_DIR }}
180
+ output-dir : " dist"
181
+ # Set `package-dir` to a folder with the extracted sdist;
182
+ # otherwise, `cibuildwheel` uses `python -m pip wheel` or
183
+ # `python -m build --wheel` with the repository package
184
+ # folder and we cannot guarantee that wheels can be built
185
+ # from the sdist.
90
186
91
187
- uses : actions/upload-artifact@v4
92
188
with :
93
- path : |
94
- packages/basemap/dist/*.tar.gz
95
- packages/basemap/dist/*.whl
96
- name : dist-basemap-${{ matrix.os }}
189
+ path : dist/*.whl
190
+ name : dist-basemap-wheels-${{ matrix.os }}
97
191
98
192
check :
99
193
name : Check packages
100
- needs : [build_data, build_basemap ]
194
+ needs : [build_data, build_sdist, build_wheels ]
101
195
runs-on : ubuntu-22.04
102
196
steps :
103
197
- uses : actions/download-artifact@v4
@@ -117,9 +211,90 @@ jobs:
117
211
python -m twine check dist/*.tar.gz
118
212
python -m twine check dist/*.whl
119
213
214
+ docs :
215
+ name : Build documentation
216
+ needs : [build_wheels]
217
+ runs-on : ubuntu-22.04
218
+ steps :
219
+ - uses : actions/checkout@v4
220
+
221
+ - name : Set up Python
222
+ uses : actions/setup-python@v5
223
+ with :
224
+ python-version : " 3.9"
225
+
226
+ - name : Download data packages
227
+ uses : actions/download-artifact@v4
228
+ with :
229
+ path : ./data_packages/
230
+ pattern : " dist-basemap_data*"
231
+ merge-multiple : true
232
+
233
+ - name : Download basemap wheel for Linux
234
+ uses : actions/download-artifact@v4
235
+ with :
236
+ path : ./wheels/
237
+ pattern : " dist-basemap-wheels-ubuntu-*"
238
+ merge-multiple : true
239
+
240
+ - name : Install packages
241
+ run : |
242
+ # Get Python version.
243
+ IMPL=cp$(python -c "import sys; print('{0}{1}'.format(*sys.version_info[:2]))")
244
+
245
+ # Install basemap wheel matching current Python version.
246
+ WHEEL=$(find ./wheels -name "*-${IMPL}-${IMPL}*.whl" | head -1)
247
+ if [ -n "${WHEEL}" ]; then
248
+ python -m pip install "${WHEEL}"
249
+ else
250
+ echo "No matching wheel found for ${IMPL}-${IMPL}"
251
+ exit 1
252
+ fi
253
+
254
+ # Install basemap data packages.
255
+ python -m pip install ./data_packages/*.whl
256
+
257
+ - name : Install docs requirements
258
+ run : |
259
+ cd packages/basemap
260
+ python -m pip install -r requirements-doc.txt
261
+
262
+ - name : Run sphinx
263
+ run : |
264
+ cd packages/basemap
265
+ python -m sphinx doc/source public
266
+
267
+ - name : Upload docs artifacts
268
+ uses : actions/upload-artifact@v4
269
+ with :
270
+ name : docs
271
+ path : packages/basemap/public
272
+
273
+ - name : Upload github-pages artifact
274
+ uses : actions/upload-pages-artifact@v3
275
+ with :
276
+ name : github-pages
277
+ path : packages/basemap/public
278
+
279
+ pages :
280
+ name : Deploy documentation
281
+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
282
+ needs : [docs, check]
283
+ runs-on : ubuntu-22.04
284
+ environment :
285
+ name : github-pages
286
+ url : ${{ steps.deployment.outputs.page_url }}
287
+ permissions :
288
+ pages : write
289
+ id-token : write
290
+ steps :
291
+ - name : Deploy github-pages
292
+ uses : actions/deploy-pages@v3
293
+ id : deployment
294
+
120
295
upload :
121
296
name : Upload packages
122
- needs : [build_data, build_basemap , check]
297
+ needs : [build_data, build_sdist, build_wheels , check]
123
298
runs-on : ubuntu-22.04
124
299
environment : PyPI
125
300
if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
0 commit comments