Skip to content

Build improvements

Build improvements #25

Workflow file for this run

name: CI
on:
workflow_dispatch:
workflow_call:
pull_request:
branches: [main]
jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Select manylinux Python tag
run: |
case "${{ matrix.python-version }}" in
"3.10") echo "MANYLINUX_PYTAG=cp310-cp310" >> "$GITHUB_ENV" ;;
"3.11") echo "MANYLINUX_PYTAG=cp311-cp311" >> "$GITHUB_ENV" ;;
"3.12") echo "MANYLINUX_PYTAG=cp312-cp312" >> "$GITHUB_ENV" ;;
"3.13") echo "MANYLINUX_PYTAG=cp313-cp313" >> "$GITHUB_ENV" ;;
"3.14") echo "MANYLINUX_PYTAG=cp314-cp314" >> "$GITHUB_ENV" ;;
*)
echo "Unsupported python-version: ${{ matrix.python-version }}"
exit 1
;;
esac
- name: Build and repair wheel in manylinux container
run: |
rm -rf dist wheelhouse
mkdir -p dist wheelhouse
docker run --rm \
-e PYTAG="${MANYLINUX_PYTAG}" \
-v "${{ github.workspace }}:/io" \
-w /io \
quay.io/pypa/manylinux_2_34:latest \
/bin/bash -lc '
set -euo pipefail
if ! command -v cmake >/dev/null 2>&1; then
dnf install -y cmake gcc gcc-c++ make ninja-build
fi
"/opt/python/${PYTAG}/bin/python" -m pip install --upgrade pip setuptools wheel build auditwheel
"/opt/python/${PYTAG}/bin/python" -m build --wheel -o dist
auditwheel repair dist/*.whl -w wheelhouse
'
- name: Install wheel
run: |
python3 -m venv env
source env/bin/activate
python -m pip install --upgrade wheelhouse/*.whl
- name: Smoke test import (non-3.14)
if: matrix.python-version != '3.14'
run: |
source env/bin/activate
python -c "import JupiterMag; print(JupiterMag.__version__)"
- name: Upload wheel artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-linux-py${{ matrix.python-version }}
path: wheelhouse/*.whl
- name: Build sdist (Linux 3.14)
if: matrix.python-version == '3.14'
run: |
docker run --rm \
-e PYTAG="${MANYLINUX_PYTAG}" \
-v "${{ github.workspace }}:/io" \
-w /io \
quay.io/pypa/manylinux_2_34:latest \
/bin/bash -lc '
set -euo pipefail
"/opt/python/${PYTAG}/bin/python" -m pip install --upgrade pip setuptools wheel build
"/opt/python/${PYTAG}/bin/python" -m build --sdist -o dist
'
- name: Upload sdist artifact (Linux 3.14)
if: matrix.python-version == '3.14'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sdist-linux-py${{ matrix.python-version }}
path: dist/*.tar.gz
- name: Run pytest from tests directory
if: matrix.python-version == '3.14'
run: |
source env/bin/activate
pip install pytest black flake8
cd tests
pytest -q
build-macos:
runs-on: ${{ matrix.macos-version }}
strategy:
fail-fast: false
matrix:
macos-version: ["macos-15", "macos-15-intel"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install build tools
run: |
brew update
brew install libtool
python3 -m venv env
source env/bin/activate
python -m pip install --upgrade pip setuptools wheel build
- name: Build wheel
run: |
source env/bin/activate
export CMAKE_OSX_ARCHITECTURES="$(uname -m)"
export CMAKE_OSX_DEPLOYMENT_TARGET="11.0"
export MACOSX_DEPLOYMENT_TARGET="11.0"
rm -rf dist
mkdir -p dist
python -m build --wheel -o dist
ls -1 dist
if ls dist/*universal2*.whl >/dev/null 2>&1; then
echo "Unexpected universal2 wheel produced"
exit 1
fi
- name: Install wheel
run: |
source env/bin/activate
python -m pip install --upgrade dist/*.whl
- name: Smoke test import (non-3.14)
if: matrix.python-version != '3.14'
run: |
source env/bin/activate
python -c "import JupiterMag; print(JupiterMag.__version__)"
- name: Upload wheel artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-${{ matrix.macos-version }}-py${{ matrix.python-version }}
path: dist/*.whl
- name: Run tests
if: matrix.python-version == '3.14'
run: |
source env/bin/activate
if [[ "$(uname -m)" == "x86_64" ]]; then
# DateTimeTools may resolve to an arm64 wheel on Intel runners.
# Rebuild from source to guarantee a native x86_64 libdatetime.dylib.
python -m pip install --force-reinstall --no-binary DateTimeTools DateTimeTools
fi
pip install pytest black flake8
cd tests
pytest -q
build-windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Set up MSYS2 toolchain
uses: msys2/setup-msys2@cafece8e6baf9247cf9b1bf95097b0b983cc558d # v2.31.0
with:
msystem: UCRT64
path-type: inherit
update: true
install: >-
mingw-w64-ucrt-x86_64-gcc
mingw-w64-ucrt-x86_64-cmake
mingw-w64-ucrt-x86_64-ninja
- name: Create venv
shell: pwsh
run: |
python -m venv env
- name: Build wheel
shell: pwsh
run: |
.\env\Scripts\Activate.ps1
pip install --upgrade build wheel
$gccCandidates = @(Get-Command gcc.exe -All -ErrorAction Stop | Select-Object -ExpandProperty Source)
$gxxCandidates = @(Get-Command g++.exe -All -ErrorAction Stop | Select-Object -ExpandProperty Source)
$ninjaCandidates = @(Get-Command ninja.exe -All -ErrorAction Stop | Select-Object -ExpandProperty Source)
$cmakeCandidates = @(Get-Command cmake.exe -All -ErrorAction Stop | Select-Object -ExpandProperty Source)
Write-Host "gcc candidates: $($gccCandidates -join '; ')"
Write-Host "g++ candidates: $($gxxCandidates -join '; ')"
Write-Host "ninja candidates: $($ninjaCandidates -join '; ')"
Write-Host "cmake candidates: $($cmakeCandidates -join '; ')"
$gcc = $gccCandidates | Where-Object { $_ -match '[\\/](ucrt64|mingw64)[\\/]bin[\\/]' } | Select-Object -First 1
if (-not $gcc) { $gcc = $gccCandidates | Where-Object { $_ -match '(msys|mingw|ucrt)' } | Select-Object -First 1 }
if (-not $gcc) { $gcc = $gccCandidates | Select-Object -First 1 }
$gxx = $gxxCandidates | Where-Object { $_ -match '[\\/](ucrt64|mingw64)[\\/]bin[\\/]' } | Select-Object -First 1
if (-not $gxx) { $gxx = $gxxCandidates | Where-Object { $_ -match '(msys|mingw|ucrt)' } | Select-Object -First 1 }
if (-not $gxx) { $gxx = $gxxCandidates | Select-Object -First 1 }
$ninja = $ninjaCandidates | Where-Object { $_ -match '[\\/](ucrt64|mingw64)[\\/]bin[\\/]' } | Select-Object -First 1
if (-not $ninja) { $ninja = $ninjaCandidates | Where-Object { $_ -match '(msys|mingw|ucrt)' } | Select-Object -First 1 }
if (-not $ninja) { $ninja = $ninjaCandidates | Select-Object -First 1 }
$cmake = $cmakeCandidates | Where-Object { $_ -match '[\\/](ucrt64|mingw64)[\\/]bin[\\/]' } | Select-Object -First 1
if (-not $cmake) { $cmake = $cmakeCandidates | Where-Object { $_ -match '(msys|mingw|ucrt)' } | Select-Object -First 1 }
if (-not $cmake) { $cmake = $cmakeCandidates | Select-Object -First 1 }
if (-not $gcc -or -not $gxx -or -not $ninja -or -not $cmake) {
throw "Could not locate gcc/g++/ninja/cmake in PATH"
}
$toolBin = Split-Path -Parent $gcc
$env:PATH = "$toolBin;$env:PATH"
$gccForCmake = $gcc -replace '\\', '/'
$gxxForCmake = $gxx -replace '\\', '/'
$env:CMAKE_GENERATOR = "Ninja"
$env:CC = $gcc
$env:CXX = $gxx
$env:CMAKE_ARGS = "-DCMAKE_C_COMPILER:FILEPATH=$gccForCmake -DCMAKE_CXX_COMPILER:FILEPATH=$gxxForCmake"
Write-Host "Using gcc: $gcc"
Write-Host "Using g++: $gxx"
Write-Host "Using ninja: $ninja"
Write-Host "Using cmake: $cmake"
& $gcc --version
& $gxx --version
& $cmake --version
& $ninja --version
python -m build --wheel -o dist
- name: Install wheel
shell: pwsh
run: |
.\env\Scripts\Activate.ps1
$wheel = Get-ChildItem -Path dist -Filter *.whl | Select-Object -First 1
if (-not $wheel) { throw "No wheel found in dist/" }
python -m pip install --upgrade $wheel.FullName
- name: Smoke test import (non-3.14)
if: matrix.python-version != '3.14'
shell: pwsh
run: |
.\env\Scripts\Activate.ps1
python -c "import JupiterMag; print(JupiterMag.__version__)"
- name: Upload wheel artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-windows-py${{ matrix.python-version }}
path: dist/*.whl
- name: Run tests
if: matrix.python-version == '3.14'
shell: pwsh
run: |
.\env\Scripts\Activate.ps1
Set-Location tests
pip install pytest black flake8
pytest -q