Skip to content

Commit 6801f72

Browse files
Add wanda cpp wheel builds (x86_64)
This adds wanda-based builds for ray C++ API wheels for x86_64. Changes: - Add ray-cpp-core.wanda.yaml and Dockerfile for cpp core - Add ray-cpp-wheel.wanda.yaml for cpp wheel builds - Update build.rayci.yml with cpp wheel build and upload steps Topic: ray-cpp-wheel Relative: ray-wheel Signed-off-by: andrew <andrew@anyscale.com>
1 parent 05785cb commit 6801f72

File tree

6 files changed

+273
-7
lines changed

6 files changed

+273
-7
lines changed

.buildkite/build.rayci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,65 @@ steps:
7676
- skip-on-premerge
7777
- oss
7878

79+
- name: ray-cpp-core-build
80+
label: "wanda: cpp core py{{matrix}} (x86_64)"
81+
wanda: ci/docker/ray-cpp-core.wanda.yaml
82+
matrix:
83+
- "3.10"
84+
- "3.11"
85+
- "3.12"
86+
- "3.13"
87+
env:
88+
PYTHON_VERSION: "{{matrix}}"
89+
ARCH_SUFFIX: ""
90+
HOSTTYPE: "x86_64"
91+
MANYLINUX_VERSION: "260103.868e54c"
92+
tags:
93+
- release_wheels
94+
- oss
95+
96+
- name: ray-cpp-wheel-build
97+
label: "wanda: cpp wheel py{{matrix}} (x86_64)"
98+
wanda: ci/docker/ray-cpp-wheel.wanda.yaml
99+
matrix:
100+
- "3.10"
101+
- "3.11"
102+
- "3.12"
103+
- "3.13"
104+
env:
105+
PYTHON_VERSION: "{{matrix}}"
106+
ARCH_SUFFIX: ""
107+
HOSTTYPE: "x86_64"
108+
MANYLINUX_VERSION: "260103.868e54c"
109+
tags:
110+
- release_wheels
111+
- linux_wheels
112+
- oss
113+
depends_on:
114+
- ray-core-build
115+
- ray-cpp-core-build
116+
- ray-java-build
117+
- ray-dashboard-build
118+
119+
# Upload cpp wheels to S3
120+
- label: ":s3: upload: cpp wheel py{{matrix}} (x86_64)"
121+
key: linux_cpp_wheels_upload
122+
instance_type: small
123+
commands:
124+
- ./ci/build/extract_wanda_wheels.sh ray-cpp-wheel-py{{matrix}}
125+
- ./ci/build/copy_build_artifacts.sh wheel
126+
matrix:
127+
- "3.10"
128+
- "3.11"
129+
- "3.12"
130+
- "3.13"
131+
depends_on:
132+
- ray-cpp-wheel-build
133+
tags:
134+
- release_wheels
135+
- skip-on-premerge
136+
- oss
137+
79138
- label: ":tapioca: build: jar"
80139
key: java_wheels
81140
tags:

ci/build/build-manylinux-wheel.sh

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ set -exuo pipefail
44
PYTHON="$1"
55
TRAVIS_COMMIT="${TRAVIS_COMMIT:-$BUILDKITE_COMMIT}"
66

7+
# WHEEL_TYPE=cpp can be set to build only the ray-cpp wheel (skips ray wheel).
8+
# Otherwise, the original default behavior is preserved for backwards compatibility:
9+
# - Always build ray wheel
10+
# - Also build ray-cpp wheel unless RAY_DISABLE_EXTRA_CPP=1
11+
712
export RAY_BUILD_ENV="manylinux_py${PYTHON}"
813

914
mkdir -p .whl
@@ -26,15 +31,21 @@ export BAZEL_PATH="$HOME"/bin/bazel
2631
# This is required for building with bazel.
2732
sudo ln -sf "/opt/python/${PYTHON}/bin/python3" /usr/local/bin/python3
2833

