Commit 9243b07f authored by Carlos Natalino's avatar Carlos Natalino
Browse files

Upgrade Pluggables to Python 3.13 to match Device.

Pluggables compiles src/device/requirements.in into a Python 3.9 image, so the Device 3.13 pins (numpy 2.3, protobuf 6) cannot resolve there. Use python:3.13-slim, common_requirements_py313.in, and the same p4runtime stub regen as Device.
parent e70d0bc5
Loading
Loading
Loading
Loading
+31 −6
Changes for src/pluggables/Dockerfile: 31 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM python:3.9-slim
FROM python:3.13-slim

# Install dependencies
RUN apt-get --yes --quiet --quiet update && \
@@ -38,9 +38,9 @@ RUN ldconfig
ENV PYTHONUNBUFFERED=0

# Download the gRPC health probe
RUN GRPC_HEALTH_PROBE_VERSION=v0.2.0 && \
    wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
    chmod +x /bin/grpc_health_probe
# RUN GRPC_HEALTH_PROBE_VERSION=v0.4.40 && \
#     wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
#     chmod +x /bin/grpc_health_probe

# Get generic Python packages
RUN python3 -m pip install --upgrade 'pip==25.2'
@@ -50,7 +50,7 @@ RUN python3 -m pip install --upgrade 'pip-tools==7.3.0'
# Get common Python packages
# Note: this step enables sharing the previous Docker build steps among all the Python components
WORKDIR /var/teraflow
COPY common_requirements.in common_requirements.in
COPY common_requirements_py313.in common_requirements.in
RUN pip-compile --quiet --output-file=common_requirements.txt common_requirements.in
RUN python3 -m pip install -r common_requirements.txt

@@ -73,9 +73,34 @@ RUN mkdir -p /var/teraflow/pluggables
WORKDIR /var/teraflow/pluggables
COPY src/device/requirements.in requirements_device.in
COPY src/pluggables/requirements.in requirements_pluggables.in
RUN pip-compile --quiet --output-file=requirements.txt requirements_device.in requirements_pluggables.in
RUN pip-compile --quiet --output-file=requirements.txt requirements_device.in requirements_pluggables.in /var/teraflow/common_requirements.in
RUN python3 -m pip install -r requirements.txt

# p4runtime 1.3.0 ships stubs generated with an old protoc that cannot be
# imported under protobuf 6. Rebuild them with this image's grpc_tools.
RUN git clone --depth 1 --branch v1.3.0 https://github.com/p4lang/p4runtime.git /tmp/p4runtime
RUN python3 - <<'PY'
from pathlib import Path
import sys
import grpc_tools
import p4
from grpc_tools import protoc
site = Path(p4.__file__).resolve().parent.parent
inc = Path(grpc_tools.__file__).resolve().parent / "_proto"
proto = Path("/tmp/p4runtime/proto")
files = [str(p) for p in proto.rglob("*.proto")]
sys.exit(protoc.main([
    "protoc",
    f"-I{proto}",
    f"-I{inc}",
    f"-I{site}",
    f"--python_out={site}",
    f"--grpc_python_out={site}",
    *files,
]))
PY
RUN rm -rf /tmp/p4runtime

# Add component files into working directory
WORKDIR /var/teraflow
COPY src/context/__init__.py context/__init__.py