looks like github is now rolling out arm64 macos workers so cached ve… #337
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI | |
on: | |
pull_request: | |
push: | |
branches: [ main ] | |
tags: [ 'v*' ] | |
release: | |
types: [ published ] | |
jobs: | |
build_sdist: | |
name: Make SpiceyPy 🌶️ 🥧 Python 🐍 source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout 🌶️ 🥧 | |
uses: actions/checkout@v4 | |
- name: Set up Python 🐍 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Display Python 🐍 | |
run: python -c "import sys; print(sys.version)" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install -r ci-requirements.txt | |
- name: Build 🛠️ sdist source and Install SpiceyPy 🌶️ 🥧 | |
run: | | |
python -m build --sdist | |
pip install dist/*.tar.gz --user | |
- name: Test 🧪 with coverage 📈 | |
run: | | |
coverage run --source spiceypy -m pytest --pyargs spiceypy | |
- name: Upload 🆙 coverage 📈 report to codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
verbose: true | |
- name: Check dists | |
run: | | |
twine check dist/* | |
- uses: actions/upload-artifact@v4 | |
with: | |
path: dist/*.tar.gz | |
build_wheels: | |
strategy: | |
matrix: | |
include: | |
- config: {"name": "Linux", "os": "ubuntu-latest", "arch": "x86_64"} | |
- config: {"name": "Linux", "os": "ubuntu-latest", "arch": "aarch64"} | |
- config: {"name": "macOS", "os": "macos-14", "arch": "x86_64"} | |
- config: {"name": "macOS", "os": "macos-14", "arch": "arm64"} | |
- config: {"name": "Windows", "os": "windows-latest", "arch": "AMD64"} | |
name: Build SpiceyPy 🌶️ 🥧 Python 🐍 wheels for ${{ matrix.config.os }} ${{ matrix.config.arch }} | |
env: | |
CSPICE_CACHE: 1 | |
CIBW_ARCHS: ${{ matrix.config.arch }} | |
runs-on: ${{ matrix.config.os }} | |
steps: | |
- name: Checkout 🌶️ 🥧 | |
uses: actions/checkout@v4 | |
- name: Setup 🔬🍦🏗️ | |
if: runner.os == 'Windows' | |
uses: ilammy/[email protected] | |
- name: set additional environment variables | |
if: runner.name == 'macOS' && runner.arch == 'arm64' | |
run: | | |
echo "CIBW_ARCHS_MACOS=arm64" >> $GITHUB_ENV | |
echo "ARCHFLAGS='-arch arm64'" >> $GITHUB_ENV | |
- name: Set up QEMU for arm64 builds | |
if: matrix.config.arch == 'aarch64' | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- name: Cache libcspice.so for aarch64 builds because they take an hour to build with qemu | |
if: matrix.config.arch == 'aarch64' | |
uses: actions/cache@v4 | |
with: | |
path: ./src/spiceypy/utils/libcspice.so | |
key: ${{ env.CSPICE_CACHE }}-${{ matrix.config.os }}-${{ matrix.config.arch }}-${{ hashFiles('get_spice.py') }}-${{ hashFiles('setup.cfg') }} | |
- name: Set up Python 🐍 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Display Python 🐍 Version | |
run: python -c "import sys; print(sys.version)" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install -r ci-requirements.txt | |
python -m pip install cibuildwheel==2.16.4 | |
- name: See if libcspice.so is available from cache | |
if: matrix.config.arch == 'aarch64' | |
run: | | |
pwd | |
ls src/spiceypy/utils -lahtr | |
- name: Build wheels for SpiceyPy 🌶️ 🥧 | |
timeout-minutes: 120 | |
run: | | |
env | grep CIBW | |
env | grep ARCH | |
python -m cibuildwheel --output-dir wheelhouse | |
- name: Extract libcspice.so for aarch64 builds | |
if: matrix.config.arch == 'aarch64' | |
run: | | |
pwd | |
ls -lahtr | |
ls src/ -lahtr | |
ls src/spiceypy/ -lahtr | |
ls src/spiceypy/utils -lahtr | |
ls wheelhouse/* | |
unzip -o wheelhouse/spiceypy-\*.whl 'spiceypy/utils/libcspice.so' -d src/ | |
- name: Check dists | |
run: | | |
twine check wheelhouse/* | |
- name: Upload wheels for SpiceyPy 🌶️ 🥧 | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifact-${{ env.CSPICE_CACHE }}-${{ matrix.config.os }}-${{ matrix.config.arch }}-${{ hashFiles('get_spice.py') }}-${{ hashFiles('setup.cfg') }} | |
path: ./wheelhouse/*.whl | |
publish_to_pypi: | |
name: Publish SpiceyPy 🌶️ 🥧 Python 🐍 distributions 📦 to PyPI and TestPyPI | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: artifact-* | |
merge-multiple: true | |
path: dist | |
- name: Set up Python 🐍 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Display Python 🐍 | |
run: python -c "import sys; print(sys.version)" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install twine | |
- name: Check dists | |
run: | | |
twine check dist/* | |
- name: Publish distribution 📦 to Test PyPI | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} | |
run: | | |
twine upload --non-interactive --skip-existing --repository testpypi dist/* | |
- name: Publish distribution 📦 to PyPI | |
if: startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push' | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
twine upload --non-interactive --skip-existing dist/* |