Skip to content

Commit e644b5f

Browse files
committed
[Python dist] Build aarch64 in different Kokoro job
1 parent 558821b commit e644b5f

15 files changed

+95
-20
lines changed

src/python/grpcio_observability/setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ def get_ext_filename(self, ext_name):
177177
EXTRA_ENV_LINK_ARGS += " -lpthread"
178178
if check_linker_need_libatomic():
179179
EXTRA_ENV_LINK_ARGS += " -latomic"
180+
if "linux" in sys.platform:
181+
EXTRA_ENV_LINK_ARGS += " -static-libgcc"
180182

181183
# This enables the standard link-time optimizer, which help us prevent some undefined symbol errors by
182184
# remove some unused symbols from .so file.

tools/bazelify_tests/dockerimage_current_versions.bzl

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ DOCKERIMAGE_CURRENT_VERSIONS = {
3636
"tools/dockerfile/distribtest/csharp_dotnet5_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/csharp_dotnet5_x64@sha256:004e02902825b54c7f0d60eaed0819acf6f10c24853bf8f793001114e9969abd",
3737
"tools/dockerfile/distribtest/csharp_ubuntu2204_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/csharp_ubuntu2204_x64@sha256:a439f2ccbc666f231e511a8e58eb7f66a3de4820a4d5aded1e62275cf8ac49f0",
3838
"tools/dockerfile/distribtest/php8_debian12_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/php8_debian12_x64@sha256:42399d061f234ee0ef79b333555db0e11ca4f106bb1d49276abf99c459c104f0",
39-
"tools/dockerfile/distribtest/python_alpine_aarch64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_alpine_aarch64@sha256:bcdfc865daa8c61dc6f9b67ddab63d47fcacb109ed57de5b9a7673dff907e02c",
39+
"tools/dockerfile/distribtest/python_alpine_aarch64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_alpine_aarch64@sha256:7f727b0896c5e86ff7e214255e2e05dee45689c1793d6e698905b3465a2752e9",
4040
"tools/dockerfile/distribtest/python_alpine_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_alpine_x64@sha256:1bbc6fa5b4b650d3037d089e164d364e05a6daf1ed6dd1025ba07cc127f73d7d",
4141
"tools/dockerfile/distribtest/python_arch_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_arch_x64@sha256:2c1adadeb010e107132cf5137f32a2d18727796631245b110cc74f69c07502e1",
4242
"tools/dockerfile/distribtest/python_bullseye_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_bullseye_x64@sha256:80553398f0c59c1dc186052f4f2deaf18fea582f6d1d166eec6ea298639031fb",
@@ -84,14 +84,14 @@ DOCKERIMAGE_CURRENT_VERSIONS = {
8484
"tools/dockerfile/interoptest/grpc_interop_java.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_interop_java@sha256:6c0319bbbf77d6c198f61adf92d205efd33cbd2cccaf914a1af8f2dcb61b16a1",
8585
"tools/dockerfile/interoptest/grpc_interop_node.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_interop_node@sha256:549a7683cc024fb7ffee807eaa8acb6c2d5a5dd0184a2590f91852804eea39a4",
8686
"tools/dockerfile/interoptest/grpc_interop_nodepurejs.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_interop_nodepurejs@sha256:62f148c4e8b031d02d445e993a840c53eb61566ad0bc007f1d89a3387d1f73a7",
87-
"tools/dockerfile/interoptest/grpc_interop_php7.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_interop_php7@sha256:eea8738f0aa1b6bbd56b847cbdfd0e0b98a46306d86db2494557f25c334abe4d",
87+
"tools/dockerfile/interoptest/grpc_interop_php7.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_interop_php7@sha256:1927feeb04a1146de3a104ae40c02307c51aad0ad26aa40afdef1964df3e8e4d",
8888
"tools/dockerfile/interoptest/grpc_interop_python.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_interop_python@sha256:b3e62554f360f18672711affb79c509a80083a1ddb8e5221bd3b9823a596d0fb",
8989
"tools/dockerfile/interoptest/grpc_interop_pythonasyncio.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_interop_pythonasyncio@sha256:c349c6e92d32f42e619134ef34d6d33e33e0aa106ea66388b2c22e4231a7baa6",
9090
"tools/dockerfile/interoptest/grpc_interop_ruby.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_interop_ruby@sha256:ce9539e9068b2597d5d43dc2bb7df17b84fd8192759cf7a02132b676ca6fa4ed",
9191
"tools/dockerfile/interoptest/lb_interop_fake_servers.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/lb_interop_fake_servers@sha256:b89a51dd9147e1293f50ee64dd719fce5929ca7894d3770a3d80dbdecb99fd52",
9292
"tools/dockerfile/test/android_ndk.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/android_ndk@sha256:e4fd2e0048c4ffd2a04e4a41154ee469ed61e058cb704ee95071f7a3bdad507a",
93-
"tools/dockerfile/test/bazel.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/bazel@sha256:a0ca2c4f113c4d9e62e67b36d1734c0ffc3baff851cc48f23616df82484f905d",
94-
"tools/dockerfile/test/bazel_arm64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/bazel_arm64@sha256:2728d010d87cb1845d002efbc3d08dadc283e8d0b7e0b582c2623960af61d2c5",
93+
"tools/dockerfile/test/bazel.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/bazel@sha256:2677aecec57bb89bc0c7a409151507187343ba8272bdafc3e42d451f5841bd57",
94+
"tools/dockerfile/test/bazel_arm64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/bazel_arm64@sha256:14157b9987b3da1a29cab71124f566c04342490f3764f52c64cb65c0158223ad",
9595
"tools/dockerfile/test/csharp_debian11_arm64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/csharp_debian11_arm64@sha256:4d4bc5f15e03f3d3d8fd889670ecde2c66a2e4d2dd9db80733c05c1d90c8a248",
9696
"tools/dockerfile/test/csharp_debian11_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/csharp_debian11_x64@sha256:0763d919b17b4cfe5b65aff3bf911c04e9e4d46d11649858742033facd9f534f",
9797
"tools/dockerfile/test/cxx_alpine_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/cxx_alpine_x64@sha256:f49643b001fde1559e1607fa2735230c0a2acf97fb854e3bd56fb9e1c419883d",
@@ -114,5 +114,5 @@ DOCKERIMAGE_CURRENT_VERSIONS = {
114114
"tools/dockerfile/test/rbe_ubuntu2004.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/rbe_ubuntu2004@sha256:b3eb1a17b7b091e3c5648a803076b2c40601242ff91c04d55997af6641305f68",
115115
"tools/dockerfile/test/ruby_debian11_arm64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_debian11_arm64@sha256:d2e79919b2e2d4cc36a29682ecb5170641df4fb506cfb453978ffdeb8a841bd9",
116116
"tools/dockerfile/test/ruby_debian11_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_debian11_x64@sha256:6e8b4696ba0661f11a31ed0992a94d2efcd889a018f57160f0e2fb62963f3593",
117-
"tools/dockerfile/test/sanity.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/sanity@sha256:8b8e0b83725dfc5f81c901b3a737872410ee04fc1cb8b9ec5b2e4a5670fbf23c",
117+
"tools/dockerfile/test/sanity.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/sanity@sha256:998a0ec246abde100bd0f295cf2d1945e381a7f53d3309f94dcadf73295fdeb9",
118118
}

tools/distrib/python/grpcio_tools/setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ def new_compile(obj, src, ext, cc_args, extra_postargs, pp_opts):
227227
EXTRA_ENV_LINK_ARGS += " -lpthread"
228228
if check_linker_need_libatomic():
229229
EXTRA_ENV_LINK_ARGS += " -latomic"
230+
if "linux" in sys.platform:
231+
EXTRA_ENV_LINK_ARGS += " -static-libgcc"
230232

231233
# Explicitly link Core Foundation framework for MacOS to ensure no symbol is
232234
# missing when compiled using package managers like Conda.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
us-docker.pkg.dev/grpc-testing/testing-images-public/python_alpine_aarch64:086c6b7ba4177b5c086a4e1e36019fdd1d86a061@sha256:da5d191e62811fd3470d593aa9a7c2bfc8ee7d3453db92db13d62edb2eb9f39e
1+
us-docker.pkg.dev/grpc-testing/testing-images-public/python_alpine_aarch64:e78a4b229d02acb518073cddbeb1d359dce6e789@sha256:7f727b0896c5e86ff7e214255e2e05dee45689c1793d6e698905b3465a2752e9

tools/dockerfile/distribtest/python_alpine_aarch64/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM python:3.10-alpine3.14
15+
# this an aarch64 image
16+
FROM arm64v8/python:3.13-alpine
1617

1718
# Our test infrastructure demands bash
1819
RUN apk update && apk add bash

tools/internal_ci/linux/arm64/grpc_distribtests_python_arm64.cfg

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Config file for the internal CI (in protobuf text format)
1616

1717
# Location of the continuous shell script in repository.
18-
build_file: "grpc/tools/internal_ci/linux/grpc_distribtests_python_arm64.sh"
18+
build_file: "grpc/tools/internal_ci/linux/grpc_distribtests_python.sh"
1919
timeout_mins: 240
2020
action {
2121
define_artifacts {
@@ -24,3 +24,8 @@ action {
2424
regex: "github/grpc/artifacts/**"
2525
}
2626
}
27+
28+
env_vars {
29+
key: "TASK_RUNNER_EXTRA_FILTERS"
30+
value: "aarch64 musllinux_1_1"
31+
}

tools/internal_ci/linux/grpc_distribtests_python.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ action {
2424
regex: "github/grpc/artifacts/**"
2525
}
2626
}
27+
28+
env_vars {
29+
key: "TASK_RUNNER_EXTRA_FILTERS"
30+
value: "-e aarch64 musllinux_1_1"
31+
}

tools/internal_ci/linux/grpc_distribtests_python.sh

+25-6
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,19 @@ cd $(dirname $0)/../../..
2323

2424
source tools/internal_ci/helper_scripts/prepare_build_linux_rc
2525

26-
# some distribtests use a pre-registered binfmt_misc hook
27-
# to automatically execute foreign binaries (such as aarch64)
28-
# under qemu emulator.
29-
source tools/internal_ci/helper_scripts/prepare_qemu_rc
26+
IS_AARCH64_MUSL=""
27+
if [[ "${TASK_RUNNER_EXTRA_FILTERS}" == "aarch64 musllinux_1_1" || "${TASK_RUNNER_EXTRA_FILTERS}" == "presubmit aarch64 musllinux_1_1" ]]; then
28+
IS_AARCH64_MUSL="True"
29+
fi
30+
31+
if [[ "${IS_AARCH64_MUSL}" == "True" ]]; then
32+
echo "Skipping prepare_qemu_rc'"
33+
else
34+
# some distribtests use a pre-registered binfmt_misc hook
35+
# to automatically execute foreign binaries (such as aarch64)
36+
# under qemu emulator.
37+
source tools/internal_ci/helper_scripts/prepare_qemu_rc
38+
fi
3039

3140
# configure ccache
3241
source tools/internal_ci/helper_scripts/prepare_ccache_rc
@@ -40,7 +49,12 @@ mkdir -p input_artifacts
4049
cp -r artifacts/* input_artifacts/ || true
4150

4251
# This step simply collects python artifacts from subdirectories of input_artifacts/ and copies them to artifacts/
43-
tools/run_tests/task_runner.py -f package linux python -x build_packages/sponge_log.xml || FAILED="true"
52+
if [[ "${IS_AARCH64_MUSL}" == "True" ]]; then
53+
# Not using TASK_RUNNER_EXTRA_FILTERS since we don't have a target with presubmit tag.
54+
tools/run_tests/task_runner.py -f package linux python musllinux_1_1 aarch64 -x build_packages/sponge_log.xml || FAILED="true"
55+
else
56+
tools/run_tests/task_runner.py -f package linux python -x build_packages/sponge_log.xml || FAILED="true"
57+
fi
4458

4559
# the next step expects to find the artifacts from the previous step in the "input_artifacts" folder.
4660
# in addition to that, preserve the contents of "artifacts" directory since we want kokoro
@@ -52,7 +66,12 @@ cp -r artifacts/* input_artifacts/ || true
5266
# Run all python linux distribtests
5367
# We run the distribtests even if some of the artifacts have failed to build, since that gives
5468
# a better signal about which distribtest are affected by the currently broken artifact builds.
55-
tools/run_tests/task_runner.py -f distribtest linux python ${TASK_RUNNER_EXTRA_FILTERS} -j 12 -x distribtests/sponge_log.xml || FAILED="true"
69+
if [[ "${IS_AARCH64_MUSL}" == "True" ]]; then
70+
# We're using alpine as tag in distribtest targets.
71+
tools/run_tests/task_runner.py -f distribtest linux python aarch64 alpine -j 12 -x distribtests/sponge_log.xml || FAILED="true"
72+
else
73+
tools/run_tests/task_runner.py -f distribtest linux python ${TASK_RUNNER_EXTRA_FILTERS} -j 12 -x distribtests/sponge_log.xml || FAILED="true"
74+
fi
5675

5776
# This step checks if any of the artifacts exceeds a per-file size limit.
5877
tools/internal_ci/helper_scripts/check_python_artifacts_size.sh

tools/internal_ci/linux/pull_request/grpc_distribtests_python.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ action {
2727

2828
env_vars {
2929
key: "TASK_RUNNER_EXTRA_FILTERS"
30-
value: "presubmit"
30+
value: "presubmit -e aarch64 musllinux_1_1"
3131
}

tools/internal_ci/linux/pull_request/grpc_distribtests_python_arm64.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Config file for the internal CI (in protobuf text format)
1616

1717
# Location of the continuous shell script in repository.
18-
build_file: "grpc/tools/internal_ci/linux/grpc_distribtests_python_arm64.sh"
18+
build_file: "grpc/tools/internal_ci/linux/grpc_distribtests_python.sh"
1919
timeout_mins: 240
2020
action {
2121
define_artifacts {
@@ -27,5 +27,5 @@ action {
2727

2828
env_vars {
2929
key: "TASK_RUNNER_EXTRA_FILTERS"
30-
value: "presubmit"
30+
value: "presubmit aarch64 musllinux_1_1"
3131
}

tools/internal_ci/linux/pull_request/grpc_examples_tests_cpp.cfg

+10
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@ action {
2323
regex: "github/grpc/reports/**"
2424
}
2525
}
26+
27+
env_vars {
28+
key: "TASK_RUNNER_EXTRA_FILTERS"
29+
value: "aarch64 -e x64 x86 armv7"
30+
}
31+
32+
# env_vars {
33+
# key: "TASK_RUNNER_EXCLUDE_FILTERS"
34+
# value: "x64 x86 armv7"
35+
# }

tools/internal_ci/linux/release/grpc_distribtests_python.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ action {
2424
regex: "github/grpc/artifacts/**"
2525
}
2626
}
27+
28+
env_vars {
29+
key: "TASK_RUNNER_EXTRA_FILTERS"
30+
value: "-e aarch64 musllinux_1_1"
31+
}

tools/run_tests/artifacts/artifact_targets.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def build_jobspec(self, inner_jobs=None):
200200
)
201201
environ["PIP"] = "/opt/python/{}/bin/pip".format(self.py_version)
202202
environ["GRPC_SKIP_PIP_CYTHON_UPGRADE"] = "TRUE"
203+
environ["GRPC_PYTHON_BUILD_WITH_STATIC_LIBSTDCXX"] = "TRUE"
203204

204205
if self.arch in ("x86", "aarch64"):
205206
environ["GRPC_SKIP_TWINE_CHECK"] = "TRUE"
@@ -208,9 +209,10 @@ def build_jobspec(self, inner_jobs=None):
208209
# As we won't strip the binary with auditwheel (see below), strip
209210
# it at link time.
210211
environ["LDFLAGS"] = "-s"
212+
# We're using musllinux aarch64 image to build this artifact so no crosscompiling required.
213+
environ["GRPC_BUILD_GRPCIO_TOOLS_DEPENDENTS"] = "TRUE"
211214
else:
212215
environ["GRPC_RUN_AUDITWHEEL_REPAIR"] = "TRUE"
213-
environ["GRPC_PYTHON_BUILD_WITH_STATIC_LIBSTDCXX"] = "TRUE"
214216

215217
return create_docker_jobspec(
216218
self.name,

tools/run_tests/artifacts/package_targets.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,18 @@ def build_jobspec(self, inner_jobs=None):
142142
class PythonPackage:
143143
"""Collects python eggs and wheels created in the artifact phase"""
144144

145-
def __init__(self):
145+
def __init__(self, platform="", arch=""):
146146
self.name = "python_package"
147147
self.labels = ["package", "python", "linux"]
148+
self.platform = platform
149+
self.arch = arch
150+
if self.platform:
151+
self.labels.append(platform)
152+
self.name += "_" + platform
153+
if self.arch:
154+
self.labels.append(arch)
155+
self.name += "_" + arch
156+
148157

149158
def pre_build_jobspecs(self):
150159
return []
@@ -154,9 +163,12 @@ def build_jobspec(self, inner_jobs=None):
154163
# since the python package build does very little, we can use virtually
155164
# any image that has new-enough python, so reusing one of the images used
156165
# for artifact building seems natural.
166+
dockerfile_dir = "tools/dockerfile/grpc_artifact_python_manylinux2014_x64"
167+
if "musllinux_1_1" in self.platform and "aarch64" in self.arch:
168+
dockerfile_dir = "tools/dockerfile/grpc_artifact_python_musllinux_1_1_aarch64"
157169
return create_docker_jobspec(
158170
self.name,
159-
"tools/dockerfile/grpc_artifact_python_manylinux2014_x64",
171+
dockerfile_dir,
160172
"tools/run_tests/artifacts/build_package_python.sh",
161173
environ={"PYTHON": "/opt/python/cp39-cp39/bin/python"},
162174
)
@@ -189,5 +201,6 @@ def targets():
189201
CSharpPackage("windows"),
190202
RubyPackage(),
191203
PythonPackage(),
204+
PythonPackage("musllinux_1_1", "aarch64"),
192205
PHPPackage(),
193206
]

tools/run_tests/task_runner.py

+11
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ def _create_build_map():
7171
default=[],
7272
help="Filter targets to build with AND semantics.",
7373
)
74+
argp.add_argument(
75+
"-e",
76+
"--exclude",
77+
choices=sorted(_BUILD_MAP.keys()),
78+
nargs="+",
79+
default=[],
80+
help="Target labels to exclude from building.",
81+
)
7482
argp.add_argument("-j", "--jobs", default=multiprocessing.cpu_count(), type=int)
7583
argp.add_argument(
7684
"-x",
@@ -106,6 +114,9 @@ def _create_build_map():
106114
# Among targets selected by -b, filter out those that don't match the filter
107115
targets = [t for t in targets if all(f in t.labels for f in args.filter)]
108116

117+
# Exclude target if it has ALL of the specified exclude labels.
118+
targets = [t for t in targets if not all(l in args.exclude for l in t.labels)]
119+
109120
print("Will build %d targets:" % len(targets))
110121
for target in targets:
111122
print(" %s, labels %s" % (target.name, target.labels))

0 commit comments

Comments
 (0)