Skip to content

Smooth stream track for streamspraydf models #1351

Smooth stream track for streamspraydf models

Smooth stream track for streamspraydf models #1351

Workflow file for this run

name: Wheel builder and uploader
# Update on every push and PR to main, and upon release creation
on:
push:
branches:
- main
paths:
- '**'
- '!*'
- '*.py'
- '!tests/**'
- '!doc/**'
- '!.github/**'
- '.github/workflows/wheels.yml'
pull_request:
branches:
- main
paths-ignore:
- 'doc/**'
release:
types: [created]
jobs:
build_wheels:
name: Build wheel for ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}
runs-on: ${{ matrix.buildplat[0] }}
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
# Following numpy's setup
buildplat:
- [ubuntu-24.04, manylinux, x86_64]
- [macos-15-intel, macosx, x86_64]
- [macos-15, macosx, arm64]
- [windows-2025, win, amd64]
python:
- ["cp310","3.10"]
- ["cp311","3.11"]
- ["cp312","3.12"]
- ["cp313","3.13"]
- ["cp314","3.14"]
steps:
- uses: actions/checkout@v6
- name: Install GSL (Windows / Mac OS x86_64)
uses: mamba-org/setup-micromamba@v3
if: matrix.buildplat[1] == 'win' || matrix.buildplat[1] == 'macosx'
with:
environment-name: gsl
condarc: |
channels:
- conda-forge
create-args: gsl
cache-environment: true
cache-environment-key: gsl-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}-${{ hashFiles('.github/workflows/wheels.yml') }}
- name: Set GSL environment variables (Windows)
if: matrix.buildplat[1] == 'win'
shell: bash -l {0}
run: |
echo "INCLUDE=$CONDA_PREFIX\\Library\\include" >> $GITHUB_ENV
echo "LIB=$CONDA_PREFIX\\Library\\lib" >> $GITHUB_ENV
echo "LIBPATH=$CONDA_PREFIX\\Library\\lib" >> $GITHUB_ENV
echo "$CONDA_PREFIX\\Library\\bin" >> $GITHUB_PATH # necessary when we don't activate the environment
- name: Set GSL environment variables (Mac OS)
if: matrix.buildplat[1] == 'macosx'
shell: bash -l {0}
run: |
echo "CFLAGS=-I$CONDA_PREFIX/include" >> $GITHUB_ENV
echo "LDFLAGS=-L$CONDA_PREFIX/lib -headerpad_max_install_names" >> $GITHUB_ENV
echo "REPAIR_LIBRARY_PATH=$CONDA_PREFIX/lib" >> $GITHUB_ENV # https://github.com/pypa/cibuildwheel/issues/816#issuecomment-916197079
echo "$CONDA_PREFIX/bin" >> $GITHUB_PATH # necessary when we don't activate the environment
- name: Inject git hash into version for dev wheels
if: github.event_name != 'release'
run: python tools/inject_git_hash.py
- name: Build wheels
uses: pypa/cibuildwheel@v3.4
env:
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}_${{ matrix.buildplat[2] }}
CIBW_BUILD_VERBOSITY: 1
CIBW_BEFORE_BUILD_LINUX: yum -y install gsl-devel
CIBW_ARCHS_MACOS: ${{ matrix.buildplat[2] }}
CIBW_ENVIRONMENT_MACOS: "MACOSX_DEPLOYMENT_TARGET=11.0"
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-listdeps {wheel} &&
DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-wheel -v --require-archs {delocate_archs} -w {dest_dir} {wheel}
- uses: actions/upload-artifact@v7
with:
name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}_${{ matrix.buildplat[2] }}
path: ./wheelhouse/*.whl
test_wheels:
name: Test Python ${{ matrix.python[1] }} wheels on ${{ matrix.buildplat[2] }} ${{ matrix.buildplat[0] }}
runs-on: ${{ matrix.buildplat[0] }}
needs: build_wheels
strategy:
# Ensure that tests finish even if another fails
fail-fast: false
matrix:
buildplat:
- [ubuntu-24.04, manylinux, x86_64]
- [macos-15-intel, macosx, x86_64]
- [macos-15, macosx, arm64]
- [windows-2025, win, amd64]
python:
- ["cp310","3.10"]
- ["cp311","3.11"]
- ["cp312","3.12"]
- ["cp313","3.13"]
- ["cp314","3.14"]
steps:
- uses: actions/checkout@v6
- run: mkdir wheelhouse
- uses: actions/download-artifact@v8
with:
name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}_${{ matrix.buildplat[2] }}
path: wheelhouse/
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python[1] }}
allow-prereleases: true
- name: Install GSL (Windows)
uses: mamba-org/setup-micromamba@v3
if: matrix.buildplat[1] == 'win'
with:
environment-name: gsl
condarc: |
channels:
- conda-forge
create-args: gsl
cache-environment: true
cache-environment-key: gsl-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}-${{ hashFiles('.github/workflows/wheels.yml') }}
- name: Set GSL environment variables (Windows)
if: matrix.buildplat[1] == 'win'
shell: bash -l {0}
run: |
micromamba activate gsl
echo "LIBPATH=$CONDA_PREFIX\\Library\\lib" >> $GITHUB_ENV
echo "$CONDA_PREFIX\\Library\\bin" >> $GITHUB_PATH # necessary when we don't activate the environment
- name: Install wheel
shell: bash
run: python -m pip install `ls -d "$(pwd)"/wheelhouse/*.whl`
- name: Print installed version
shell: bash
working-directory: ${{ runner.temp }}
run: python -c "import galpy; print('Installed galpy version:', galpy.__version__)"
- name: Test built wheel in non-conda environment
shell: bash
working-directory: ${{ runner.temp }}
run: |
pip install astropy pytest
pytest -v $GITHUB_WORKSPACE/tests/test_orbit.py -k "test_energy_jacobi_conservation and NFW"
# Test that built wheels also work in a conda environment, setup environment, install wheel, and run test
- name: Setup test conda environment (Linux / Mac OS)
if: matrix.buildplat[1] != 'win'
uses: mamba-org/setup-micromamba@v3
with:
environment-name: test-wheel-conda
condarc: |
channels:
- conda-forge
create-args: python=${{ matrix.python[1] }} numpy scipy matplotlib astropy pytest
cache-environment: true
cache-environment-key: test-wheel-conda-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}-${{ hashFiles('.github/workflows/wheels.yml') }}
- name: Setup test conda environment (Windows)
if: matrix.buildplat[1] == 'win'
shell: bash -l {0}
run: |
micromamba create -n test-wheel-conda -c conda-forge python=${{ matrix.python[1] }} numpy scipy matplotlib astropy pytest gsl
micromamba activate test-wheel-conda
echo "LIBPATH=$CONDA_PREFIX\\Library\\lib" >> $GITHUB_ENV
- name: Install built wheel in conda environment
shell: bash -l {0}
run: |
micromamba activate test-wheel-conda
python -m pip install `ls -d "$(pwd)"/wheelhouse/*.whl`
- name: Print installed version
shell: bash -l {0}
working-directory: ${{ runner.temp }}
run: python -c "import galpy; print('Installed galpy version:', galpy.__version__)"
- name: Test built wheel in conda environment
shell: bash -l {0}
working-directory: ${{ runner.temp }}
run: |
micromamba activate test-wheel-conda
pytest -v $GITHUB_WORKSPACE/tests/test_orbit.py -k "test_energy_jacobi_conservation and NFW"
build_sdist:
name: Build source directory for release
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
steps:
# check-out this repository
- uses: actions/checkout@v6
# Setup python
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.x
# Install the GSL (necessary to properly include the C files)
- name: Install GSL
run: sudo apt-get install -y libgsl0-dev
- name: Build sdist
run: |
pip install build
python -m build --sdist
- uses: actions/upload-artifact@v7
with:
name: sdist
path: ./dist/*.tar.gz
test_sdist:
name: Test that galpy can be built from the sdist
needs: build_sdist
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.x
- name: Install GSL
run: sudo apt-get install -y libgsl0-dev
- uses: actions/download-artifact@v8
with:
name: sdist
- name: Build from sdist
run: python -m pip install -v galpy*.tar.gz
- name: Run simple test
working-directory: ${{ runner.temp }}
run: |
python -c "
import numpy
from galpy.potential import MWPotential2014
from galpy.orbit import Orbit
o = Orbit()
ts = numpy.linspace(0., 100., 1001)
o.integrate(ts, MWPotential2014)
print('Orbit integration successful!')
print('Final position:', o.R(ts[-1]), o.z(ts[-1]))
"
# Deploy wheels and sdist to PyPI (upon release creation)
deploy_pypi:
name: Deploy to PyPI
needs: [build_wheels, test_wheels, test_sdist]
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
if: github.event_name == 'release' && github.event.action == 'created'
steps:
- uses: actions/checkout@v6
- run: |
mkdir tmp_wheelhouse
mkdir wheelhouse
- uses: actions/download-artifact@v8
with:
path: tmp_wheelhouse/
- run: find tmp_wheelhouse/ -mindepth 2 -type f -exec mv -i '{}' wheelhouse/ ';'
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages_dir: wheelhouse/
# Deploy wheels to AWS S3 (main)
deploy_s3:
name: Deploy to AWS S3
needs: [build_wheels, test_wheels]
runs-on: ubuntu-latest
if: github.event_name != 'release' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v6
- run: |
mkdir tmp_wheelhouse
mkdir wheelhouse
- uses: actions/download-artifact@v8
with:
path: tmp_wheelhouse/
- run: find tmp_wheelhouse/ -mindepth 2 -type f -exec mv -i '{}' wheelhouse/ ';'
- name: Create simple index
working-directory: wheelhouse
run: |
python <<EOF
import os
from pathlib import Path
import html
links = []
for file in sorted(Path(".").glob("*.whl")):
links.append(f'<a href="{html.escape(file.name)}">{html.escape(file.name)}</a><br>')
if not links:
raise RuntimeError("No wheel or files found in wheelhouse")
with open("index.html", "w") as f:
f.write("<html><body>\n" + "\n".join(links) + "\n</body></html>\n")
EOF
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v6
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Upload to AWS S3
run: |
aws s3 sync wheelhouse "s3://${AWS_S3_BUCKET}/wheelhouse/simple/galpy" \
--acl public-read --follow-symlinks --delete \
--exclude "*emscripten*" --exclude "*pyodide*"
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}