Skip to content

Add docs to workflow #175

Add docs to workflow

Add docs to workflow #175

Workflow file for this run

name: Build
on:
push:
paths:
- ".github/workflows/**"
- "packages/basemap/**"
- "packages/basemap_data/**"
- "packages/basemap_data_hires/**"
pull_request:
paths:
- ".github/workflows/**"
- "packages/basemap/**"
- "packages/basemap_data/**"
- "packages/basemap_data_hires/**"
workflow_dispatch:
jobs:
build_data:
name: Build data packages
strategy:
matrix:
package: [basemap_data, basemap_data_hires]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Build sdist and wheels
run: |
cd packages/${{ matrix.package }}
python -m pip install build wheel
python -m build --sdist --wheel
- uses: actions/upload-artifact@v4
with:
path: |
packages/${{ matrix.package }}/dist/*.tar.gz
packages/${{ matrix.package }}/dist/*.whl
name: dist-${{ matrix.package }}
build_sdist:
name: Build basemap sdist
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Build sdist
run: |
cd packages/basemap
python -m pip install build
python -m build --sdist
- 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"
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_TEST_EXTRAS: "test"
CIBW_TEST_COMMAND: "python -m pytest {project}/packages/basemap"
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 }} # Use extracted sdist
output-dir: "dist"
- 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:
- uses: actions/download-artifact@v4
with:
path: dist
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:
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
- 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
docs:
name: Build documentation
needs: [build_wheels]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Download basemap wheel for Linux
uses: actions/download-artifact@v4
with:
name: dist-basemap-wheels-ubuntu-22.04
path: ./wheels/
- name: Download data packages
uses: actions/download-artifact@v4
with:
pattern: dist-basemap_data*
path: ./data_packages/
merge-multiple: true
- name: Install packages
run: |
# Get Python version to find matching wheel
PYTHON_VERSION=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
echo "Using Python $PYTHON_VERSION"
# Install matching wheel for Linux
MATCHING_WHEEL=$(find ./wheels -name "basemap-*-cp3${PYTHON_VERSION/./}*.whl" | head -1)
if [ -n "$MATCHING_WHEEL" ]; then
echo "Installing wheel: $MATCHING_WHEEL"
python -m pip install "$MATCHING_WHEEL"
else
echo "No matching wheel found for Python $PYTHON_VERSION. Available wheels:"
ls -la ./wheels/
echo "Falling back to installing any available wheel..."
python -m pip install ./wheels/*.whl
fi
# Install data packages
echo "Installing data packages..."
python -m pip install ./data_packages/*.whl
- name: Install documentation requirements
run: |
cd packages/basemap
python -m pip install -r requirements-doc.txt
- name: Build documentation
run: |
cd packages/basemap
python -m sphinx doc/source public
- name: Upload docs artifacts
uses: actions/upload-artifact@v4
with:
name: docs-artifact
path: packages/basemap/public
- name: Upload github-pages artifact
uses: actions/upload-pages-artifact@v3
with:
name: github-pages
path: packages/basemap/public
pages:
name: Deploy documentation
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [docs, check]
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@v3
id: deployment
upload:
name: Upload packages
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')
steps:
- uses: actions/download-artifact@v4
with:
path: dist
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:
password: ${{ secrets.PYPI_TOKEN }}
repository-url: ${{ secrets.PYPI_REPOSITORY_URL }}
skip-existing: true