actionAngleStaeckel C: frequencies and angles near turning points #1968
Workflow file for this run
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: 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@v7 | |
| # Install GSL via conda. The composite action handles all platforms. | |
| - if: matrix.buildplat[1] != 'manylinux' | |
| uses: ./.github/actions/setup-conda | |
| 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 | |
| run: | | |
| ENV_WIN="$(cygpath -w "$CONDA_PREFIX")" | |
| echo "INCLUDE=${ENV_WIN}\\Library\\include" >> $GITHUB_ENV | |
| echo "LIB=${ENV_WIN}\\Library\\lib" >> $GITHUB_ENV | |
| echo "LIBPATH=${ENV_WIN}\\Library\\lib" >> $GITHUB_ENV | |
| - 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 | |
| - 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@v4.2 | |
| 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@v7 | |
| - 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@v7 | |
| with: | |
| python-version: ${{ matrix.python[1] }} | |
| allow-prereleases: true | |
| # Install GSL via conda (Windows only — Linux/macOS wheels bundle GSL). | |
| - if: matrix.buildplat[1] == 'win' | |
| uses: ./.github/actions/setup-conda | |
| 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 LIBPATH (Windows) | |
| if: matrix.buildplat[1] == 'win' | |
| shell: bash | |
| run: | | |
| ENV_WIN="$(cygpath -w "$CONDA_PREFIX")" | |
| echo "LIBPATH=${ENV_WIN}\\Library\\lib" >> $GITHUB_ENV | |
| - name: Install wheel | |
| shell: bash | |
| run: python -m pip install "$(ls wheelhouse/*.whl)[test]" | |
| - 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 -v $GITHUB_WORKSPACE/tests/test_orbit.py -k "test_energy_jacobi_conservation and NFW" | |
| # Test that built wheels also work in a conda environment: set up env, | |
| # install wheel, and run a single test from inside the env. | |
| - name: Set up test conda environment | |
| uses: ./.github/actions/setup-conda | |
| with: | |
| environment-name: test-wheel-conda | |
| condarc: | | |
| channels: | |
| - conda-forge | |
| # gsl is included on Windows so the wheel can find gsl.dll via the | |
| # env's Library\bin when conda-forge Python activates it via the | |
| # CONDA_PREFIX startup hook. | |
| create-args: python=${{ matrix.python[1] }} numpy scipy matplotlib astropy pytest pip${{ matrix.buildplat[1] == 'win' && ' gsl' || '' }} | |
| cache-environment: true | |
| cache-environment-key: test-wheel-conda-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}-${{ matrix.python[1] }}-${{ hashFiles('.github/workflows/wheels.yml') }} | |
| - name: Install built wheel in conda environment | |
| shell: bash -l {0} | |
| run: python -m pip install "$(ls wheelhouse/*.whl)[test]" | |
| - name: Print installed version in conda environment | |
| 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: pytest -v "$GITHUB_WORKSPACE"/tests/test_orbit.py -k "test_energy_jacobi_conservation and NFW" | |
| build_sdist: | |
| name: Build source distribution (sdist) | |
| # Build and test the sdist on every push/PR (like the wheels), so | |
| # sdist-packaging regressions are caught before release; the sdist is | |
| # only uploaded to PyPI on release creation (see deploy_pypi). | |
| runs-on: ubuntu-latest | |
| steps: | |
| # check-out this repository | |
| - uses: actions/checkout@v7 | |
| # Setup python | |
| - name: Set up Python | |
| uses: actions/setup-python@v7 | |
| 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@v7 | |
| 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: | | |
| # Expand the glob first, then append the [test] extras: quoting the | |
| # whole "galpy*.tar.gz[test]" would stop the shell expanding the glob. | |
| tarball=$(ls galpy*.tar.gz) | |
| python -m pip install -v "${tarball}[test]" | |
| - 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@v7 | |
| - 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@v7 | |
| - 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 }} |