|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on the `manylinux_wheels` job of |
| 5 | +# https://github.com/google/pytype/blob/2024.10.11/.github/workflows/build.yml |
| 6 | +name: Build pytype wheels (riscv64) |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'Version glob to (re)build; empty builds every version of docs/packages/pytype.yaml not released yet' |
| 13 | + required: false |
| 14 | + default: '' |
| 15 | + pull_request: |
| 16 | + branches: [main] |
| 17 | + paths: |
| 18 | + - '.github/workflows/build-pytype.yml' |
| 19 | + - 'docs/packages/pytype.yaml' |
| 20 | + push: |
| 21 | + branches: [main] |
| 22 | + paths: |
| 23 | + - '.github/workflows/build-pytype.yml' |
| 24 | + - 'docs/packages/pytype.yaml' |
| 25 | + |
| 26 | +concurrency: |
| 27 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 28 | + cancel-in-progress: true |
| 29 | + |
| 30 | +permissions: |
| 31 | + contents: read # to fetch code (actions/checkout) |
| 32 | + |
| 33 | +env: |
| 34 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 35 | + |
| 36 | +jobs: |
| 37 | + setup: |
| 38 | + uses: $/.github/workflows/_setup.yml |
| 39 | + with: |
| 40 | + package: pytype |
| 41 | + version: ${{ inputs.version }} |
| 42 | + |
| 43 | + build_wheels: |
| 44 | + needs: [setup] |
| 45 | + if: needs.setup.outputs.versions != '[]' |
| 46 | + name: Build pytype ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 |
| 47 | + runs-on: ubuntu-24.04-riscv |
| 48 | + timeout-minutes: 300 |
| 49 | + strategy: |
| 50 | + fail-fast: false |
| 51 | + matrix: |
| 52 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 53 | + # pytype rejects any interpreter past 3.12 ("Python versions > 3.12 are |
| 54 | + # not yet supported"), which is why upstream ships cp310-cp312 only. |
| 55 | + python: ["cp312"] |
| 56 | + |
| 57 | + env: |
| 58 | + PYTYPE_VERSION: ${{ matrix.version }} |
| 59 | + |
| 60 | + steps: |
| 61 | + - name: Checkout pytype ${{ env.PYTYPE_VERSION }} |
| 62 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 63 | + with: |
| 64 | + repository: google/pytype |
| 65 | + ref: ${{ env.PYTYPE_VERSION }} |
| 66 | + submodules: recursive |
| 67 | + persist-credentials: false |
| 68 | + |
| 69 | + - name: Build wheels |
| 70 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 71 | + with: |
| 72 | + output-dir: wheelhouse/ |
| 73 | + only: ${{ matrix.python }}-manylinux_riscv64 |
| 74 | + env: |
| 75 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 76 | + # libcst and msgspec have no riscv64 wheels on public PyPI. |
| 77 | + CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ |
| 78 | + CIBW_TEST_REQUIRES: pytest pytest-xdist |
| 79 | + # The wheel carries pytype's unit tests but not the pytype.tests |
| 80 | + # helpers a third of them import, so those are copied in beside it. |
| 81 | + CIBW_TEST_SOURCES: pytype/tests/__init__.py pytype/tests/test_base.py pytype/tests/test_utils.py |
| 82 | + # Deselected: the helpers themselves; main_test.py and test_error_doc, |
| 83 | + # which run files that exist only in a git checkout; the two typeshed |
| 84 | + # tests reading typeshed/tests/, excluded from the wheel; test_die, |
| 85 | + # which needs a mkdir to fail and the container runs as root; and the |
| 86 | + # two serialize_ast tests, which fail the same way on an x86 checkout. |
| 87 | + CIBW_TEST_COMMAND: >- |
| 88 | + cp -r pytype/tests "$(python -c 'import pytype, os; print(os.path.dirname(pytype.__file__))')" |
| 89 | + && printf 'def f(x: int) -> str:\n return str(x)\n' > ok.py |
| 90 | + && pytype ok.py |
| 91 | + && python -m pytest --pyargs pytype -n auto |
| 92 | + --deselect tests/test_base.py |
| 93 | + --deselect tests/test_utils.py |
| 94 | + --deselect main_test.py |
| 95 | + --deselect errors/errors_test.py::ErrorDocTest::test_error_doc |
| 96 | + --deselect imports/typeshed_test.py::TestTypeshedLoading::test_blacklisted_modules |
| 97 | + --deselect imports/typeshed_test.py::TestTypeshedLoading::test_read_blacklist |
| 98 | + --deselect tools/tool_utils_test.py::TestMakeDirsOrDie::test_die |
| 99 | + --deselect pytd/serialize_ast_test.py::SerializeAstTest::test_node_index_visitor_usage |
| 100 | + --deselect pytd/serialize_ast_test.py::SerializeAstTest::test_unrestorable_child |
| 101 | +
|
| 102 | + - name: Check the extension module made it into the wheel |
| 103 | + run: | |
| 104 | + python3 - wheelhouse/*.whl <<'EOF' |
| 105 | + import sys, zipfile |
| 106 | + for whl in sys.argv[1:]: |
| 107 | + names = zipfile.ZipFile(whl).namelist() |
| 108 | + found = {n.split(".", 1)[0] for n in names if n.endswith(".so")} |
| 109 | + assert found == {"pytype/typegraph/cfg"}, (whl, found) |
| 110 | + print(whl, "ok") |
| 111 | + EOF |
| 112 | +
|
| 113 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 114 | + with: |
| 115 | + name: pytype-${{ env.PYTYPE_VERSION }}-${{ matrix.python }}-manylinux_riscv64 |
| 116 | + path: wheelhouse/*.whl |
| 117 | + if-no-files-found: error |
| 118 | + |
| 119 | + publish: |
| 120 | + name: Publish pytype ${{ matrix.version }} |
| 121 | + needs: [setup, build_wheels] |
| 122 | + if: needs.setup.outputs.versions != '[]' |
| 123 | + strategy: |
| 124 | + fail-fast: false |
| 125 | + matrix: |
| 126 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 127 | + permissions: |
| 128 | + contents: write |
| 129 | + pull-requests: write |
| 130 | + uses: $/.github/workflows/_publish-wheel.yml |
| 131 | + secrets: |
| 132 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 133 | + with: |
| 134 | + artifact-pattern: pytype-${{ matrix.version }}-*-manylinux_riscv64 |
0 commit comments