diff --git a/scripts/install.sh b/scripts/install.sh index 1e1e415704adcf829ec83643b0e1b3b36b8ac486..1ab7b476c5621a737366fcddb26189928ca533ef 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -10,19 +10,32 @@ if [ -z "$LARVATAGGER_PATH" ]; then fi if [ "$1" = "--uninstall" ]; then - if [ -d "$LARVATAGGER_PATH/MaggotUBA" ]; then - env=$(cd "$LARVATAGGER_PATH/MaggotUBA" && poetry env info -p) - if [ -d "$env" ]; then - # clear the virtual environments - env=$(dirname "$env") - rm -rf "$env"/maggotuba* - rm -rf "$env"/taggingbackends* + for pkg in MaggotUBA TaggingBackends; do + if [ -d "$LARVATAGGER_PATH/$pkg" ]; then + env=$(cd "$LARVATAGGER_PATH/$pkg" && poetry env info -p) + [ -d "$env" ] && rm -rf "$env" fi - fi + done rm -rf "$BIN_DIR/larvatagger" rm -rf "$LARVATAGGER_PATH" else +PYTHON_VERSION=3.8 +for arg in "$@"; do + if [ "$arg" = "--with-default-backend" ]; then + WITH_BACKEND=1 + MAGGOTUBA_CORE_BRANCH= + MAGGOTUBA_ADAPTER_BRANCH= + break + elif [ "$arg" = "--with-backend" ]; then + WITH_BACKEND=1 + elif [ "$arg" = "--experimental" ]; then + MAGGOTUBA_CORE_BRANCH= + MAGGOTUBA_ADAPTER_BRANCH=torch2 + PYTHON_VERSION=3.11 + fi +done + if ! command -v curl 1>/dev/null 2>&1; then if command -v brew 1>/dev/null 2>&1; then # macOS users are not given the choice as they usually do not care about freedom @@ -63,26 +76,20 @@ if ! command -v julia 1>/dev/null 2>&1; then fi fi -for arg in "$@"; do - if [ "$arg" = "--with-default-backend" ]; then - WITH_DEFAULT_BACKEND=1 - break - fi -done -if [ -n "$WITH_DEFAULT_BACKEND" ]; then +if [ -n "$WITH_BACKEND" ]; then if [ "`uname`" = "Darwin" ]; then echo "WARNING: the default tagging backend is not supported by macOS" fi - if ! command -v python3.8 1>/dev/null 2>&1; then + if ! command -v python$PYTHON_VERSION 1>/dev/null 2>&1; then if command -v pyenv 1>/dev/null 2>&1; then - pyenv install 3.8 + pyenv install $PYTHON_VERSION else check_brew if command -v brew 1>/dev/null 2>&1; then - brew install python@3.8 + brew install python@$PYTHON_VERSION else - echo "WARNING: command python3.8 not found" - echo "if under Ubuntu, consider running: sudo apt install python3.8 python3.8-venv" + echo "WARNING: command python$PYTHON_VERSION not found" + echo "if under Ubuntu, consider running: sudo apt install python$PYTHON_VERSION python${PYTHON_VERSION}-venv" fi fi fi @@ -121,7 +128,7 @@ fi (cd LarvaTagger.jl && julia --project=. -e 'using Pkg; Pkg.instantiate()') [ -d PlanarLarvae ] && (cd LarvaTagger.jl && julia --project=. -e 'using Pkg; Pkg.develop(path="../PlanarLarvae")') -if [ -z "$WITH_DEFAULT_BACKEND" ]; then +if [ -z "$WITH_BACKEND" ]; then mkdir -p "$BIN_DIR" cat <<EOF >"$BIN_DIR"/larvatagger @@ -133,7 +140,7 @@ EOF else activate() { - poetry env use 3.8 + poetry env use $PYTHON_VERSION } if [ -d TaggingBackends ]; then