|
| 1 | +name: Pip build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + |
| 11 | +jobs: |
| 12 | + build_sdist: |
| 13 | + name: Build SDist |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v2 |
| 17 | + with: |
| 18 | + submodules: true |
| 19 | + |
| 20 | + - name: Build SDist |
| 21 | + run: pipx run build --sdist |
| 22 | + |
| 23 | + - name: Check metadata |
| 24 | + run: pipx run twine check dist/* |
| 25 | + |
| 26 | + - uses: actions/upload-artifact@v2 |
| 27 | + with: |
| 28 | + path: dist/*.tar.gz |
| 29 | + |
| 30 | + build_wheels: |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + # Launch separate job for each python. The build is so much longer than |
| 35 | + # machine configuration/setup, so parallel builds will be faster. More |
| 36 | + # importantly, github times out after 6 hours _per job_. |
| 37 | + cpversion: ["cp36", "cp37", "cp38", "cp39", "cp310", "cp311"] |
| 38 | + os: [ { runs-on: ubuntu-latest, cibw-arch: manylinux_x86_64}, { runs-on: macos-latest, cibw-arch: macosx_x86_64}, { runs-on: macos-latest, cibw-arch: macosx_arm64}, { runs-on: windows-latest, cibw-arch: win_amd64} ] |
| 39 | + exclude: |
| 40 | + - os: { runs-on: macos-latest, cibw-arch: macosx_arm64} |
| 41 | + cpversion: "cp36" |
| 42 | + - os: { runs-on: macos-latest, cibw-arch: macosx_arm64} |
| 43 | + cpversion: "cp37" |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + name: Build wheels ${{ matrix.cpversion }}-${{ matrix.os.cibw-arch }} |
| 48 | + runs-on: ${{ matrix.os.runs-on }} |
| 49 | + |
| 50 | + env: |
| 51 | + CIBW_BUILD_VERBOSITY: 3 |
| 52 | + # This is very dubious... It *may* work because these are just cpp libraries that should not depend on the python version. Still, super-dubious. |
| 53 | + CIBW_BEFORE_BUILD_WINDOWS: "python -m pip install delvewheel" |
| 54 | + CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "python -m delvewheel repair --no-mangle-all --add-path build\\temp.win-amd64-3.6\\Release;build\\temp.win-amd64-3.6\\Release\\Release;build\\temp.win-amd64-3.6\\Release\\_deps\\gmp-src\\lib;build\\temp.win-amd64-3.6\\Release\\_deps\\mpfr-src\\lib -w {dest_dir} {wheel} " |
| 55 | + CIBW_TEST_COMMAND: "python {project}/tests/test_basic.py {project}/data/" |
| 56 | + CIBW_BUILD: "${{ matrix.cpversion }}-${{ matrix.os.cibw-arch }}" |
| 57 | + CIBW_TEST_SKIP: "*-macosx_arm64" |
| 58 | + CIBW_ENVIRONMENT: "MAX_JOBS=2" |
| 59 | + # Why universal2 here? It's not included above in CIBW_BUILD |
| 60 | + CIBW_ARCHS_MACOS: "x86_64 arm64 universal2" |
| 61 | + CIBW_ENVIRONMENT_MACOS: "CMAKE_OSX_ARCHITECTURES=\"${{ matrix.os.cibw-arch == 'macosx_x86_64' && 'x86_64' || matrix.os.cibw-arch == 'macosx_arm64' && 'arm64' || matrix.os.cibw-arch == 'macosx_universal2' && 'arm64;x86_64' || '' }}\"" |
| 62 | + |
| 63 | + |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@v3 |
| 66 | + with: |
| 67 | + submodules: 'recursive' |
| 68 | + |
| 69 | + - uses: actions/setup-python@v2 |
| 70 | + name: Install Python |
| 71 | + with: |
| 72 | + python-version: '3.7' |
| 73 | + |
| 74 | + - name: Install cibuildwheel |
| 75 | + run: | |
| 76 | + python -m pip install --upgrade pip |
| 77 | + python -m pip install cibuildwheel==2.12.0 |
| 78 | +
|
| 79 | + - name: Build wheels |
| 80 | + run: | |
| 81 | + python -m cibuildwheel --output-dir wheelhouse |
| 82 | +
|
| 83 | + # Upload binaries to github |
| 84 | + - uses: actions/upload-artifact@v2 |
| 85 | + with: |
| 86 | + path: | |
| 87 | + ./wheelhouse/*.whl |
| 88 | + ./wheelhouse/*.tar.gz |
| 89 | +
|
| 90 | + # # Push the resulting binaries to pypi on a tag starting with 'v' |
| 91 | + upload_pypi: |
| 92 | + needs: [build_wheels] |
| 93 | + runs-on: ubuntu-latest |
| 94 | + # upload to PyPI on every tag starting with 'v' |
| 95 | + # if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') |
| 96 | + # alternatively, to publish when a GitHub Release is created, use the following rule: |
| 97 | + if: github.event_name == 'release' && github.event.action == 'published' |
| 98 | + steps: |
| 99 | + - uses: actions/download-artifact@v2 |
| 100 | + with: |
| 101 | + name: artifact |
| 102 | + path: dist |
| 103 | + |
| 104 | + |
| 105 | + with: |
| 106 | + user: __token__ |
| 107 | + password: ${{ secrets.pypi_password }} |
| 108 | + skip_existing: true |
| 109 | + # To test: repository_url: https://test.pypi.org/legacy/ |
0 commit comments