Skip to content

Commit

Permalink
BUG,COCALC: Install hg-git and hg-evolve if needed on CoCalc
Browse files Browse the repository at this point in the history
--HG--
branch : 0.4
  • Loading branch information
Michael McNeil Forbes committed Mar 24, 2024
1 parent 9928173 commit 0ec24a2
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions bin/mmf_setup
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ if [[ -n $BASH_VERSION ]] && [[ "$(basename "$0" 2> /dev/null)" == "mmf_setup" ]
shift # move to the next argument
echo "DRY RUN: the following is what would happen with the -v option"
echo
# Default is empty so when debugging, the default is dry run.
not_dry_run=
else
not_dry_run=true
Expand All @@ -72,19 +73,19 @@ if [[ -n $BASH_VERSION ]] && [[ "$(basename "$0" 2> /dev/null)" == "mmf_setup" ]
_python3="${ANACONDA2020}/bin/python3"
fi
if [[ -f "${_python3}" ]]; then
echo "ln -sf ${_python3} ~/.local/bin/"
if [[ $not_dry_run ]]; then
ln -sf ${_python3} ~/.local/bin/
fi
echo "ln -sf ${_python3} ~/.local/bin/"
if [[ $not_dry_run ]]; then
ln -sf ${_python3} ~/.local/bin/
fi
else
echo "ERROR: Could not find python3 to put in ~/.local/bin/"
echo "ERROR: Could not find python3 to put in ~/.local/bin/"
fi
fi

hg="$(type -p hg)"
if type pipx 2> /dev/null && pipx list --short | grep "mmf-setup"; then
# Use pipx version of python from now on.
PYTHON3="$(pipx environment --value PIPX_LOCAL_VENVS)/mmf-setup/bin/python3"
PYTHON3="$(pipx environment --value PIPX_LOCAL_VENVS)/mmf-setup/bin/python3"
echo "Found pipx mmf-setup venv... Switching to PYTHON3=$PYTHON3"

echo "# Injecting tools into mmf-setup:"
Expand All @@ -100,6 +101,25 @@ if [[ -n $BASH_VERSION ]] && [[ "$(basename "$0" 2> /dev/null)" == "mmf_setup" ]
fi
fi

echo "# Checking for mercurial extensions..."
if type hg; then
HG_PYTHON="$(hg debuginstall 2> /dev/null | grep 'Python executable' \
| sed 's/.*(\(.*\))/\1/g')"
for ext_pkg in "evolve hg-evolve" "hggit hg-git"; do
# See https://stackoverflow.com/a/52228219
set -- ${ext_pkg} # Set the two arguments to $1 and $2.
ext=$1
pkg=$2
if [[ ! "$(hg debugextensions 2> /dev/null | grep ${ext})" ]]; then
echo "# Installing ${ext} extension..."
echo "${HG_PYTHON} -m pip install -q --upgrade --user ${pkg}"
if [[ $not_dry_run ]]; then
"${HG_PYTHON}" -m pip install -q --upgrade --user ${pkg}
fi
fi
done
fi

echo "# Installing poetry..."
echo "curl -sSL https://install.python-poetry.org | $PYTHON3 -"
if [[ $not_dry_run ]]; then
Expand Down

0 comments on commit 0ec24a2

Please sign in to comment.