Migration of python version on conda for AiiDA

I install AiiDA on conda env. Python packages follow python release versions, and often newer python versions are preferable. But updating python version on a conda env by, e.g., conda update "python=3.11" fails when many packages were already installed because of the failure of solving dependency. Then, an easy choice is creating new env and install packages from scratch. This is much easier for me indeed.

Recent conda can rename env easily

conda rename -n orig_env backup_env

Create orig_env

conda create -n orig_env

Install packages (here python 3.11 for example)

conda install "python=3.11" postgresql

Having major version change of postgresql, db migration is necessary, see https://atztogo.hatenablog.com/entry/2023/05/06/154612.

Install other packages

conda install numpy scipy h5py pyyaml matplotlib-base c-compiler cxx-compiler "libblas=*=*mkl" spglib mkl-include boost eigen cmake ipython make

Activate (deactivate) setting has to be modified for zsh user like me.

cd $CONDA_PREFIX/etc/conda/activate.d/ 
mkdir bash
mv * bash
cp ~/.miniforge/envs/backup_env/etc/conda/activate.d/env_vars.sh .

Modify env_vars.sh. Do the same for deactivate. In my case following lines:

export AIIDA_PATH=~/aiida
eval "$(_VERDI_COMPLETE=zsh_source verdi)"
export HOST=`hostname`
autoload bashcompinit
emulate sh -c 'source $CONDA_PREFIX/etc/conda/activate.d/bash/activate-binutils_linux-64.sh'
emulate sh -c 'source $CONDA_PREFIX/etc/conda/activate.d/bash/activate-gcc_linux-64.sh'
emulate sh -c 'source $CONDA_PREFIX/etc/conda/activate.d/bash/activate-gxx_linux-64.sh'
emulate sh -c 'source $CONDA_PREFIX/etc/conda/activate.d/bash/libblas_mkl_activate.sh'
emulate sh -c 'source $CONDA_PREFIX/etc/conda/activate.d/bash/libxml2_activate.sh'

are written in env_vars.sh. Then installing packages via pip. git-pull aiida-core, and

pip install -e ."[atomic_tools,docs,tests,rest]"

git-pull aiida-vasp, and

pip install -e ."[pre-commit,tests,graphs]"

Installed a different version of aiida-core, aiida-storage update may be necessary, but this is informed when verdi status or verdi daemon start, etc. So just follow it.