Update Spack and add support for Spack packages repository

This commit is contained in:
Rocco Meli 2025-06-26 08:27:09 +02:00 committed by GitHub
parent 58c5f645d6
commit 400017fac0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 63 additions and 42 deletions

View file

@ -10,6 +10,7 @@ RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
bzip2 \
ca-certificates \
cmake \
curl \
g++ \
gcc \
gfortran \
@ -41,15 +42,27 @@ RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip3 install --quiet boto3==1.38.11 google-cloud-storage==3.1.0
# Install a recent Spack version
# Install Spack and Spack packages
WORKDIR /root/spack
ARG SPACK_VERSION
ENV SPACK_VERSION=${SPACK_VERSION:-develop-2025-05-18}
RUN git init --quiet && \
git remote add origin https://github.com/spack/spack.git && \
git fetch --quiet --depth 1 origin ${SPACK_VERSION} --no-tags && \
git checkout --quiet FETCH_HEAD
ENV PATH="/root/spack/bin:${PATH}"
ENV SPACK_VERSION=${SPACK_VERSION:-2e7168b4cfe9222a94becf0c2c5b401f513181ec}
ARG SPACK_PACKAGES_VERSION
ENV SPACK_PACKAGES_VERSION=${SPACK_PACKAGES_VERSION:-c63151a5baffcd96978966cd5ed83a6b8328e026}
ARG SPACK_REPO=https://github.com/spack/spack
ENV SPACK_ROOT=/opt/spack-$SPACK_VERSION
ARG SPACK_PACKAGES_REPO=https://github.com/spack/spack-packages
ENV SPACK_PACKAGES_ROOT=/opt/spack-packages-$SPACK_PACKAGES_VERSION
RUN mkdir -p $SPACK_ROOT \
&& curl -OL $SPACK_REPO/archive/$SPACK_VERSION.tar.gz \
&& tar -xzf $SPACK_VERSION.tar.gz -C /opt && rm -f $SPACK_VERSION.tar.gz \
&& mkdir -p $SPACK_PACKAGES_ROOT \
&& curl -OL $SPACK_PACKAGES_REPO/archive/$SPACK_PACKAGES_VERSION.tar.gz \
&& tar -xzf $SPACK_PACKAGES_VERSION.tar.gz -C /opt && rm -f $SPACK_PACKAGES_VERSION.tar.gz
ENV PATH="$SPACK_ROOT/bin:${PATH}"
# Add Spack packages builtin repository
RUN spack repo add --scope site $SPACK_PACKAGES_ROOT/repos/spack_repo/builtin
# Find all compilers
RUN spack compiler find
@ -65,8 +78,9 @@ RUN ./setup_spack_cache.sh
# Copy Spack configuration and build recipes
ARG CP2K_BUILD_TYPE
ENV CP2K_BUILD_TYPE=${CP2K_BUILD_TYPE:-all}
COPY ./tools/spack/repo.yaml ./tools/spack/cp2k_deps_${CP2K_BUILD_TYPE}_psmp.yaml ./
COPY ./tools/spack/packages ./packages
COPY ./tools/spack/cp2k_deps_${CP2K_BUILD_TYPE}_psmp.yaml ./
COPY ./tools/spack/cp2k_dev_repo $SPACK_PACKAGES_ROOT/repos/spack_repo/cp2k_dev_repo/
RUN spack repo add --scope site $SPACK_PACKAGES_ROOT/repos/spack_repo/cp2k_dev_repo/
# Sarus containers must be dynamically linked to an MPI implementation that is ABI-compatible
# with the MPI on the compute nodes at CSCS like MPICH@3
@ -78,7 +92,7 @@ RUN sed -i -e "s/mpich@[0-9.]*/mpich@${MPICH_VERSION}/" cp2k_deps_${CP2K_BUILD_T
# Install CP2K dependencies via Spack
RUN spack -e myenv concretize -f
ENV SPACK_ENV_VIEW="/root/spack/var/spack/environments/myenv/spack-env/view"
ENV SPACK_ENV_VIEW="$SPACK_ROOT/var/spack/environments/myenv/spack-env/view"
RUN spack -e myenv env depfile -o spack_makefile && \
make -j32 --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

View file

@ -855,6 +855,7 @@ RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
bzip2 \
ca-certificates \
cmake \
curl \
g++ \
gcc \
gfortran \
@ -886,15 +887,27 @@ RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip3 install --quiet boto3==1.38.11 google-cloud-storage==3.1.0
# Install a recent Spack version
# Install Spack and Spack packages
WORKDIR /root/spack
ARG SPACK_VERSION
ENV SPACK_VERSION=${{SPACK_VERSION:-develop-2025-05-18}}
RUN git init --quiet && \
git remote add origin https://github.com/spack/spack.git && \
git fetch --quiet --depth 1 origin ${{SPACK_VERSION}} --no-tags && \
git checkout --quiet FETCH_HEAD
ENV PATH="/root/spack/bin:${{PATH}}"
ENV SPACK_VERSION=${{SPACK_VERSION:-2e7168b4cfe9222a94becf0c2c5b401f513181ec}}
ARG SPACK_PACKAGES_VERSION
ENV SPACK_PACKAGES_VERSION=${{SPACK_PACKAGES_VERSION:-c63151a5baffcd96978966cd5ed83a6b8328e026}}
ARG SPACK_REPO=https://github.com/spack/spack
ENV SPACK_ROOT=/opt/spack-$SPACK_VERSION
ARG SPACK_PACKAGES_REPO=https://github.com/spack/spack-packages
ENV SPACK_PACKAGES_ROOT=/opt/spack-packages-$SPACK_PACKAGES_VERSION
RUN mkdir -p $SPACK_ROOT \
&& curl -OL $SPACK_REPO/archive/$SPACK_VERSION.tar.gz \
&& tar -xzf $SPACK_VERSION.tar.gz -C /opt && rm -f $SPACK_VERSION.tar.gz \
&& mkdir -p $SPACK_PACKAGES_ROOT \
&& curl -OL $SPACK_PACKAGES_REPO/archive/$SPACK_PACKAGES_VERSION.tar.gz \
&& tar -xzf $SPACK_PACKAGES_VERSION.tar.gz -C /opt && rm -f $SPACK_PACKAGES_VERSION.tar.gz
ENV PATH="$SPACK_ROOT/bin:${{PATH}}"
# Add Spack packages builtin repository
RUN spack repo add --scope site $SPACK_PACKAGES_ROOT/repos/spack_repo/builtin
# Find all compilers
RUN spack compiler find
@ -910,8 +923,9 @@ RUN ./setup_spack_cache.sh
# Copy Spack configuration and build recipes
ARG CP2K_BUILD_TYPE
ENV CP2K_BUILD_TYPE=${{CP2K_BUILD_TYPE:-all}}
COPY ./tools/spack/repo.yaml ./tools/spack/cp2k_deps_${{CP2K_BUILD_TYPE}}_{version}.yaml ./
COPY ./tools/spack/packages ./packages
COPY ./tools/spack/cp2k_deps_${{CP2K_BUILD_TYPE}}_{version}.yaml ./
COPY ./tools/spack/cp2k_dev_repo $SPACK_PACKAGES_ROOT/repos/spack_repo/cp2k_dev_repo/
RUN spack repo add --scope site $SPACK_PACKAGES_ROOT/repos/spack_repo/cp2k_dev_repo/
# Sarus containers must be dynamically linked to an MPI implementation that is ABI-compatible
# with the MPI on the compute nodes at CSCS like MPICH@3
@ -923,7 +937,7 @@ RUN sed -i -e "s/mpich@[0-9.]*/mpich@${{MPICH_VERSION}}/" cp2k_deps_${{CP2K_BUIL
# Install CP2K dependencies via Spack
RUN spack -e myenv concretize -f
ENV SPACK_ENV_VIEW="/root/spack/var/spack/environments/myenv/spack-env/view"
ENV SPACK_ENV_VIEW="$SPACK_ROOT/var/spack/environments/myenv/spack-env/view"
RUN spack -e myenv env depfile -o spack_makefile && \
make -j32 --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

View file

@ -216,7 +216,7 @@ def process_file(fn: str, allow_modifications: bool) -> None:
if re.match(r"(.*/PACKAGE)|(.*\.py)$", fn):
ast.parse(orig_content, filename=fn)
if "tools/spack/packages" in fn:
if "tools/spack/cp2k_dev_repo/packages" in fn:
run_remote_tool("spackformat", fn)
else:
run_remote_tool("black", fn)

View file

@ -92,8 +92,6 @@ spack:
require:
- +hdf5
- build_system=cmake
repos:
- $spack
specs:
- "mpich@4.3.0"
- "openblas@0.3.29"
@ -102,13 +100,13 @@ spack:
- "dbcsr@2.8.0"
- "deepmdkit@3.0.2"
- "dftd4@3.7.0"
- "dla-future@0.9.0"
- "dla-future-fortran@0.4.0"
- "dla-future@0.10.0"
- "dla-future-fortran@0.5.0"
- "elpa@2025.01.001"
- "fftw@3.3.10"
- "greenx@2.2"
- "hdf5@1.14"
- "lammps_user_pace@2023.11.25.fix2"
- "lammps-user-pace@2023.11.25.fix2"
- "libint@2.9.0"
- "libsmeagol@1.2"
- "libvori@220621"

View file

@ -61,8 +61,6 @@ spack:
require:
- +hdf5
- build_system=cmake
repos:
- $spack
specs:
- "openblas@0.3.29"
- "dbcsr@2.8.0"
@ -71,7 +69,7 @@ spack:
- "fftw@3.3.10"
- "greenx@2.2"
- "hdf5@1.14"
- "lammps_user_pace@2023.11.25.fix2"
- "lammps-user-pace@2023.11.25.fix2"
- "libint@2.9.0"
- "libvori@220621"
- "libxc@7.0.0"

View file

@ -37,8 +37,6 @@ spack:
- ~examples
- +openmp
- smm=blas
repos:
- $spack
specs:
- "dbcsr@2.8.0"
- "mpich@4.3.0"

View file

@ -27,8 +27,6 @@ spack:
- ~examples
- +openmp
- smm=blas
repos:
- $spack
specs:
- "dbcsr@2.8.0"
- "openblas@0.3.29"

View file

@ -2,8 +2,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.build_systems import cmake
from spack.package import *
from spack_repo.builtin.build_systems.cmake import CMakePackage
class Deepmdkit(CMakePackage):

View file

@ -3,6 +3,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import *
from spack_repo.builtin.build_systems.cmake import CMakePackage
class Greenx(CMakePackage):

View file

@ -2,8 +2,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.build_systems import cmake
from spack.package import *
from spack_repo.builtin.build_systems.cmake import CMakePackage
class LammpsUserPace(CMakePackage):

View file

@ -2,12 +2,11 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.build_systems.cmake
import spack.build_systems.makefile
from spack.package import *
from spack_repo.builtin.build_systems import cmake, makefile
class Pexsi(MakefilePackage, CMakePackage):
class Pexsi(makefile.MakefilePackage, cmake.CMakePackage):
"""The PEXSI library is written in C++, and uses message passing interface
(MPI) to parallelize the computation on distributed memory computing
systems and achieve scalability on more than 10,000 processors.
@ -60,7 +59,7 @@ class Pexsi(MakefilePackage, CMakePackage):
return f"https://bitbucket.org/berkeleylab/pexsi/downloads/pexsi_v{version}.tar.gz"
class MakefileBuilder(spack.build_systems.makefile.MakefileBuilder):
class MakefileBuilder(makefile.MakefileBuilder):
parallel = False
def edit(self, pkg, spec, prefix):
@ -120,7 +119,7 @@ class MakefileBuilder(spack.build_systems.makefile.MakefileBuilder):
)
class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
class CMakeBuilder(cmake.CMakeBuilder):
def cmake_args(self):
args = [
self.define_from_variant("PEXSI_ENABLE_FORTRAN", "fortran"),

View file

@ -0,0 +1,3 @@
repo:
namespace: cp2k_dev_repo
api: v2.0

View file

@ -1,2 +0,0 @@
repo:
namespace: cp2k