Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cibuild built from sdist -> wheel #622

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 155 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,9 @@ jobs:
packages/${{ matrix.package }}/dist/*.whl
name: dist-${{ matrix.package }}

build_basemap:
name: Build basemap package (${{ matrix.os }})
needs: [build_data]
strategy:
matrix:
os: [ubuntu-22.04, windows-2019, macos-13, macos-14]
runs-on: ${{ matrix.os }}
build_sdist:
name: Build basemap sdist
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand All @@ -59,13 +55,127 @@ jobs:
python-version: "3.9"

- name: Build sdist
if: matrix.os == 'ubuntu-22.04'
run: |
cd packages/basemap
python -m pip install build
python -m build --sdist

- name: Build wheels
- uses: actions/upload-artifact@v4
with:
path: packages/basemap/dist/*.tar.gz
name: basemap-sdist

build_wheels:
name: Build wheels on ${{ matrix.os }}
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 basemap sdist
uses: actions/download-artifact@v4
with:
name: basemap-sdist
path: ./sdist/

- 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: |
# Debug - show what we downloaded
ls -la ./data_packages/

# Install the data packages
python -m pip install ./data_packages/*.whl

# Verify they're installed
python -c "import mpl_toolkits.basemap_data; print('Data package installed')"

# Install the data packages (Windows)
- name: Install data packages (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
# Debug - show what we downloaded
Get-ChildItem -Path "./data_packages" -Recurse

# Find all wheel files
$wheels = Get-ChildItem -Path "./data_packages" -Filter "*.whl" -Recurse

# Install each wheel file
foreach ($wheel in $wheels) {
Write-Host "Installing $($wheel.FullName)"
python -m pip install $wheel.FullName
}

# Show installed packages
python -m pip list | Select-String "mpl_toolkits.basemap"

# Try different import paths
Write-Host "Trying to import basemap_data..."
python -c "import mpl_toolkits.basemap_data; print('mpl_toolkits.basemap_data imported successfully')"

- name: Extract sdist (Linux/macOS)
if: runner.os != 'Windows'
shell: bash
run: |
# Create extraction directory in the workspace
mkdir -p ./sdist_extract

# Extract using tar (Unix-style)
tar -xvf ./sdist/*.tar.gz -C ./sdist_extract

# Get the extracted directory name
EXTRACTED_DIR=$(ls -d ./sdist_extract/*/ | head -1)
echo "SDIST_DIR=$(pwd)/${EXTRACTED_DIR}" >> $GITHUB_ENV

# Verify contents
ls -la ${EXTRACTED_DIR}

- name: Extract sdist (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
# Create extraction directory
New-Item -ItemType Directory -Force -Path "sdist_extract"

# Find the tarball file (without using wildcards)
$tarball = Get-ChildItem -Path "sdist" -Filter "*.tar.gz" | Select-Object -First 1

# Debug - show what we found
Write-Host "Found tarball: $($tarball.FullName)"

# Extract using the specific file path (not wildcard)
tar -xvf $tarball.FullName -C "sdist_extract"

# Get the extracted directory name
$extractedDir = (Get-ChildItem -Path "sdist_extract" -Directory | Select-Object -First 1).FullName

# Debug - show what we found
Write-Host "Extracted directory: $extractedDir"

# Set the environment variable
echo "SDIST_DIR=$extractedDir" | Out-File -FilePath $env:GITHUB_ENV -Append

# Verify contents
Get-ChildItem $extractedDir

- name: Build wheels from sdist
uses: pypa/[email protected]
env:
CIBW_ARCHS: "native"
Expand All @@ -85,19 +195,17 @@ jobs:
# LD_LIBRARY_PATH in environment is needed by
# auditwheel (Linux) and delocate (MacOS).
with:
package-dir: "packages/basemap"
output-dir: "packages/basemap/dist"
package-dir: ${{ env.SDIST_DIR }} # Use extracted sdist
output-dir: "dist"

- uses: actions/upload-artifact@v4
with:
path: |
packages/basemap/dist/*.tar.gz
packages/basemap/dist/*.whl
name: dist-basemap-${{ matrix.os }}
path: dist/*.whl
name: dist-basemap-wheels-${{ matrix.os }}

check:
name: Check packages
needs: [build_data, build_basemap]
needs: [build_data, build_sdist, build_wheels]
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v4
Expand All @@ -106,6 +214,11 @@ jobs:
pattern: "dist-*"
merge-multiple: true

- uses: actions/download-artifact@v4
with:
path: dist
name: basemap-sdist

- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -117,9 +230,29 @@ jobs:
python -m twine check dist/*.tar.gz
python -m twine check dist/*.whl

- name: Verify sdist content
run: |
mkdir -p /tmp/sdist_test

# Find and extract basemap sdist
BASEMAP_SDIST=$(ls dist/basemap-*.tar.gz 2>/dev/null || ls dist/*basemap*.tar.gz 2>/dev/null | head -1)
tar -xvf "$BASEMAP_SDIST" -C /tmp/sdist_test

# Verify contents
echo "Files in extracted sdist:"
find /tmp/sdist_test -type f | grep -v "__pycache__" | sort

# Check for critical files
if [ -f "$(find /tmp/sdist_test -name "_geoslib.pyx")" ]; then
echo "✓ Source files verified in sdist"
else
echo "✗ Missing critical source files in sdist"
exit 1
fi

upload:
name: Upload packages
needs: [build_data, build_basemap, check]
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')
Expand All @@ -130,6 +263,11 @@ jobs:
pattern: "dist-*"
merge-multiple: true

- uses: actions/download-artifact@v4
with:
path: dist
name: basemap-sdist

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down