4040# cpu-base #
4141####################
4242FROM ${BASE_IMAGE} AS cpu-base
43+ USER 0
44+ RUN /bin/bash <<'EOF'
45+ set -Eeuxo pipefail
46+ if command -v subscription-manager &> /dev/null; then
47+ subscription-manager identity &>/dev/null && subscription-manager refresh || echo "Not registered, skipping refresh."
48+ fi
49+ EOF
4350
4451WORKDIR /opt/app-root/bin
4552
@@ -144,7 +151,13 @@ RUN --mount=type=cache,target=/root/.cache/pip \
144151set -Eeuxo pipefail
145152if [ "$TARGETARCH" = "ppc64le" ] || [ "$TARGETARCH" = "s390x" ]; then
146153 # Install build dependencies (shared for pyarrow and onnx)
147- dnf install -y cmake make gcc-c++ pybind11-devel wget
154+ packages=(
155+ cmake make gcc-c++ pybind11-devel wget
156+ # pyarrow -DARROW_S3=ON pulls in AWS C++ SDK
157+ # libcurl-devel is required to build AWS C++ SDK
158+ libcurl-devel openssl-devel
159+ )
160+ dnf install -y "${packages[@]}"
148161 dnf clean all
149162 # Build and collect pyarrow wheel
150163 git clone --depth 1 --branch "apache-arrow-17.0.0" https://github.com/apache/arrow.git
@@ -173,7 +186,8 @@ if [ "$TARGETARCH" = "ppc64le" ] || [ "$TARGETARCH" = "s390x" ]; then
173186 make -j$(nproc) VERBOSE=1
174187 make install -j$(nproc)
175188 cd ../../python
176- pip install --no-cache-dir -r requirements-build.txt
189+ # aipcc index is missing cython, and maybe more
190+ pip install --no-cache-dir --extra-index-url https://pypi.org/simple -r requirements-build.txt
177191 PYARROW_WITH_PARQUET=1 \
178192 PYARROW_WITH_DATASET=1 \
179193 PYARROW_WITH_FILESYSTEM=1 \
@@ -224,10 +238,12 @@ if [ "${TARGETARCH}" = "ppc64le" ]; then
224238 cd onnx
225239 git checkout ${ONNX_VERSION}
226240 git submodule update --init --recursive
227- pip install --no-cache-dir -r requirements.txt
241+ # aipcc index does not have numpy>=1.22
242+ pip install --no-cache-dir --extra-index-url https://pypi.org/simple -r requirements.txt
228243 CMAKE_ARGS="-DPython3_EXECUTABLE=$(which python3.12)"
229244 export CMAKE_ARGS
230- pip wheel . -w /root/onnx_wheel
245+ # protobuf>=4.25.1
246+ pip wheel --extra-index-url https://pypi.org/simple . -w /root/onnx_wheel
231247else
232248 echo "Skipping ONNX build on non-Power"
233249 mkdir -p /root/onnx_wheel
@@ -328,7 +344,8 @@ COPY --from=pyarrow-builder /tmp/wheels /tmp/wheels
328344RUN /bin/bash <<'EOF'
329345set -Eeuxo pipefail
330346if [ "$TARGETARCH" = "ppc64le" ] || [ "$TARGETARCH" = "s390x" ]; then
331- pip install --no-cache-dir /tmp/wheels/*.whl
347+ # aipcc is lacking numpy>=1.16.6
348+ pip install --no-cache-dir --extra-index-url https://pypi.org/simple /tmp/wheels/*.whl
332349else
333350 echo "Skipping wheel install for $TARGETARCH"
334351fi
@@ -342,7 +359,8 @@ COPY --from=onnx-builder /root/onnx_wheel/ /onnxwheels/
342359RUN /bin/bash <<'EOF'
343360set -Eeuxo pipefail
344361if [ "${TARGETARCH}" = "ppc64le" ]; then
345- pip install --no-cache-dir /onnxwheels/*.whl
362+ # aipcc is sure to lack something, so add extra index preemptively
363+ pip install --no-cache-dir --extra-index-url https://pypi.org/simple /onnxwheels/*.whl
346364else
347365 echo "Skipping ONNX/OpenBLAS install on non-Power"
348366fi
@@ -368,6 +386,26 @@ else
368386fi
369387EOF
370388
389+ RUN /bin/bash <<'EOF'
390+ set -Eeuxo pipefail
391+ if [ "${TARGETARCH}" = "ppc64le" ]; then
392+ packages=(
393+ # required to compile pillow
394+ zlib-devel libjpeg-turbo-devel
395+ # optional pillow deps https://pillow.readthedocs.io/en/latest/installation/building-from-source.html#external-libraries
396+ #libtiff-devel libwebp-devel openjpeg2-devel lcms2-devel freetype-devel
397+ #libimagequant-devel harfbuzz-devel fribidi-devel
398+
399+ # required to compile maturin
400+ openssl-devel
401+
402+ # required to compile scikit-learn
403+ gcc-gfortran
404+ )
405+ dnf install -y "${packages[@]}"
406+ fi
407+ EOF
408+
371409USER 1001:0
372410
373411# Install Python packages and Jupyterlab extensions from pylock.toml
@@ -382,10 +420,12 @@ echo "Installing software and packages"
382420# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
383421if [ "$TARGETARCH" = "ppc64le" ] || [ "$TARGETARCH" = "s390x" ]; then
384422 # We need special flags and environment variables when building packages
423+ # aipcc does not have some dependencies to build cryptography==43.0.3 on ppc64le, so we need to use pypi.org/simple
385424 GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 \
386425 CFLAGS="-O3" CXXFLAGS="-O3" \
387426 uv pip install --strict --no-deps --no-cache --no-config --no-progress \
388427 --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match \
428+ --extra-index-url https://pypi.org/simple \
389429 --requirements=./pylock.toml
390430else
391431 # This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
0 commit comments