Skip to content

Commit 1d489e5

Browse files
committed
flow sdist->wheel
1 parent 7913a36 commit 1d489e5

File tree

1 file changed

+102
-19
lines changed

1 file changed

+102
-19
lines changed

.github/workflows/build.yml

Lines changed: 102 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,9 @@ jobs:
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,83 @@ 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: basemap-sdist
67+
68+
build_wheels:
69+
name: Build wheels on ${{ matrix.os }}
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 basemap sdist
84+
uses: actions/download-artifact@v4
85+
with:
86+
name: basemap-sdist
87+
path: ./sdist/
88+
89+
- name: Extract sdist (Linux/macOS)
90+
if: runner.os != 'Windows'
91+
shell: bash
92+
run: |
93+
# Create extraction directory in the workspace
94+
mkdir -p ./sdist_extract
95+
96+
# Extract using tar (Unix-style)
97+
tar -xvf ./sdist/*.tar.gz -C ./sdist_extract
98+
99+
# Get the extracted directory name
100+
EXTRACTED_DIR=$(ls -d ./sdist_extract/*/ | head -1)
101+
echo "SDIST_DIR=$(pwd)/${EXTRACTED_DIR}" >> $GITHUB_ENV
102+
103+
# Verify contents
104+
ls -la ${EXTRACTED_DIR}
105+
106+
- name: Extract sdist (Windows)
107+
if: runner.os == 'Windows'
108+
shell: pwsh
109+
run: |
110+
# Create extraction directory
111+
New-Item -ItemType Directory -Force -Path "sdist_extract"
112+
113+
# Find the tarball file (without using wildcards)
114+
$tarball = Get-ChildItem -Path "sdist" -Filter "*.tar.gz" | Select-Object -First 1
115+
116+
# Debug - show what we found
117+
Write-Host "Found tarball: $($tarball.FullName)"
118+
119+
# Extract using the specific file path (not wildcard)
120+
tar -xvf $tarball.FullName -C "sdist_extract"
121+
122+
# Get the extracted directory name
123+
$extractedDir = (Get-ChildItem -Path "sdist_extract" -Directory | Select-Object -First 1).FullName
124+
125+
# Debug - show what we found
126+
Write-Host "Extracted directory: $extractedDir"
127+
128+
# Set the environment variable
129+
echo "SDIST_DIR=$extractedDir" | Out-File -FilePath $env:GITHUB_ENV -Append
130+
131+
# Verify contents
132+
Get-ChildItem $extractedDir
133+
134+
- name: Build wheels from sdist
69135
uses: pypa/cibuildwheel@v2.22.0
70136
env:
71137
CIBW_ARCHS: "native"
@@ -82,22 +148,18 @@ jobs:
82148
PIP_PREFER_BINARY=1
83149
PYTHONUNBUFFERED=1
84150
LD_LIBRARY_PATH="${GEOS_DIR}/lib"
85-
# LD_LIBRARY_PATH in environment is needed by
86-
# auditwheel (Linux) and delocate (MacOS).
87151
with:
88-
package-dir: "packages/basemap"
89-
output-dir: "packages/basemap/dist"
152+
package-dir: ${{ env.SDIST_DIR }} # Use extracted sdist
153+
output-dir: "dist"
90154

91155
- uses: actions/upload-artifact@v4
92156
with:
93-
path: |
94-
packages/basemap/dist/*.tar.gz
95-
packages/basemap/dist/*.whl
96-
name: dist-basemap-${{ matrix.os }}
157+
path: dist/*.whl
158+
name: dist-basemap-wheels-${{ matrix.os }}
97159

98160
check:
99161
name: Check packages
100-
needs: [build_data, build_basemap]
162+
needs: [build_data, build_sdist, build_wheels]
101163
runs-on: ubuntu-22.04
102164
steps:
103165
- uses: actions/download-artifact@v4
@@ -106,6 +168,11 @@ jobs:
106168
pattern: "dist-*"
107169
merge-multiple: true
108170

171+
- uses: actions/download-artifact@v4
172+
with:
173+
path: dist
174+
name: basemap-sdist
175+
109176
- name: Set up Python
110177
uses: actions/setup-python@v5
111178
with:
@@ -117,9 +184,20 @@ jobs:
117184
python -m twine check dist/*.tar.gz
118185
python -m twine check dist/*.whl
119186
187+
# Verification step to ensure sdist is complete
188+
- name: Verify sdist can build wheel
189+
run: |
190+
python -m pip install build setuptools wheel
191+
mkdir -p /tmp/sdist_test
192+
tar -xvf dist/*.tar.gz -C /tmp/sdist_test
193+
cd /tmp/sdist_test/*/
194+
python -m pip install -e .
195+
python -m build --wheel
196+
ls -la dist/*.whl
197+
120198
upload:
121199
name: Upload packages
122-
needs: [build_data, build_basemap, check]
200+
needs: [build_data, build_sdist, build_wheels, check]
123201
runs-on: ubuntu-22.04
124202
environment: PyPI
125203
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
@@ -130,6 +208,11 @@ jobs:
130208
pattern: "dist-*"
131209
merge-multiple: true
132210

211+
- uses: actions/download-artifact@v4
212+
with:
213+
path: dist
214+
name: basemap-sdist
215+
133216
- name: Publish to PyPI
134217
uses: pypa/gh-action-pypi-publish@release/v1
135218
with:

0 commit comments

Comments
 (0)