Install Spack view in install_tree

This commit is contained in:
Matthias Krack 2025-12-22 13:20:39 +01:00
parent ab76537063
commit 4bfb9b15cf
6 changed files with 11 additions and 20 deletions

View file

@ -97,9 +97,7 @@ RUN spack env create myenv cp2k_deps_${CP2K_VERSION}.yaml && \
# Install CP2K dependencies via Spack
RUN spack -e myenv concretize -f
ENV SPACK_ENV_VIEW="${SPACK_ROOT}/var/spack/environments/myenv/spack-env/view"
RUN spack -e myenv env depfile -o spack_makefile && \
make -j${NUM_PROCS} --file=spack_makefile SPACK_COLOR=never --output-sync=recurse && \
cp -ar ${SPACK_ENV_VIEW}/bin ${SPACK_ENV_VIEW}/include ${SPACK_ENV_VIEW}/lib /opt/spack
RUN spack -e myenv env depfile -o spack_makefile
RUN make -j${NUM_PROCS} --file=spack_makefile SPACK_COLOR=never --output-sync=recurse
# EOF

View file

@ -24,6 +24,9 @@ VERSION=$2
if [[ "${PROFILE}" =~ ^spack ]]; then
eval "$(spack env activate myenv --sh)"
# PyTorch's TorchConfig.cmake is buried in the Python site-packages directory
Torch_DIR="$(dirname "$(find /opt/spack ! -type l -name TorchConfig.cmake | tail -n 1)")"
export Torch_DIR
elif [[ "${PROFILE}" =~ ^toolchain ]]; then
# shellcheck disable=SC1091
source "${TOOLCHAIN_DIR}/install/setup"
@ -41,9 +44,6 @@ cd build || return 1
# TODO: Reconcile PROFILE/VERSION with CP2K_BUILD_OPTIONS in CMakeLists.txt
#
if [[ "${PROFILE}" == "spack" ]] && [[ "${VERSION}" == "psmp" ]]; then
# PyTorch's TorchConfig.cmake is buried in the Python site-packages directory
Torch_DIR="$(dirname "$(find /opt/spack/lib -name TorchConfig.cmake)")"
export Torch_DIR
cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \
@ -56,9 +56,6 @@ if [[ "${PROFILE}" == "spack" ]] && [[ "${VERSION}" == "psmp" ]]; then
CMAKE_EXIT_CODE=$?
elif [[ "${PROFILE}" == "spack" ]] && [[ "${VERSION}" == "ssmp" ]]; then
# PyTorch's TorchConfig.cmake is buried in the Python site-packages directory
Torch_DIR="$(dirname "$(find /opt/spack/lib -name TorchConfig.cmake)")"
export Torch_DIR
cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \

View file

@ -89,10 +89,8 @@ RUN spack env create myenv cp2k_deps_${CP2K_VERSION}.yaml && \
# Install CP2K dependencies via Spack
RUN spack -e myenv concretize -f
ENV SPACK_ENV_VIEW="${SPACK_ROOT}/var/spack/environments/myenv/spack-env/view"
RUN spack -e myenv env depfile -o spack_makefile && \
make -j${NUM_PROCS} --file=spack_makefile SPACK_COLOR=never --output-sync=recurse && \
cp -ar ${SPACK_ENV_VIEW}/bin ${SPACK_ENV_VIEW}/include ${SPACK_ENV_VIEW}/lib /opt/spack
RUN spack -e myenv env depfile -o spack_makefile
RUN make -j${NUM_PROCS} --file=spack_makefile SPACK_COLOR=never --output-sync=recurse
# Install CP2K sources.
WORKDIR /opt/cp2k

View file

@ -724,10 +724,8 @@ RUN spack env create myenv cp2k_deps_${{CP2K_VERSION}}.yaml && \
# Install CP2K dependencies via Spack
RUN spack -e myenv concretize -f
ENV SPACK_ENV_VIEW="${{SPACK_ROOT}}/var/spack/environments/myenv/spack-env/view"
RUN spack -e myenv env depfile -o spack_makefile && \
make -j${{NUM_PROCS}} --file=spack_makefile SPACK_COLOR=never --output-sync=recurse && \
cp -ar ${{SPACK_ENV_VIEW}}/bin ${{SPACK_ENV_VIEW}}/include ${{SPACK_ENV_VIEW}}/lib /opt/spack
RUN spack -e myenv env depfile -o spack_makefile
RUN make -j${{NUM_PROCS}} --file=spack_makefile SPACK_COLOR=never --output-sync=recurse
"""

View file

@ -136,7 +136,7 @@ spack:
- "trexio@2.5.0"
view:
default:
root: ./spack-env/view
root: /opt/spack/view
exclude:
# Exclude gcc-runtime to avoid adding a copy of libgomp.so to the view
- gcc-runtime

View file

@ -85,7 +85,7 @@ spack:
- "trexio@2.5.0"
view:
default:
root: ./spack-env/view
root: /opt/spack/view
exclude:
# Exclude gcc-runtime to avoid adding a copy of libgomp.so to the view
- gcc-runtime