From f237e468156842ebc2318c2f5230252e82f8635e Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Wed, 27 Mar 2024 15:09:28 +0500 Subject: [PATCH] Install cp2k from conda-forge (#170) Installing CP2K from conda provides an easy way to change the CP2K version and greatly reduces the size of the Dockerfile used for testing. Using the `mamba` installer allows keeping the installation time low. --- .docker/cp2k-code.yml | 6 ++++-- Dockerfile | 12 +++++------- conftest.py | 6 +++++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.docker/cp2k-code.yml b/.docker/cp2k-code.yml index 48cdb68..d38915f 100644 --- a/.docker/cp2k-code.yml +++ b/.docker/cp2k-code.yml @@ -2,6 +2,8 @@ label: cp2k computer: localhost description: default_calc_job_plugin: cp2k -filepath_executable: /usr/bin/cp2k +filepath_executable: /opt/conda/envs/cp2k/bin/cp2k.psmp append_text: -prepend_text: +prepend_text: | + eval "$(command conda shell.bash hook 2> /dev/null)" + conda activate cp2k diff --git a/Dockerfile b/Dockerfile index 9762664..2ad3d09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,21 +9,19 @@ ARG AIIDA_VERSION=2.5.0 FROM aiidateam/aiida-core-with-services:${AIIDA_VERSION} + # To prevent the container to exit prematurely. ENV KILL_ALL_RPOCESSES_TIMEOUT=50 - USER root -# Install statically linked CP2K which is a considerably newer release than Debian builtin. -# The statically linked CP2K is a non-MPI binary, but we're running all tests with 1 MPI proc. RUN set -ex ; \ apt-get update ; \ - apt-get install -y --no-install-recommends openmpi-bin locate; \ - wget --no-verbose -O /usr/bin/cp2k https://github.com/cp2k/cp2k/releases/download/v8.2.0/cp2k-8.2-Linux-x86_64.ssmp ; \ - echo "1e6fccf901873ebe9c827f45fb29331f599772f6e6281e988d8956c7a3aa143c /usr/bin/cp2k" | sha256sum -c ; \ - chmod +x /usr/bin/cp2k + apt-get install -y --no-install-recommends libsymspg1 USER aiida + +RUN mamba create --yes -c conda-forge -n cp2k cp2k=9.1 && mamba clean --all -f -y + # Install aiida-cp2k plugin. COPY --chown="${SYSTEM_UID}:${SYSTEM_GID}" . /home/aiida/aiida-cp2k RUN pip install ./aiida-cp2k[dev,docs] diff --git a/conftest.py b/conftest.py index 352b999..fd00978 100644 --- a/conftest.py +++ b/conftest.py @@ -6,7 +6,11 @@ @pytest.fixture(scope="function") def cp2k_code(aiida_local_code_factory): - return aiida_local_code_factory("cp2k", "cp2k") + return aiida_local_code_factory( + entry_point="cp2k", + executable="/opt/conda/envs/cp2k/bin/cp2k.psmp", + prepend_text='eval "$(command conda shell.bash hook 2> /dev/null)"\nconda activate cp2k\n', + ) @pytest.fixture(scope="function", autouse=True)