Skip to content

Commit 87f4791

Browse files
committed
workflows: build-grpcio: add
We need an updated version of our old patch for the install_all_python_modules.sh script, since the project now uses pyproject.toml for pip instead of setup.py. The sunny day skip patch is preserved as well, and applies cleanly (no changes since v1.76.0). Ref: #45 Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
1 parent 6139ccb commit 87f4791

3 files changed

Lines changed: 207 additions & 0 deletions

File tree

.github/workflows/build-grpcio.yml

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

0 commit comments

Comments
 (0)