29-
# build ray wheel
30-
PATH="/opt/python/${PYTHON}/bin:$PATH" RAY_INSTALL_JAVA=0 \
31-
"/opt/python/${PYTHON}/bin/python" -m pip wheel -v -w dist . --no-deps
32-
33-
34-
if [[ "${RAY_DISABLE_EXTRA_CPP:-}" != 1 ]]; then
35-
# build ray-cpp wheel
34+
# Build wheel(s)
35+
if [[ "${WHEEL_TYPE:-}" == "cpp" ]]; then
36+
# cpp-only mode: build only ray-cpp wheel
37+
echo "Building ray-cpp wheel..."
3638
PATH="/opt/python/${PYTHON}/bin:$PATH" RAY_INSTALL_JAVA=0 \
3739
RAY_INSTALL_CPP=1 "/opt/python/${PYTHON}/bin/python" -m pip wheel -v -w dist . --no-deps
40+
else
41+
# Default mode: build ray wheel, then cpp wheel unless disabled
42+
PATH="/opt/python/${PYTHON}/bin:$PATH" RAY_INSTALL_JAVA=0 \
43+
"/opt/python/${PYTHON}/bin/python" -m pip wheel -v -w dist . --no-deps
44+
45+
if [[ "${RAY_DISABLE_EXTRA_CPP:-}" != 1 ]]; then
46+
PATH="/opt/python/${PYTHON}/bin:$PATH" RAY_INSTALL_JAVA=0 \
47+
RAY_INSTALL_CPP=1 "/opt/python/${PYTHON}/bin/python" -m pip wheel -v -w dist . --no-deps
48+
fi
3849
fi
3950

4051
# Rename the wheels so that they can be uploaded to PyPI. TODO(rkn): This is a

ci/docker/ray-cpp-core.Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# syntax=docker/dockerfile:1.3-labs
2+
#
3+
# Ray C++ Core Artifacts Builder
4+
# ==============================
5+
# Builds ray_cpp_pkg.zip containing C++ headers, libraries, and examples.
6+
#
7+
ARG ARCH_SUFFIX=
8+
ARG HOSTTYPE=x86_64
9+
ARG MANYLINUX_VERSION
10+
FROM rayproject/manylinux2014:${MANYLINUX_VERSION}-jdk-${HOSTTYPE} AS builder
11+
12+
ARG PYTHON_VERSION=3.10
13+
ARG BUILDKITE_BAZEL_CACHE_URL
14+
ARG BUILDKITE_CACHE_READONLY
15+
ARG HOSTTYPE
16+
17+
WORKDIR /home/forge/ray
18+
19+
COPY . .
20+
21+
# Mounting cache dir for faster local rebuilds (architecture-specific to avoid toolchain conflicts)
22+
RUN --mount=type=cache,target=/home/forge/.cache,uid=2000,gid=100,id=bazel-cache-${HOSTTYPE}-${PYTHON_VERSION} \
23+
<<'EOF'
24+
#!/bin/bash
25+
set -euo pipefail
26+
27+
PY_CODE="${PYTHON_VERSION//./}"
28+
PY_BIN="cp${PY_CODE}-cp${PY_CODE}"
29+
export RAY_BUILD_ENV="manylinux_py${PY_BIN}"
30+
31+
sudo ln -sf "/opt/python/${PY_BIN}/bin/python3" /usr/local/bin/python3
32+
sudo ln -sf /usr/local/bin/python3 /usr/local/bin/python
33+
34+
if [[ "${BUILDKITE_CACHE_READONLY:-}" == "true" ]]; then
35+
echo "build --remote_upload_local_results=false" >> "$HOME/.bazelrc"
36+
fi
37+
38+
echo "build --repository_cache=/home/forge/.cache/bazel-repo" >> "$HOME/.bazelrc"
39+
40+
bazelisk build --config=ci //cpp:ray_cpp_pkg_zip
41+
42+
cp bazel-bin/cpp/ray_cpp_pkg.zip /home/forge/ray_cpp_pkg.zip
43+
44+
EOF
45+
46+
FROM scratch
47+
48+
COPY --from=builder /home/forge/ray_cpp_pkg.zip /

