[WIP] Cython spiceypy prototype #463
This file contains hidden or 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.13 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- name: Display Python 🐍 | |
run: python -c "import sys; print(sys.version)" | |
- name: Update pip | |
run: | | |
python -m pip install --upgrade pip | |
- name: Install CI dependencies | |
run: | | |
python -m pip install -U -r ci-requirements.txt | |
- name: Build 🛠️ sdist source for 🌶️ 🥧 SpiceyPy | |
env: | |
CSPICE_NO_TEMP: "YES" | |
run: | | |
echo "Get CSPICE" | |
python get_spice.py | |
ls ./src/ | |
ls ./src/spiceypy/utils/ | |
echo "Building Cython Extension" | |
python setup.py build_ext -j 2 --inplace | |
ls ./src/spiceypy/cyice/ | |
echo "Running build for sdist" | |
python -m build --sdist | |
echo "contents of dist folder: " | |
ls dist/ | |
- name: Check dists | |
run: | | |
twine check dist/* | |
- uses: actions/upload-artifact@v4 | |
with: | |
path: dist/*.tar.gz | |
test_sdist: | |
name: Test SpiceyPy 🌶️ 🥧 Python 🐍 source distribution | |
needs: [build_sdist] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-14, windows-latest] | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout 🌶️ 🥧 | |
uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
path: dist | |
- name: Display structure of downloaded files | |
run: ls dist/ | |
- name: Setup windows msvc | |
if: ${{ matrix.os == 'windows-latest' }} | |
uses: ilammy/[email protected] | |
- name: Set up Python 🐍 3.13 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- name: Display Python 🐍 | |
run: python -c "import sys; print(sys.version)" | |
- name: Update pip | |
run: | | |
python -m pip install --upgrade pip | |
- name: Install CI dependencies | |
run: | | |
python -m pip install --user -r ci-requirements.txt | |
- name: Install SpiceyPy 🌶️ 🥧 from sdist on Mac/Linux | |
if: ${{ matrix.os != 'windows-latest' }} | |
shell: bash | |
run: | | |
echo "Running Pip install from sdist" | |
python -m pip install dist/*.tar.gz --user --no-build-isolation -vvvv | |
- name: Install SpiceyPy 🌶️ 🥧 from sdist on Windows | |
if: ${{ matrix.os == 'windows-latest' }} | |
shell: cmd | |
run: | | |
for /f %%f in ('dir /b dist\*.tar.gz') do ( | |
python -m pip install dist\%%f --user --no-build-isolation -vvvv | |
) | |
- name: Test 🧪 with coverage 📈 | |
run: | | |
python -m coverage run --source spiceypy -m pytest --pyargs spiceypy --benchmark-disable | |
- name: Upload 🆙 coverage 📈 report to codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: false | |
verbose: true | |
use_oidc: true | |
build_wheels: | |
strategy: | |
matrix: | |
include: | |
- config: {"name": "Linux", "os": "ubuntu-latest", "arch": "x86_64"} | |
- config: {"name": "Linux", "os": "ubuntu-22.04-arm", "arch": "aarch64"} | |
- config: {"name": "macOS", "os": "macos-13", "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: 2 | |
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 for macOS arm | |
if: runner.os == 'macOS' && matrix.config.arch == 'arm64' | |
run: | | |
echo "CIBW_ARCHS_MACOS=arm64" >> $GITHUB_ENV | |
echo "ARCHFLAGS=-arch arm64" >> $GITHUB_ENV | |
- name: set additional environment variables for macOS x86 | |
if: runner.os == 'macOS' && matrix.config.arch == 'x86_64' | |
run: | | |
echo "CIBW_ARCHS_MACOS=x86_64" >> $GITHUB_ENV | |
echo "ARCHFLAGS=-arch x86_64" >> $GITHUB_ENV | |
- name: set additional environment variables for linux aarch64 | |
if: runner.os == 'Linux' && matrix.config.arch == 'aarch64' | |
run: | | |
echo "CIBW_ARCHS_LINUX=aarch64" >> $GITHUB_ENV | |
echo "ARCHFLAGS=-arch aarch64" >> $GITHUB_ENV | |
- name: Print ARCHFLAGS | |
run: | | |
echo "ARCHFLAGS is: $ARCHFLAGS" | |
- name: Set up Python 🐍 3.13 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- 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.23.3 | |
- name: Build wheels for SpiceyPy 🌶️ 🥧 | |
timeout-minutes: 120 | |
run: | | |
env | grep CIBW | |
env | grep ARCH | |
python -m cibuildwheel --output-dir wheelhouse | |
- 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, test_sdist] | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: artifact-* | |
merge-multiple: true | |
path: dist | |
- name: Set up Python 🐍 3.13 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- 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 | |
if: startsWith(github.ref, 'refs/tags/v') | |
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/* |