|
4 | 4 | release:
|
5 | 5 | types: [created]
|
6 | 6 |
|
| 7 | + # Enable Run Workflow button in GitHub UI |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
7 | 14 | jobs:
|
8 |
| - wheels: |
| 15 | + build_sdist: |
| 16 | + name: Build SDist |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v3 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Build SDist |
| 24 | + run: pipx run build --sdist |
| 25 | + |
| 26 | + - name: Check metadata |
| 27 | + run: pipx run twine check dist/* |
| 28 | + |
| 29 | + - uses: actions/upload-artifact@v3 |
| 30 | + with: |
| 31 | + path: dist/*.tar.gz |
| 32 | + |
| 33 | + |
| 34 | + build_wheels: |
| 35 | + name: Wheels on ${{ matrix.platform_id }} - ${{ matrix.os }} |
9 | 36 | runs-on: ${{ matrix.os }}
|
10 |
| - defaults: |
11 |
| - run: |
12 |
| - shell: bash -l {0} |
13 | 37 | strategy:
|
14 | 38 | fail-fast: false
|
15 | 39 | matrix:
|
16 |
| - os: ["ubuntu-latest"] |
| 40 | + # Loosely based on scikit-learn's config: |
| 41 | + # https://github.com/scikit-learn/scikit-learn/blob/main/.github/workflows/wheels.yml |
| 42 | + include: |
| 43 | + - os: windows-latest |
| 44 | + python-version: "3.8" |
| 45 | + platform_id: win_amd64 |
| 46 | + |
| 47 | + # Linux 64 bit manylinux2014 |
| 48 | + - os: ubuntu-latest |
| 49 | + python-version: "3.8" |
| 50 | + platform_id: manylinux_x86_64 |
| 51 | + manylinux_image: manylinux2014 |
| 52 | + |
| 53 | + # Use x86 macOS runner to build both x86 and ARM. GitHub does not offer M1/M2 yet (only self-hosted). |
| 54 | + - os: macos-latest |
| 55 | + python-version: "3.8" |
| 56 | + platform_id: macosx_x86_64 |
| 57 | + |
17 | 58 | steps:
|
18 |
| - - name: Checkout |
19 |
| - uses: actions/checkout@v3 |
20 |
| - - name: Set up Python |
21 |
| - uses: actions/setup-python@v4 |
22 |
| - with: |
23 |
| - python-version: '3.8' |
24 |
| - - name: Upgrade pip |
25 |
| - run: | |
26 |
| - python -m pip install --upgrade pip |
27 |
| - - name: Build manylinux Python wheels |
28 |
| - uses: RalfG/[email protected]_x86_64 |
29 |
| - with: |
30 |
| - python-versions: 'cp38-cp38 cp39-cp39' |
31 |
| - build-requirements: 'cffi numpy>=1.19,<1.20 cython' |
32 |
| - pre-build-command: ${{ format('sh suitesparse.sh {0}', github.ref) }} |
33 |
| - - name: Publish wheels to PyPI |
34 |
| - env: |
35 |
| - TWINE_USERNAME: __token__ |
36 |
| - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
37 |
| - run: | |
38 |
| - pip install twine |
39 |
| - twine upload dist/*-manylinux*.whl |
| 59 | + - uses: actions/checkout@v3 |
| 60 | + with: |
| 61 | + fetch-depth: 0 |
| 62 | + |
| 63 | + - uses: actions/setup-python@v4 |
| 64 | + with: |
| 65 | + python-version: ${{ matrix.python-version }} |
| 66 | + |
| 67 | +# - name: Install tools (macOS) |
| 68 | +# if: contains(matrix.os, 'macos') |
| 69 | +# # Install coreutils which includes `nproc` used by `make -j` in suitesparse.sh |
| 70 | +# # |
| 71 | +# # GitHub actions comes with libomp already installed, but for its native arch only. Must build universal one |
| 72 | +# # manually so that both x86 and arm builds can be built. |
| 73 | +# run: | |
| 74 | +# brew install coreutils |
| 75 | +# brew install libomp |
| 76 | +# sh add_arm_to_libomp_dylib.sh |
| 77 | + |
| 78 | + - name: Build Wheels |
| 79 | + env: |
| 80 | + # very verbose |
| 81 | + CIBW_BUILD_VERBOSITY: 3 |
| 82 | + |
| 83 | + # Build SuiteSparse |
| 84 | + CIBW_BEFORE_ALL: bash suitesparse.sh ${{ github.ref }} |
| 85 | + |
| 86 | + # CMAKE_GNUtoMS=ON asks suitesparse.sh to build libraries in MSVC style on Windows. |
| 87 | + CIBW_ENVIRONMENT_WINDOWS: CMAKE_GNUtoMS=ON GRAPHBLAS_PREFIX="C:/GraphBLAS" |
| 88 | + |
| 89 | + # macOS libomp requires special configs. BREW_LIBOMP=1 asks suitesparse.sh to include them. |
| 90 | + CIBW_ENVIRONMENT_MACOS: BREW_LIBOMP="1" |
| 91 | + |
| 92 | + # Uncomment to only build CPython wheels |
| 93 | +# CIBW_BUILD: "cp*" |
| 94 | + |
| 95 | + # macOS: build x86_64 and arm64 |
| 96 | + #CIBW_ARCHS_MACOS: "x86_64 arm64" |
| 97 | + |
| 98 | + # No 32-bit builds |
| 99 | + CIBW_SKIP: "*-win32 *_i686 *musl*" |
| 100 | + |
| 101 | + # Use delvewheel on Windows. |
| 102 | + # This copies graphblas.dll into the wheel. "repair" in cibuildwheel parlance includes copying any shared |
| 103 | + # libraries from the build host into the wheel to make the wheel self-contained. |
| 104 | + # Cibuildwheel includes tools for this for Linux and macOS, and they recommend delvewheel for Windows. |
| 105 | + # Note: Currently using a workaround: --no-mangle instead of stripping graphblas.dll |
| 106 | + # see https://github.com/adang1345/delvewheel/issues/33 |
| 107 | + CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel" |
| 108 | + CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair --add-path \"C:\\GraphBLAS\\bin\" --no-mangle \"libgomp-1.dll;libgcc_s_seh-1.dll\" -w {dest_dir} {wheel}" |
| 109 | + |
| 110 | + # make cibuildwheel install test dependencies from pyproject.toml |
| 111 | + CIBW_TEST_EXTRAS: "test" |
| 112 | + |
| 113 | + # run tests |
| 114 | + CIBW_TEST_COMMAND: "pytest {project}/suitesparse_graphblas/tests" |
| 115 | + |
| 116 | + # GitHub Actions macOS Intel runner cannot run ARM tests. |
| 117 | + CIBW_TEST_SKIP: "*-macosx_arm64" |
| 118 | + |
| 119 | + run: | |
| 120 | + python -m pip install cibuildwheel |
| 121 | + python -m cibuildwheel --output-dir wheelhouse . |
| 122 | + shell: bash |
| 123 | + |
| 124 | + - uses: actions/upload-artifact@v3 |
| 125 | + id: uploadAttempt1 |
| 126 | + continue-on-error: true |
| 127 | + with: |
| 128 | + path: wheelhouse/*.whl |
| 129 | + if-no-files-found: error |
| 130 | + |
| 131 | + # Retry upload if first attempt failed. This happens somewhat randomly and for irregular reasons. |
| 132 | + # Logic is a duplicate of previous step. |
| 133 | + - uses: actions/upload-artifact@v3 |
| 134 | + id: uploadAttempt2 |
| 135 | + if: steps.uploadAttempt1.outcome == 'failure' |
| 136 | + continue-on-error: false |
| 137 | + with: |
| 138 | + path: wheelhouse/*.whl |
| 139 | + if-no-files-found: error |
| 140 | + |
| 141 | + upload_all: |
| 142 | + name: Upload to PyPI |
| 143 | + needs: [build_wheels, build_sdist] |
| 144 | + runs-on: ubuntu-latest |
| 145 | + if: github.repository == 'GraphBLAS/python-suitesparse-graphblas' |
| 146 | +# if: github.event_name == 'release' && github.event.action == 'published' |
| 147 | + |
| 148 | + steps: |
| 149 | + - uses: actions/setup-python@v4 |
| 150 | + with: |
| 151 | + python-version: "3.x" |
| 152 | + |
| 153 | + - uses: actions/download-artifact@v3 |
| 154 | + with: |
| 155 | + name: artifact |
| 156 | + path: dist |
| 157 | + |
| 158 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
| 159 | + with: |
| 160 | + # PyPI does not allow replacing a file. Without this flag the entire action fails if even a single duplicate exists. |
| 161 | + skip_existing: true |
| 162 | + verbose: true |
| 163 | + # Real PyPI: |
| 164 | + password: ${{ secrets.PYPI_TOKEN }} |
| 165 | + |
| 166 | + # Test PyPI: |
| 167 | +# password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 168 | +# repository_url: https://test.pypi.org/legacy/ |
0 commit comments