Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 78 additions & 6 deletions .buildkite/build.rayci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,95 @@ steps:
HOSTTYPE: "x86_64"
MANYLINUX_VERSION: "260103.868e54c"

- label: ":tapioca: build: wheel {{matrix}} (x86_64)"
key: linux_wheels
- name: ray-wheel-build
label: "wanda: wheel py{{matrix}} (x86_64)"
wanda: ci/docker/ray-wheel.wanda.yaml
matrix:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
env:
PYTHON_VERSION: "{{matrix}}"
ARCH_SUFFIX: ""
HOSTTYPE: "x86_64"
MANYLINUX_VERSION: "260103.868e54c"
tags:
- release_wheels
- linux_wheels
- oss
instance_type: large
depends_on:
- ray-core-build
- ray-java-build
- ray-dashboard-build

# Upload wheels to S3
- label: ":s3: upload: wheel py{{matrix}} (x86_64)"
key: linux_wheels_upload
instance_type: small
commands:
- bazel run //ci/ray_ci:build_in_docker -- wheel --python-version {{matrix}} --architecture x86_64 --upload
- ./ci/build/extract_wanda_wheels.sh ray-wheel-py{{matrix}}
- ./ci/build/copy_build_artifacts.sh wheel
matrix:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
depends_on:
- manylinux-x86_64
- forge
- ray-wheel-build
tags:
- release_wheels
- skip-on-premerge
- oss

- name: ray-cpp-core-build
label: "wanda: cpp core py{{matrix}} (x86_64)"
wanda: ci/docker/ray-cpp-core.wanda.yaml
matrix:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
env:
PYTHON_VERSION: "{{matrix}}"
ARCH_SUFFIX: ""
HOSTTYPE: "x86_64"
MANYLINUX_VERSION: "260103.868e54c"
tags:
- release_wheels
- oss

- name: ray-cpp-wheel-build
label: "wanda: cpp wheel (x86_64)"
wanda: ci/docker/ray-cpp-wheel.wanda.yaml
env:
PYTHON_VERSION: "3.10" # Used for upstream images; wheel is Python-agnostic
ARCH_SUFFIX: ""
HOSTTYPE: "x86_64"
MANYLINUX_VERSION: "260103.868e54c"
tags:
- release_wheels
- linux_wheels
- oss
depends_on:
- ray-core-build
- ray-cpp-core-build
- ray-java-build
- ray-dashboard-build

# Upload cpp wheel to S3
- label: ":s3: upload: cpp wheel (x86_64)"
key: linux_cpp_wheels_upload
instance_type: small
commands:
- ./ci/build/extract_wanda_wheels.sh ray-cpp-wheel
- ./ci/build/copy_build_artifacts.sh wheel
depends_on:
- ray-cpp-wheel-build
tags:
- release_wheels
- skip-on-premerge
- oss

- label: ":tapioca: build: jar"
key: java_wheels
Expand Down
2 changes: 1 addition & 1 deletion .rayciversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.21.0
0.22.0
54 changes: 54 additions & 0 deletions ci/build/build-cpp-wheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
# Build Python-agnostic ray-cpp wheel.
#
# The ray-cpp wheel contains only C++ headers, libraries, and executables
# with no Python version-specific content. This script builds a single wheel
# tagged py3-none-manylinux2014_* that works with any Python 3 version.
#
# Usage: ./ci/build/build-cpp-wheel.sh
#
# Environment variables:
# BUILDKITE_COMMIT - Git commit SHA for ray.__commit__ (required)

set -exuo pipefail

TRAVIS_COMMIT="${TRAVIS_COMMIT:-$BUILDKITE_COMMIT}"

# Use any Python 3 to run setuptools (wheel content is Python-agnostic)
PYTHON="cp310-cp310"

mkdir -p .whl
cd python

/opt/python/"${PYTHON}"/bin/pip install -q cython==3.0.12 setuptools==80.9.0

# Set the commit SHA in _version.py
if [[ -n "$TRAVIS_COMMIT" ]]; then
sed -i.bak "s/{{RAY_COMMIT_SHA}}/$TRAVIS_COMMIT/g" ray/_version.py && rm ray/_version.py.bak
else
echo "TRAVIS_COMMIT variable not set - required to populate ray.__commit__."
exit 1
fi