ci/docker/ray-cpp-core.wanda.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: "ray-cpp-core-py$PYTHON_VERSION$ARCH_SUFFIX"
2+
froms: ["rayproject/manylinux2014:$MANYLINUX_VERSION-jdk-$HOSTTYPE"]
3+
dockerfile: ci/docker/ray-cpp-core.Dockerfile
4+
srcs:
5+
- .bazelversion
6+
- .bazelrc
7+
- WORKSPACE
8+
- BUILD.bazel
9+
- bazel/
10+
- thirdparty/
11+
- src/
12+
- cpp/
13+
- python/ray/__init__.py
14+
- python/ray/_raylet.pxd
15+
- python/ray/_raylet.pyi
16+
- python/ray/_raylet.pyx
17+
- python/ray/includes/
18+
- java/BUILD.bazel
19+
- java/dependencies.bzl
20+
- release/BUILD.bazel
21+
- release/requirements.txt
22+
- release/requirements_py310.txt
23+
build_args:
24+
- PYTHON_VERSION
25+
- ARCH_SUFFIX
26+
- HOSTTYPE
27+
- MANYLINUX_VERSION
28+
- BUILDKITE_BAZEL_CACHE_URL
29+
build_hint_args:
30+
- BUILDKITE_CACHE_READONLY

