Skip to content

Commit e0e2fa3

Browse files
fix(codeserver): build pyarrow from source for ppc64le (opendatahub-io#2495)
* build pyarrow from source for ppc64le Signed-off-by: Md. Shafi Hussain <[email protected]> * fix environment variables Signed-off-by: Md. Shafi Hussain <[email protected]> --------- Signed-off-by: Md. Shafi Hussain <[email protected]>
1 parent 1eec8a8 commit e0e2fa3

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

codeserver/ubi9-python-3.12/Dockerfile.cpu

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,13 @@ COPY ${CODESERVER_SOURCE_CODE}/pylock.toml ./
234234
COPY --from=whl-cache /tmp/control /dev/null
235235

236236
# Install packages and cleanup
237+
# (ARCH-ppc64le): install packages (eg. pyarrow) that need to be built from source repository on ppc64le
238+
RUN --mount=type=cache,target=/root/.cache/uv \
239+
--mount=type=cache,from=whl-cache,source=/wheelsdir/,target=/wheelsdir/,rw \
240+
bash -c ' \
241+
if [[ $(uname -m) == "ppc64le" ]]; then \
242+
uv pip install /wheelsdir/*.whl; \
243+
fi '
237244
# install packages as USER 0 (this will allow us to consume uv cache)
238245
RUN --mount=type=cache,target=/root/.cache/uv \
239246
echo "Installing softwares and packages" && \

codeserver/ubi9-python-3.12/devel_env_setup.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,40 @@ set -eoux pipefail
66
# It installs the required build-time dependencies for python wheels #
77
# OpenBlas is built from source (instead of distro provided) with recommended flags for performance #
88
#####################################################################################################
9+
export WHEEL_DIR=${WHEEL_DIR:-"/wheelsdir"}
10+
mkdir -p ${WHEEL_DIR}
11+
12+
build_pyarrow() {
13+
CURDIR=$(pwd)
14+
15+
export PYARROW_VERSION=${1:-$(curl -s https://api.github.com/repos/apache/arrow/releases/latest | jq -r '.tag_name' | grep -Eo "[0-9\.]+")}
16+
17+
TEMP_BUILD_DIR=$(mktemp -d)
18+
cd ${TEMP_BUILD_DIR}
19+
20+
: ================== Installing Pyarrow ==================
21+
git clone --recursive https://github.com/apache/arrow.git -b apache-arrow-${PYARROW_VERSION}
22+
cd arrow/cpp
23+
mkdir build && cd build
24+
cmake -DCMAKE_BUILD_TYPE=release \
25+
-DCMAKE_INSTALL_PREFIX=/usr/local \
26+
-DARROW_PYTHON=ON \
27+
-DARROW_BUILD_TESTS=OFF \
28+
-DARROW_JEMALLOC=ON \
29+
-DARROW_BUILD_STATIC="OFF" \
30+
-DARROW_PARQUET=ON \
31+
..
32+
make install -j ${MAX_JOBS:-$(nproc)}
33+
cd ../../python/
34+
uv pip install -v -r requirements-wheel-build.txt
35+
PYARROW_PARALLEL=${PYARROW_PARALLEL:-$(nproc)} \
36+
python setup.py build_ext \
37+
--build-type=release --bundle-arrow-cpp \
38+
bdist_wheel --dist-dir ${WHEEL_DIR}
39+
40+
cd ${CURDIR}
41+
rm -rf ${TEMP_BUILD_DIR}
42+
}
943

1044
if [[ $(uname -m) == "ppc64le" ]]; then
1145
# install development packages
@@ -36,6 +70,10 @@ if [[ $(uname -m) == "ppc64le" ]]; then
3670
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/OpenBLAS/lib/
3771
export PKG_CONFIG_PATH=$(find / -type d -name "pkgconfig" 2>/dev/null | tr '\n' ':')
3872
export CMAKE_ARGS="-DPython3_EXECUTABLE=python"
73+
74+
PYARROW_VERSION=$(grep -A1 '"pyarrow"' pylock.toml | grep -Eo '\b[0-9\.]+\b')
75+
build_pyarrow ${PYARROW_VERSION}
76+
uv pip install ${WHEEL_DIR}/*.whl
3977
else
4078
# only for mounting on non-ppc64le
4179
mkdir -p /root/OpenBLAS/

0 commit comments

Comments
 (0)