diff --git a/.github/workflows/build-grpcio.yml b/.github/workflows/build-grpcio.yml new file mode 100644 index 0000000..d157c3b --- /dev/null +++ b/.github/workflows/build-grpcio.yml @@ -0,0 +1,103 @@ +--- +name: Build grpcio wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'grpcio version to build (git tag without leading v, e.g. 1.78.0)' + required: true + default: '1.78.0' + pull_request: + paths: + - '.github/workflows/build-grpcio.yml' + - 'patches/grpcio/**' + +concurrency: + group: ${{ github.workflow }}-${{ inputs.version || '1.78.0' }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +env: + GRPCIO_VERSION: ${{ inputs.version || '1.78.0' }} + UV_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/ + UV_INDEX_STRATEGY: unsafe-best-match + UV_ONLY_BINARY: ':all:' + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + build_wheels: + name: Build grpcio ${{ inputs.version || '1.78.0' }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + strategy: + fail-fast: false + matrix: + # grpcio doesn't advertise free-threaded support yet + # (src/python/grpcio/python_version.py lists only 3.10-3.14), so + # 3.14t is dropped from the usual default matrix. + # See also: https://github.com/grpc/grpc/issues/38762 + python: ["cp312", "cp313", "cp314"] + + steps: + - name: Checkout grpc v${{ env.GRPCIO_VERSION }} + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + repository: grpc/grpc + ref: v${{ env.GRPCIO_VERSION }} + submodules: true + persist-credentials: false + + - name: Checkout python-wheels + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + path: python-wheels + persist-credentials: false + + # install_all_python_modules.sh (run below via CIBW_TEST_COMMAND) would + # otherwise reinstall grpcio from source before testing, rather than + # testing the wheel this job just built. + - name: Patch grpc source + run: git apply python-wheels/patches/grpcio/${{ env.GRPCIO_VERSION }}/00*.patch + + - name: Build wheels + uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0 + env: + CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64 + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + # Enables grpc's optional systemd socket-activation feature (see + # src/python/grpcio/README.rst); needs libsystemd-devel present. + CIBW_ENVIRONMENT: GRPC_PYTHON_BUILD_WITH_SYSTEMD=1 + CIBW_BEFORE_ALL: dnf install -y systemd-devel + CIBW_BEFORE_BUILD: pip install -r requirements.txt + CIBW_REPAIR_WHEEL_COMMAND: auditwheel repair --strip -w {dest_dir} {wheel} + CIBW_TEST_REQUIRES: setuptools + CIBW_TEST_COMMAND: >- + cd {project}/tools/distrib && + PIP_NO_BUILD_ISOLATION=0 ./install_all_python_modules.sh && + cd {project}/src && python python/grpcio_tests/setup.py test_lite + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: grpcio-${{ env.GRPCIO_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: ./wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish grpcio ${{ inputs.version || '1.78.0' }} to GitLab + needs: [build_wheels] + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Publish wheels and open docs PR + uses: riseproject-dev/python-wheels/actions/publish-wheels@main + with: + artifact-pattern: grpcio-${{ env.GRPCIO_VERSION }}-*-manylinux_riscv64 + gitlab-username: ${{ vars.GITLAB_DEPLOY_USER }} + gitlab-token: ${{ secrets.GITLAB_DEPLOY_TOKEN }} + gitlab-project-id: ${{ vars.GITLAB_PROJECT_ID }} + gh-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/patches/grpcio/1.78.0/0001-don-t-build-grpcio-in-install_all_python_modules.sh.patch b/patches/grpcio/1.78.0/0001-don-t-build-grpcio-in-install_all_python_modules.sh.patch new file mode 100644 index 0000000..8c176e3 --- /dev/null +++ b/patches/grpcio/1.78.0/0001-don-t-build-grpcio-in-install_all_python_modules.sh.patch @@ -0,0 +1,37 @@ +From 67901366eea10b98c29dc57a72c796ec786a210e Mon Sep 17 00:00:00 2001 +From: Trevor Gamblin +Date: Thu, 13 Aug 2026 13:31:27 -0400 +Subject: [PATCH] don't build grpcio in install_all_python_modules.sh + +We run this script in CIBW_TEST_COMMAND to install grpcio's other Python +packages and their test dependencies, but we don't want it to reinstall +grpcio itself from source - we want the test environment to use the +wheel built (and about to be distributed) in this same cibuildwheel +invocation. + +This is a rework of the older patches from Mark to handle upstream's +change to using pyproject.toml instead of setup.py. + +Upstream-Status: Inappropriate [upstream tests in a different way] + +Signed-off-by: Trevor Gamblin +--- + tools/distrib/install_all_python_modules.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/distrib/install_all_python_modules.sh b/tools/distrib/install_all_python_modules.sh +index 5652580c76..acab4f9d6f 100755 +--- a/tools/distrib/install_all_python_modules.sh ++++ b/tools/distrib/install_all_python_modules.sh +@@ -30,7 +30,7 @@ function maybe_run_command () { + } + + python3 -m pip install --upgrade "cython==3.1.1"; +-python3 -m pip install .; ++#python3 -m pip install .; + + # Build and install grpcio_tools + pushd tools/distrib/python/grpcio_tools; +-- +2.55.0 + diff --git a/patches/grpcio/1.78.0/0002-Skip-test_sunny_day.patch b/patches/grpcio/1.78.0/0002-Skip-test_sunny_day.patch new file mode 100644 index 0000000..798113c --- /dev/null +++ b/patches/grpcio/1.78.0/0002-Skip-test_sunny_day.patch @@ -0,0 +1,67 @@ +From 3b1b82e17e21b4b6b59c6240fb233b2f2f0175ea Mon Sep 17 00:00:00 2001 +From: Mark Ryan +Date: Mon, 3 Nov 2025 09:27:22 +0000 +Subject: [PATCH 2/2] Skip test_sunny_day + +The test + +tests.unit._dynamic_stubs_test.DynamicStubTest.test_sunny_day + +seems to be hanging on the riscv64 builders. + +Use the nuclear option and strip the test out entirely to ensure no +strange import interactions happen. + +Upstream-Status: To upstream [ Further investigation needed ] + +Signed-off-by: Mark Ryan +Signed-off-by: Trevor Gamblin +--- + src/python/grpcio_tests/tests/tests.json | 1 - + .../tests/unit/_dynamic_stubs_test.py | 18 ------------------ + 2 files changed, 19 deletions(-) + +diff --git a/src/python/grpcio_tests/tests/tests.json b/src/python/grpcio_tests/tests/tests.json +index 86b359e2d2..8ab1ead2c2 100644 +--- a/src/python/grpcio_tests/tests/tests.json ++++ b/src/python/grpcio_tests/tests/tests.json +@@ -60,7 +60,6 @@ + "tests.unit._cython.cygrpc_test.SecureServerSecureClient", + "tests.unit._cython.cygrpc_test.TypeSmokeTest", + "tests.unit._dns_resolver_test.DNSResolverTest", +- "tests.unit._dynamic_stubs_test.DynamicStubTest", + "tests.unit._empty_message_test.EmptyMessageTest", + "tests.unit._error_message_encoding_test.ErrorMessageEncodingTest", + "tests.unit._exit_test.ExitTest", +diff --git a/src/python/grpcio_tests/tests/unit/_dynamic_stubs_test.py b/src/python/grpcio_tests/tests/unit/_dynamic_stubs_test.py +index 98bdb19a2f..108db35ea3 100644 +--- a/src/python/grpcio_tests/tests/unit/_dynamic_stubs_test.py ++++ b/src/python/grpcio_tests/tests/unit/_dynamic_stubs_test.py +@@ -136,24 +136,6 @@ def _test_grpc_tools_unimportable(): + _assert_unimplemented("grpcio-tools") + + +-# NOTE(rbellevi): multiprocessing.Process fails to pickle function objects +-# when they do not come from the "__main__" module, so this test passes +-# if run directly on Windows or MacOS, but not if started by the test runner. +-@unittest.skipIf( +- os.name == "nt" or "darwin" in sys.platform, +- "Windows and MacOS multiprocessing unsupported", +-) +-class DynamicStubTest(unittest.TestCase): +- def test_sunny_day(self): +- _run_in_subprocess(_test_sunny_day) +- +- def test_well_known_types(self): +- _run_in_subprocess(_test_well_known_types) +- +- def test_grpc_tools_unimportable(self): +- _run_in_subprocess(_test_grpc_tools_unimportable) +- +- + if __name__ == "__main__": + logging.basicConfig() + unittest.main(verbosity=2) +-- +2.34.1 +