diff --git a/.github/workflows/ciwheels.yml b/.github/workflows/ciwheels.yml index 86f6c2cb..92940498 100644 --- a/.github/workflows/ciwheels.yml +++ b/.github/workflows/ciwheels.yml @@ -1,9 +1,12 @@ name: Pip build +# Run on the main branch and on tags (note conditional below) on: push: branches: - main + # tags: + # - v* pull_request: branches: - main @@ -28,63 +31,83 @@ jobs: path: dist/*.tar.gz build_wheels: + + # Only run if the commit message contains '[ci build]' OR always run if it's a tag + # This will not respect the tag if it appears in a pull request commit message. Those builds always show up as 'synchronize' events, and there is no easy way to get the corresponding commit messages. We instead pull the PR title to check for tags. + # More info here: https://github.community/t/accessing-commit-message-in-pull-request-event/17158/13 + # if: "contains(toJSON(github.event.commits.*.message), '[ci build]') || contains(toJSON(github.event.pull_request.title), '[ci build]') || contains(github.ref, 'refs/tags')" + strategy: fail-fast: false matrix: - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] - os: - - runs-on: ubuntu-latest - cibw-arch: manylinux_x86_64 - cibw-platform: manylinux2014 - - runs-on: macos-latest - cibw-arch: macosx_x86_64 - cibw-platform: macosx_x86_64 - - runs-on: macos-latest - cibw-arch: macosx_arm64 - cibw-platform: macosx_arm64 - - runs-on: windows-latest - cibw-arch: win_amd64 - cibw-platform: win_amd64 + # Launch separate job for each python. The build is so much longer than + # machine configuration/setup, so parallel builds will be faster. More + # importantly, github times out after 6 hours _per job_. + + cpversion: ["cp36", "cp37", "cp38", "cp39", "cp310", "cp311", "cp312"] + os: [ { runs-on: ubuntu-latest, cibw-arch: manylinux_x86_64, cibw-platform: manylinux2014}, { 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} ] exclude: - - os: { runs-on: macos-latest, cibw-arch: macosx_arm64 } - python-version: "3.6" - - os: { runs-on: macos-latest, cibw-arch: macosx_arm64 } - python-version: "3.7" + - os: { runs-on: macos-latest, cibw-arch: macosx_arm64} + cpversion: "cp36" + - os: { runs-on: macos-latest, cibw-arch: macosx_arm64} + cpversion: "cp37" + - name: Build wheels ${{ matrix.python-version }}-${{ matrix.os.cibw-arch }} + + name: Build wheels ${{ matrix.cpversion }}-${{ matrix.os.cibw-arch }} runs-on: ${{ matrix.os.runs-on }} + env: CIBW_BUILD_VERBOSITY: 3 - CIBW_BEFORE_BUILD_LINUX: "yum install -y libXrandr libXrandr-devel libXinerama libXinerama-devel libXcursor libXcursor-devel libXi libXi-devel" - CIBW_BUILD: "cp${{ matrix.python-version }}-${{ matrix.os.cibw-arch }}" + CIBW_BEFORE_BUILD_LINUX : "yum install -y libXrandr libXrandr-devel libXinerama libXinerama-devel libXcursor libXcursor-devel libXi libXi-devel" + CIBW_BUILD: "${{ matrix.cpversion }}-${{ matrix.os.cibw-arch }}" + # CIBW_TEST_SKIP: "*-macosx_arm64" CIBW_ENVIRONMENT: "MAX_JOBS=2" + # Why universal2 here? It's not included above in CIBW_BUILD CIBW_ARCHS_MACOS: "x86_64 arm64 universal2" - 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' || '' }}'" + 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' || '' }}\"" MACOSX_DEPLOYMENT_TARGET: 10.16 - CIBW_PLATFORM: ${{ matrix.os.cibw-platform }} + # CIBW_PRERELEASE_PYTHONS: True + + + + steps: - uses: actions/checkout@v3 with: submodules: 'recursive' - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install cibuildwheel==2.17.0 - - name: Build wheels - run: cibuildwheel --output-dir wheelhouse + uses: pypa/cibuildwheel@v2.17.0 + + # Upload binaries to github - uses: actions/upload-artifact@v3 with: name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} path: | ./wheelhouse/*.whl ./wheelhouse/*.tar.gz + + # # Push the resulting binaries to pypi on a tag starting with 'v' + # upload_pypi: + # needs: [build_wheels] + # runs-on: ubuntu-latest + # # upload to PyPI on every tag starting with 'v' + # # if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') + # # alternatively, to publish when a GitHub Release is created, use the following rule: + # if: github.event_name == 'release' && github.event.action == 'published' + # steps: + # - uses: actions/download-artifact@v3 + # with: + # name: artifact + # path: dist + + # - uses: pypa/gh-action-pypi-publish@v1.5.0 + # with: + # user: __token__ + # password: ${{ secrets.pypi_password }} + # skip_existing: true + # # To test: repository_url: https://test.pypi.org/legacy/ \ No newline at end of file