ci/docker/ray-cpp-wheel.Dockerfile

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# syntax=docker/dockerfile:1.3-labs
2+
#
3+
# Ray C++ Wheel Builder
4+
# =====================
5+
# Builds manylinux2014-compatible ray-cpp wheel using pre-built C++ artifacts from wanda cache.
6+
#
7+
# This is a minimal Dockerfile for ray-cpp wheel builds only.
8+
# It copies only the files needed for the cpp wheel, reducing build context size.
9+
10+
ARG RAY_CORE_IMAGE
11+
ARG RAY_CPP_CORE_IMAGE
12+
ARG RAY_JAVA_IMAGE
13+
ARG RAY_DASHBOARD_IMAGE
14+
ARG MANYLINUX_VERSION
15+
ARG HOSTTYPE
16+
17+
FROM ${RAY_CORE_IMAGE} AS ray-core
18+
FROM ${RAY_CPP_CORE_IMAGE} AS ray-cpp-core
19+
FROM ${RAY_JAVA_IMAGE} AS ray-java
20+
FROM ${RAY_DASHBOARD_IMAGE} AS ray-dashboard
21+
22+
# Main build stage - manylinux2014 provides GLIBC 2.17
23+
FROM rayproject/manylinux2014:${MANYLINUX_VERSION}-jdk-${HOSTTYPE} AS builder
24+
25+
ARG PYTHON_VERSION=3.10
26+
ARG BUILDKITE_COMMIT
27+
28+
WORKDIR /home/forge/ray
29+
30+
# Copy artifacts from all stages
31+
COPY --from=ray-core /ray_pkg.zip /tmp/
32+
COPY --from=ray-core /ray_py_proto.zip /tmp/
33+
COPY --from=ray-java /ray_java_pkg.zip /tmp/
34+
COPY --from=ray-dashboard /dashboard.tar.gz /tmp/
35+
36+
# Minimal source files needed for cpp wheel build
37+
COPY --chown=forge ci/build/build-manylinux-wheel.sh ci/build/
38+
COPY --chown=forge README.rst pyproject.toml ./
39+
COPY --chown=forge python/setup.py python/
40+
COPY --chown=forge python/LICENSE.txt python/
41+
COPY --chown=forge python/MANIFEST.in python/
42+
COPY --chown=forge python/ray/_version.py python/ray/
43+
44+
USER forge
45+
# - BUILDKITE_COMMIT: Used for ray.__commit__. Defaults to "unknown" for local builds.
46+
ENV PYTHON_VERSION=${PYTHON_VERSION} \
47+
BUILDKITE_COMMIT=${BUILDKITE_COMMIT:-unknown}
48+
RUN --mount=from=ray-cpp-core,source=/,target=/ray-cpp-core,ro \
49+
<<'EOF'
50+
#!/bin/bash
51+
set -euo pipefail
52+
53+
# Clean extraction dirs to avoid stale leftovers
54+
rm -rf /tmp/ray_pkg /tmp/ray_java_pkg /tmp/ray_cpp_pkg
55+
mkdir -p /tmp/ray_pkg /tmp/ray_java_pkg /tmp/ray_cpp_pkg
56+
57+
# Unpack pre-built artifacts
58+
unzip -o /tmp/ray_pkg.zip -d /tmp/ray_pkg
59+
unzip -o /tmp/ray_py_proto.zip -d python/
60+
unzip -o /tmp/ray_java_pkg.zip -d /tmp/ray_java_pkg
61+
mkdir -p python/ray/dashboard/client/build
62+
tar -xzf /tmp/dashboard.tar.gz -C python/ray/dashboard/client/build/
63+
64+
# C++ core artifacts
65+
cp -r /tmp/ray_pkg/ray/* python/ray/
66+
67+
# Java JARs
68+
cp -r /tmp/ray_java_pkg/ray/* python/ray/
69+
70+
# C++ API artifacts (headers, libs, examples)
71+
unzip -o /ray-cpp-core/ray_cpp_pkg.zip -d /tmp/ray_cpp_pkg
72+
cp -r /tmp/ray_cpp_pkg/ray/cpp python/ray/
73+
74+
# Build cpp wheel
75+
PY_VERSION="${PYTHON_VERSION//./}"
76+
PY_BIN="cp${PY_VERSION}-cp${PY_VERSION}"
77+
SKIP_BAZEL_BUILD=1 WHEEL_TYPE=cpp \
78+
./ci/build/build-manylinux-wheel.sh "$PY_BIN"
79+
80+
# Sanity check: ensure wheels exist
81+
shopt -s nullglob
82+
wheels=(.whl/*.whl)
83+
if (( ${#wheels[@]} == 0 )); then
84+
echo "ERROR: No wheels produced in .whl/"
85+
ls -la .whl || true
86+
exit 1
87+
fi
88+
89+
EOF
90+
91+
FROM scratch
92+
COPY --from=builder /home/forge/ray/.whl/*.whl /

ci/docker/ray-cpp-wheel.wanda.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "ray-cpp-wheel-py$PYTHON_VERSION$ARCH_SUFFIX"
2+
froms:
3+
- "rayproject/manylinux2014:$MANYLINUX_VERSION-jdk-$HOSTTYPE"
4+
- "cr.ray.io/rayproject/ray-core-py$PYTHON_VERSION$ARCH_SUFFIX" # C++ binaries (ray_pkg.zip)
5+
- "cr.ray.io/rayproject/ray-cpp-core-py$PYTHON_VERSION$ARCH_SUFFIX" # C++ headers/libs (ray_cpp_pkg.zip)
6+
- "cr.ray.io/rayproject/ray-java-build$ARCH_SUFFIX" # Java JARs
7+
- "cr.ray.io/rayproject/ray-dashboard" # Dashboard
8+
dockerfile: ci/docker/ray-cpp-wheel.Dockerfile
9+
srcs:
10+
- pyproject.toml
11+
- README.rst
12+
- ci/build/build-manylinux-wheel.sh
13+
- python/setup.py
14+
- python/LICENSE.txt
15+
- python/MANIFEST.in
16+
- python/ray/_version.py
17+
build_args:
18+
- PYTHON_VERSION
19+
- MANYLINUX_VERSION
20+
- HOSTTYPE
21+
- BUILDKITE_COMMIT
22+
- ARCH_SUFFIX
23+
- RAY_CORE_IMAGE=cr.ray.io/rayproject/ray-core-py$PYTHON_VERSION$ARCH_SUFFIX
24+
- RAY_CPP_CORE_IMAGE=cr.ray.io/rayproject/ray-cpp-core-py$PYTHON_VERSION$ARCH_SUFFIX
25+
- RAY_JAVA_IMAGE=cr.ray.io/rayproject/ray-java-build$ARCH_SUFFIX
26+
- RAY_DASHBOARD_IMAGE=cr.ray.io/rayproject/ray-dashboard

0 commit comments

Comments
 (0)