# Determine platform tag based on architecture
ARCH=$(uname -m)
if [[ "$ARCH" == "x86_64" ]]; then
PLAT_NAME="manylinux2014_x86_64"
elif [[ "$ARCH" == "aarch64" ]]; then
PLAT_NAME="manylinux2014_aarch64"
else
echo "ERROR: Unsupported architecture: $ARCH"
exit 1
fi

echo "Building ray-cpp wheel (Python-agnostic, platform: $PLAT_NAME)..."

# Build wheel with py3-none tag (Python version-agnostic)
# SKIP_BAZEL_BUILD=1 because artifacts are pre-built from wanda cache
PATH="/opt/python/${PYTHON}/bin:$PATH" \
SKIP_BAZEL_BUILD=1 RAY_INSTALL_JAVA=0 RAY_INSTALL_CPP=1 \
"/opt/python/${PYTHON}/bin/python" setup.py bdist_wheel \
--python-tag py3 \
--plat-name "$PLAT_NAME"

mv dist/*.whl ../.whl/
25 changes: 18 additions & 7 deletions ci/build/build-manylinux-wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ set -exuo pipefail
PYTHON="$1"
TRAVIS_COMMIT="${TRAVIS_COMMIT:-$BUILDKITE_COMMIT}"

# WHEEL_TYPE=cpp can be set to build only the ray-cpp wheel (skips ray wheel).
# Otherwise, the original default behavior is preserved for backwards compatibility:
# - Always build ray wheel
# - Also build ray-cpp wheel unless RAY_DISABLE_EXTRA_CPP=1

export RAY_BUILD_ENV="manylinux_py${PYTHON}"

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

# build ray wheel
PATH="/opt/python/${PYTHON}/bin:$PATH" RAY_INSTALL_JAVA=0 \
"/opt/python/${PYTHON}/bin/python" -m pip wheel -v -w dist . --no-deps


if [[ "${RAY_DISABLE_EXTRA_CPP:-}" != 1 ]]; then
# build ray-cpp wheel
# Build wheel(s)
if [[ "${WHEEL_TYPE:-}" == "cpp" ]]; then
# cpp-only mode: build only ray-cpp wheel
echo "Building ray-cpp wheel..."
PATH="/opt/python/${PYTHON}/bin:$PATH" RAY_INSTALL_JAVA=0 \
RAY_INSTALL_CPP=1 "/opt/python/${PYTHON}/bin/python" -m pip wheel -v -w dist . --no-deps
else
# Default mode: build ray wheel, then cpp wheel unless disabled
PATH="/opt/python/${PYTHON}/bin:$PATH" RAY_INSTALL_JAVA=0 \
"/opt/python/${PYTHON}/bin/python" -m pip wheel -v -w dist . --no-deps

if [[ "${RAY_DISABLE_EXTRA_CPP:-}" != 1 ]]; then
PATH="/opt/python/${PYTHON}/bin:$PATH" RAY_INSTALL_JAVA=0 \
RAY_INSTALL_CPP=1 "/opt/python/${PYTHON}/bin/python" -m pip wheel -v -w dist . --no-deps
fi
fi

# Rename the wheels so that they can be uploaded to PyPI. TODO(rkn): This is a
Expand Down
49 changes: 49 additions & 0 deletions ci/build/extract_wanda_wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

set -exuo pipefail

# Extract wheels from a Wanda-cached image.
#
# Usage: ./ci/build/extract_wanda_wheels.sh <wanda_image_name>
#
# Example:
# ./ci/build/extract_wanda_wheels.sh ray-wheel-py3.10
#
# The script will:
# 1. Export the wanda image using crane
# 2. Extract .whl files from the tarball
# 3. Move them to .whl/ directory (clears existing wheels first)

WANDA_IMAGE_NAME=${1:?Usage: $0 <wanda_image_name>}

# Construct full image tag from environment
WANDA_IMAGE="${RAYCI_WORK_REPO}:${RAYCI_BUILD_ID}-${WANDA_IMAGE_NAME}"

echo "Extracting wheels from: ${WANDA_IMAGE}"

tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir" || true' EXIT

# Export image and extract to temp dir
crane export "${WANDA_IMAGE}" - | tar -xf - -C "$tmpdir"

# Clear existing wheels to avoid stale files from previous runs
rm -rf .whl
mkdir -p .whl

# Move extracted wheels to .whl/
find "${tmpdir}" -type f -name '*.whl' -exec mv {} .whl/ \;

# Verify that wheels were actually extracted
shopt -s nullglob
wheels=(.whl/*.whl)
shopt -u nullglob

if (( ${#wheels[@]} == 0 )); then
echo "ERROR: No wheel files were extracted from image: ${WANDA_IMAGE}" >&2
echo "This may indicate image corruption, incorrect image tag, or path issues." >&2
exit 1
fi

echo "Extracted ${#wheels[@]} wheel(s):"
ls -la .whl/
48 changes: 48 additions & 0 deletions ci/docker/ray-cpp-core.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# syntax=docker/dockerfile:1.3-labs
#
# Ray C++ Core Artifacts Builder
# ==============================
# Builds ray_cpp_pkg.zip containing C++ headers, libraries, and examples.
#
ARG ARCH_SUFFIX=
ARG HOSTTYPE=x86_64
ARG MANYLINUX_VERSION
FROM rayproject/manylinux2014:${MANYLINUX_VERSION}-jdk-${HOSTTYPE} AS builder

ARG PYTHON_VERSION=3.10
ARG BUILDKITE_BAZEL_CACHE_URL
ARG BUILDKITE_CACHE_READONLY
ARG HOSTTYPE

WORKDIR /home/forge/ray

COPY . .

# Mounting cache dir for faster local rebuilds (architecture-specific to avoid toolchain conflicts)
RUN --mount=type=cache,target=/home/forge/.cache,uid=2000,gid=100,id=bazel-cache-${HOSTTYPE}-${PYTHON_VERSION} \
<<'EOF'
#!/bin/bash
set -euo pipefail

PY_CODE="${PYTHON_VERSION//./}"
PY_BIN="cp${PY_CODE}-cp${PY_CODE}"
export RAY_BUILD_ENV="manylinux_py${PY_BIN}"

sudo ln -sf "/opt/python/${PY_BIN}/bin/python3" /usr/local/bin/python3
sudo ln -sf /usr/local/bin/python3 /usr/local/bin/python

if [[ "${BUILDKITE_CACHE_READONLY:-}" == "true" ]]; then
echo "build --remote_upload_local_results=false" >> "$HOME/.bazelrc"
fi

echo "build --repository_cache=/home/forge/.cache/bazel-repo" >> "$HOME/.bazelrc"

bazelisk build --config=ci //cpp:ray_cpp_pkg_zip

cp bazel-bin/cpp/ray_cpp_pkg.zip /home/forge/ray_cpp_pkg.zip

EOF

FROM scratch

COPY --from=builder /home/forge/ray_cpp_pkg.zip /
30 changes: 30 additions & 0 deletions ci/docker/ray-cpp-core.wanda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "ray-cpp-core-py$PYTHON_VERSION$ARCH_SUFFIX"
froms: ["rayproject/manylinux2014:$MANYLINUX_VERSION-jdk-$HOSTTYPE"]
dockerfile: ci/docker/ray-cpp-core.Dockerfile
srcs:
- .bazelversion
- .bazelrc
- WORKSPACE
- BUILD.bazel
- bazel/
- thirdparty/
- src/
- cpp/
- python/ray/__init__.py
- python/ray/_raylet.pxd
- python/ray/_raylet.pyi
- python/ray/_raylet.pyx
- python/ray/includes/
- java/BUILD.bazel
- java/dependencies.bzl
- release/BUILD.bazel
- release/requirements.txt
- release/requirements_py310.txt
build_args:
- PYTHON_VERSION
- ARCH_SUFFIX
- HOSTTYPE
- MANYLINUX_VERSION
- BUILDKITE_BAZEL_CACHE_URL
build_hint_args:
- BUILDKITE_CACHE_READONLY
Loading