直接复制 conda 目录,执行下面的脚本重写一些路径就行了
#!/bin/sh
if [[ -z $1 ]]; then
echo usage: $0 conda/bin/conda
exit
fi
set -x -e
conda_exe=$(realpath $1)
CONDA_DIR=$(dirname $(dirname $conda_exe))
OLD_PREFIX=$(grep CONDA_EXE $CONDA_DIR/etc/profile.d/
conda.sh | head -n1 | cut -d "'" -f 2 | sed 's|/bin/conda||')
NEW_PREFIX=$(echo $conda_exe | sed 's|/bin/conda||')
need_sed=$(grep -RnIH "$OLD_PREFIX" $NEW_PREFIX 2>/dev/null | cut -d ':' -f 1 | sort | uniq)
sed -i "s|$OLD_PREFIX|$NEW_PREFIX|g" $need_sed
need_sed=$(grep -r -E '^#\!.*python' $NEW_PREFIX/bin/ | cut -d ':' -f 1)
sed -i "1c #!${NEW_PREFIX}/bin/python" $need_sed