4343 packages/${{ matrix.package }}/dist/*.whl
4444 name : dist-${{ matrix.package }}
4545
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
5349 steps :
5450 - uses : actions/checkout@v4
5551
@@ -59,13 +55,108 @@ jobs:
5955 python-version : " 3.9"
6056
6157 - name : Build sdist
62- if : matrix.os == 'ubuntu-22.04'
6358 run : |
6459 cd packages/basemap
6560 python -m pip install build
6661 python -m build --sdist
6762
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
69160 uses : pypa/cibuildwheel@v2.22.0
70161 env :
71162 CIBW_ARCHS : " native"
@@ -85,19 +176,22 @@ jobs:
85176 # LD_LIBRARY_PATH in environment is needed by
86177 # auditwheel (Linux) and delocate (MacOS).
87178 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.
90186
91187 - uses : actions/upload-artifact@v4
92188 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 }}
97191
98192 check :
99193 name : Check packages
100- needs : [build_data, build_basemap ]
194+ needs : [build_data, build_sdist, build_wheels ]
101195 runs-on : ubuntu-22.04
102196 steps :
103197 - uses : actions/download-artifact@v4
@@ -119,7 +213,7 @@ jobs:
119213
120214 upload :
121215 name : Upload packages
122- needs : [build_data, build_basemap , check]
216+ needs : [build_data, build_sdist, build_wheels , check]
123217 runs-on : ubuntu-22.04
124218 environment : PyPI
125219 if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
0 commit comments