|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +# Build arguments and version numbers |
| 17 | +ARG FROM_IMAGE_NAME=quay.io/pypa/manylinux2014_x86_64 |
| 18 | +ARG BUILDER_EXTRA_DEPS=scratch |
| 19 | + |
| 20 | +# Base image |
| 21 | +FROM ${BUILDER_EXTRA_DEPS} AS extra_deps |
| 22 | +FROM ${FROM_IMAGE_NAME} |
| 23 | + |
| 24 | +ARG ARCH=x86_64 |
| 25 | +ARG CC=gcc |
| 26 | +ARG CXX=g++ |
| 27 | +ARG PATCHELF_VERSION=0.17.2 |
| 28 | +ARG CMAKE_VERSION=3.20.1 |
| 29 | +ARG PYVER=3.8 |
| 30 | +ARG PYV=38 |
| 31 | +ARG CLANG_VERSION=14.0 |
| 32 | +ARG SPHINX_VERSION=4.5.0 |
| 33 | + |
| 34 | +# Set build arguments as environment variables |
| 35 | +ENV ARCH=${ARCH} |
| 36 | +ENV CC=${CC} |
| 37 | +ENV CXX=${CXX} |
| 38 | +ENV PATCHELF_VERSION=${PATCHELF_VERSION} |
| 39 | +ENV CMAKE_VERSION=${CMAKE_VERSION} |
| 40 | +ENV PYVER=${PYVER} |
| 41 | +ENV PYV=${PYV} |
| 42 | +ENV CLANG_VERSION=${CLANG_VERSION} |
| 43 | +ENV LIBCLANG_VERSION=${CLANG_VERSION} |
| 44 | +ENV SPHINX_VERSION=${SPHINX_VERSION} |
| 45 | + |
| 46 | +# Install additional dependencies |
| 47 | +RUN yum install -y ninja-build ccache ShellCheck curl |
| 48 | + |
| 49 | +# Configure ccache |
| 50 | +RUN mkdir -p /cache |
| 51 | +COPY ccache.conf /etc/ccache.conf |
| 52 | +ENV CCACHE_CONFIGPATH=/etc/ccache.conf |
| 53 | +ENV PRE_COMMIT_HOME=/cache/pre-commit |
| 54 | + |
| 55 | +# Install patchelf (needed to patch rpath of dependencies in bundle-wheel.sh) |
| 56 | +RUN wget -q https://github.com/NixOS/patchelf/releases/download/${PATCHELF_VERSION}/patchelf-${PATCHELF_VERSION}-${ARCH}.tar.gz -O /tmp/patchelf.tar.gz && \ |
| 57 | + tar -xzf /tmp/patchelf.tar.gz -C /tmp && \ |
| 58 | + mv /tmp/bin/patchelf /usr/local/bin/ && \ |
| 59 | + rm -rf /tmp/patchelf* |
| 60 | + |
| 61 | +# Install CMake |
| 62 | +RUN cmake --version |
| 63 | +RUN wget -q https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-${ARCH}.sh -O /tmp/cmake-install.sh && \ |
| 64 | + chmod +x /tmp/cmake-install.sh && \ |
| 65 | + mkdir /opt/cmake-${CMAKE_VERSION} && \ |
| 66 | + /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-${CMAKE_VERSION} \ |
| 67 | + && rm -f /usr/local/bin/*cmake* \ |
| 68 | + && rm -f /usr/local/bin/cpack \ |
| 69 | + && rm -f /usr/local/bin/ctest && \ |
| 70 | + ln -s /opt/cmake-${CMAKE_VERSION}/bin/* /usr/local/bin/ && \ |
| 71 | + rm -rf /tmp/cmake-install.sh |
| 72 | + |
| 73 | +# Set up Python environment variables |
| 74 | +ENV PYTHONPATH=/opt/python/v |
| 75 | +ENV PYBIN=${PYTHONPATH}/bin |
| 76 | +ENV PYLIB=${PYTHONPATH}/lib |
| 77 | + |
| 78 | +# Create symlink to the desired Python version |
| 79 | +RUN ln -s /opt/python/cp${PYV}* ${PYTHONPATH} |
| 80 | + |
| 81 | +# Update PATH and library paths |
| 82 | +ENV PATH=${PYTHONPATH}/bin:/opt/python/*/bin:${PATH} |
| 83 | +ENV LD_LIBRARY_PATH=/usr/local/lib:/opt/python/*/lib:${PYLIB}:${LD_LIBRARY_PATH} |
| 84 | +ENV LIBRARY_PATH=/usr/local/lib:/opt/python/*/lib:${PYLIB}:${LIBRARY_PATH} |
| 85 | + |
| 86 | +# Propagate the environment variable to profile.d |
| 87 | +RUN echo "export PYTHONPATH=${PYTHONPATH}" >> /etc/profile.d/python.sh && \ |
| 88 | + echo "export PYBIN=${PYBIN}" >> /etc/profile.d/python.sh && \ |
| 89 | + echo "export PYLIB=${PYLIB}" >> /etc/profile.d/python.sh && \ |
| 90 | + echo "export PATH=\${PYTHONPATH}/bin:/opt/python/*/bin:\${PATH}" >> /etc/profile.d/python.sh && \ |
| 91 | + echo "export LD_LIBRARY_PATH=/usr/local/lib:/opt/python/*/lib:\${PYLIB}:\${LD_LIBRARY_PATH}" >> /etc/profile.d/python.sh && \ |
| 92 | + echo "export LIBRARY_PATH=/usr/local/lib:/opt/python/*/lib:\${PYLIB}:\${LIBRARY_PATH}" >> /etc/profile.d/python.sh && \ |
| 93 | + chmod +x /etc/profile.d/python.sh |
| 94 | + |
| 95 | +# Install Python packages |
| 96 | +RUN python3 -m pip install --no-cache-dir \ |
| 97 | + breathe \ |
| 98 | + cibuildwheel \ |
| 99 | + clang==${CLANG_VERSION} \ |
| 100 | + exhale \ |
| 101 | + flake8 \ |
| 102 | + future \ |
| 103 | + graphviz \ |
| 104 | + numpy \ |
| 105 | + pre-commit \ |
| 106 | + recommonmark \ |
| 107 | + setuptools \ |
| 108 | + sphinx_rtd_theme \ |
| 109 | + sphinx==${SPHINX_VERSION} \ |
| 110 | + twine \ |
| 111 | + wheel |
| 112 | + |
| 113 | +# Update the dynamic linker run-time bindings |
| 114 | +RUN ldconfig |
| 115 | + |
| 116 | +# extra deps |
| 117 | +COPY --from=extra_deps / / |
0 commit comments