diff --git a/tools/docker/Dockerfile.test_spack b/tools/docker/Dockerfile.test_spack index 41b5189354..98892afd9f 100644 --- a/tools/docker/Dockerfile.test_spack +++ b/tools/docker/Dockerfile.test_spack @@ -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 diff --git a/tools/docker/generate_dockerfiles.py b/tools/docker/generate_dockerfiles.py index 64b6e707b1..9a0006e274 100755 --- a/tools/docker/generate_dockerfiles.py +++ b/tools/docker/generate_dockerfiles.py @@ -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 diff --git a/tools/precommit/precommit.py b/tools/precommit/precommit.py index 1b356d0d2b..8089d16ae2 100755 --- a/tools/precommit/precommit.py +++ b/tools/precommit/precommit.py @@ -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) diff --git a/tools/spack/cp2k_deps_all_psmp.yaml b/tools/spack/cp2k_deps_all_psmp.yaml index 902c0a0ea5..1223e54024 100644 --- a/tools/spack/cp2k_deps_all_psmp.yaml +++ b/tools/spack/cp2k_deps_all_psmp.yaml @@ -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" diff --git a/tools/spack/cp2k_deps_all_ssmp.yaml b/tools/spack/cp2k_deps_all_ssmp.yaml index 3f790dced9..780fd1c9c3 100644 --- a/tools/spack/cp2k_deps_all_ssmp.yaml +++ b/tools/spack/cp2k_deps_all_ssmp.yaml @@ -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" diff --git a/tools/spack/cp2k_deps_minimal_psmp.yaml b/tools/spack/cp2k_deps_minimal_psmp.yaml index 69632c8553..315d3e3b70 100644 --- a/tools/spack/cp2k_deps_minimal_psmp.yaml +++ b/tools/spack/cp2k_deps_minimal_psmp.yaml @@ -37,8 +37,6 @@ spack: - ~examples - +openmp - smm=blas - repos: - - $spack specs: - "dbcsr@2.8.0" - "mpich@4.3.0" diff --git a/tools/spack/cp2k_deps_minimal_ssmp.yaml b/tools/spack/cp2k_deps_minimal_ssmp.yaml index 314003dde7..105d4abba0 100644 --- a/tools/spack/cp2k_deps_minimal_ssmp.yaml +++ b/tools/spack/cp2k_deps_minimal_ssmp.yaml @@ -27,8 +27,6 @@ spack: - ~examples - +openmp - smm=blas - repos: - - $spack specs: - "dbcsr@2.8.0" - "openblas@0.3.29" diff --git a/tools/spack/packages/deepmdkit/package.py b/tools/spack/cp2k_dev_repo/packages/deepmdkit/package.py similarity index 97% rename from tools/spack/packages/deepmdkit/package.py rename to tools/spack/cp2k_dev_repo/packages/deepmdkit/package.py index 8a09686f44..dd6d7d03de 100644 --- a/tools/spack/packages/deepmdkit/package.py +++ b/tools/spack/cp2k_dev_repo/packages/deepmdkit/package.py @@ -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): diff --git a/tools/spack/packages/greenx/package.py b/tools/spack/cp2k_dev_repo/packages/greenx/package.py similarity index 96% rename from tools/spack/packages/greenx/package.py rename to tools/spack/cp2k_dev_repo/packages/greenx/package.py index 80f61abd25..1b081f5780 100644 --- a/tools/spack/packages/greenx/package.py +++ b/tools/spack/cp2k_dev_repo/packages/greenx/package.py @@ -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): diff --git a/tools/spack/packages/lammps_user_pace/package.py b/tools/spack/cp2k_dev_repo/packages/lammps_user_pace/package.py similarity index 96% rename from tools/spack/packages/lammps_user_pace/package.py rename to tools/spack/cp2k_dev_repo/packages/lammps_user_pace/package.py index 5fdde2deb3..74b0fcb8ca 100644 --- a/tools/spack/packages/lammps_user_pace/package.py +++ b/tools/spack/cp2k_dev_repo/packages/lammps_user_pace/package.py @@ -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): diff --git a/tools/spack/packages/pexsi/fujitsu-add-link-flags.patch b/tools/spack/cp2k_dev_repo/packages/pexsi/fujitsu-add-link-flags.patch similarity index 100% rename from tools/spack/packages/pexsi/fujitsu-add-link-flags.patch rename to tools/spack/cp2k_dev_repo/packages/pexsi/fujitsu-add-link-flags.patch diff --git a/tools/spack/packages/pexsi/package.py b/tools/spack/cp2k_dev_repo/packages/pexsi/package.py similarity index 95% rename from tools/spack/packages/pexsi/package.py rename to tools/spack/cp2k_dev_repo/packages/pexsi/package.py index b9684cca60..e9df9622b5 100644 --- a/tools/spack/packages/pexsi/package.py +++ b/tools/spack/cp2k_dev_repo/packages/pexsi/package.py @@ -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"), diff --git a/tools/spack/cp2k_dev_repo/repo.yaml b/tools/spack/cp2k_dev_repo/repo.yaml new file mode 100644 index 0000000000..8938dbd52a --- /dev/null +++ b/tools/spack/cp2k_dev_repo/repo.yaml @@ -0,0 +1,3 @@ +repo: + namespace: cp2k_dev_repo + api: v2.0 diff --git a/tools/spack/repo.yaml b/tools/spack/repo.yaml deleted file mode 100644 index 6456475a51..0000000000 --- a/tools/spack/repo.yaml +++ /dev/null @@ -1,2 +0,0 @@ -repo: - namespace: cp2k