8 wide SIMD (#62) #21
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: Python Wheels | |
| on: | |
| push: | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| jobs: | |
| build_wheels: | |
| name: Build wheels (${{ matrix.os }}, Python ${{ matrix.python }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux x86_64 | |
| - os: ubuntu-latest | |
| python: '3.12' | |
| target: linux-x86_64 | |
| - os: ubuntu-latest | |
| python: '3.11' | |
| target: linux-x86_64 | |
| - os: ubuntu-latest | |
| python: '3.10' | |
| target: linux-x86_64 | |
| # macOS ARM64 | |
| - os: macos-latest | |
| python: '3.12' | |
| target: macos-arm64 | |
| - os: macos-latest | |
| python: '3.11' | |
| target: macos-arm64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Set up Zig | |
| uses: mlugg/setup-zig@v2 | |
| with: | |
| version: master | |
| - name: Set version from tag | |
| run: | | |
| if [[ "$GITHUB_REF" == refs/tags/v* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| else | |
| VERSION="0.0.0.dev" | |
| fi | |
| sed -i.bak "s/version = \".*\"/version = \"$VERSION\"/" bindings/python/pyproject.toml | |
| sed -i.bak "s/__version__ = \".*\"/__version__ = \"$VERSION\"/" bindings/python/astroz/__init__.py | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| - name: Build Python bindings | |
| run: | | |
| PYTHON_INCLUDE=$(python -c "import sysconfig; print(sysconfig.get_path('include'))") | |
| PYTHON_LIBDIR=$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))") | |
| PYTHON_LIB=$(python -c "import sys; print(f'python{sys.version_info.major}.{sys.version_info.minor}')") | |
| echo "Python include: $PYTHON_INCLUDE" | |
| echo "Python libdir: $PYTHON_LIBDIR" | |
| echo "Python lib: $PYTHON_LIB" | |
| # On macOS, don't link against Python library - symbols resolve at load time | |
| if [[ "$RUNNER_OS" == "macOS" ]]; then | |
| zig build python-bindings \ | |
| -Dpython-include="$PYTHON_INCLUDE" \ | |
| -Doptimize=ReleaseFast | |
| else | |
| zig build python-bindings \ | |
| -Dpython-include="$PYTHON_INCLUDE" \ | |
| -Dpython-lib="$PYTHON_LIB" \ | |
| -Dpython-lib-path="$PYTHON_LIBDIR" \ | |
| -Doptimize=ReleaseFast | |
| fi | |
| - name: Copy built library | |
| run: | | |
| ls -la zig-out/bindings/python/astroz/ | |
| # Zig builds lib_astroz.so (Linux) or lib_astroz.dylib (macOS) | |
| if [ -f zig-out/bindings/python/astroz/lib_astroz.so ]; then | |
| cp zig-out/bindings/python/astroz/lib_astroz.so bindings/python/astroz/_astroz.so | |
| elif [ -f zig-out/bindings/python/astroz/lib_astroz.dylib ]; then | |
| cp zig-out/bindings/python/astroz/lib_astroz.dylib bindings/python/astroz/_astroz.so | |
| else | |
| echo "ERROR: Could not find built library" | |
| exit 1 | |
| fi | |
| - name: Install build tools | |
| run: pip install build wheel | |
| - name: Build wheel | |
| run: | | |
| cd bindings/python | |
| python -m build --wheel | |
| - name: Repair wheel (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| pip install auditwheel patchelf | |
| auditwheel repair bindings/python/dist/*.whl -w bindings/python/dist/repaired/ || true | |
| if [ -d "bindings/python/dist/repaired" ] && [ "$(ls -A bindings/python/dist/repaired/)" ]; then | |
| rm bindings/python/dist/*.whl | |
| mv bindings/python/dist/repaired/*.whl bindings/python/dist/ | |
| fi | |
| - name: Test wheel | |
| run: | | |
| pip install bindings/python/dist/*.whl | |
| python -c "from astroz import Tle, Sgp4, __version__; print(f'astroz {__version__}')" | |
| python -c " | |
| from astroz import Tle, Sgp4 | |
| tle = Tle('1 25544U 98067A 24127.82853009 .00015698 00000+0 27310-3 0 9995\n2 25544 51.6393 160.4574 0003580 140.6673 205.7250 15.50957674452123') | |
| sgp4 = Sgp4(tle) | |
| pos, vel = sgp4.propagate(30.0) | |
| print(f'Position: {pos}') | |
| " | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel-${{ matrix.target }}-py${{ matrix.python }} | |
| path: bindings/python/dist/*.whl | |
| build_sdist: | |
| name: Build source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Set version from tag | |
| run: | | |
| if [[ "$GITHUB_REF" == refs/tags/v* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| else | |
| VERSION="0.0.0.dev" | |
| fi | |
| sed -i "s/version = \".*\"/version = \"$VERSION\"/" bindings/python/pyproject.toml | |
| sed -i "s/__version__ = \".*\"/__version__ = \"$VERSION\"/" bindings/python/astroz/__init__.py | |
| - name: Build sdist | |
| run: | | |
| cd bindings/python | |
| pip install build | |
| python -m build --sdist | |
| - name: Upload sdist | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sdist | |
| path: bindings/python/dist/*.tar.gz | |
| publish: | |
| name: Publish to PyPI | |
| needs: [build_wheels, build_sdist] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheel-* | |
| path: dist | |
| merge-multiple: true | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist | |
| - name: List dist contents | |
| run: ls -la dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |