@@ -810,15 +810,18 @@ function _tue-install-pip
810810 local pv=$1
811811 shift
812812 tue-install-debug " tue-install-pip${pv} $* "
813+ local name=" $* "
814+ name=" ${name// / ^} "
813815
814816 if [ -z " $1 " ]
815817 then
816818 tue-install-error " Invalid tue-install-pip${pv} call: needs package as argument."
817819 fi
818- tue-install-debug " Adding $1 to pip${pv} list"
820+
821+ tue-install-debug " Adding $name to pip${pv} list"
819822 local list=TUE_INSTALL_PIP" ${pv} " S
820823 # shellcheck disable=SC2140
821- declare -g " $list " =" $1 ${! list} "
824+ declare -g " $list " =" $name ${! list} "
822825}
823826
824827# Needed for backward compatibility
@@ -848,11 +851,7 @@ function _tue-install-pip-now
848851 # Make sure pip is up-to-date before checking version and installing
849852 local pip_version desired_pip_version
850853 pip_version=$( python" ${pv} " -m pip --version | awk ' {print $2}' )
851- desired_pip_version=" 21"
852- if [ " $pv " == 2 ]
853- then
854- desired_pip_version=" 20"
855- fi
854+ desired_pip_version=" 22"
856855 if version_gt " $desired_pip_version " " $pip_version "
857856 then
858857 tue-install-debug " pip${pv} not yet version >=$desired_pip_version , but $pip_version "
@@ -863,7 +862,9 @@ function _tue-install-pip-now
863862 fi
864863
865864 local pips_to_check=" "
865+ local pips_to_check_w_options=" "
866866 local pips_to_install=" "
867+ local pips_to_install_w_options=" "
867868 local git_pips_to_install=" "
868869 # shellcheck disable=SC2048
869870 for pkg in $*
@@ -872,19 +873,94 @@ function _tue-install-pip-now
872873 then
873874 git_pips_to_install=" $git_pips_to_install $pkg "
874875 else
875- pips_to_check=" $pips_to_check $pkg "
876+ read -r -a pkg_split <<< " ${pkg//^/ }"
877+ if [ ${# pkg_split[@]} -gt 1 ]
878+ then
879+ pips_to_check_w_options=" $pips_to_check_w_options $pkg "
880+ else
881+ pips_to_check=" $pips_to_check $pkg "
882+ fi
876883 fi
877884 done
878885
879- read -r -a pips_to_check <<< " $pips_to_check"
886+ if [ -n " $pips_to_check " ]
887+ then
888+ local indexes_to_install=" "
889+ # shellcheck disable=SC2086
890+ _tue-install-pip-check " $pv " $pips_to_check
891+
892+ read -r -a pips_to_check <<< " $pips_to_check"
893+
894+ for idx in $indexes_to_install
895+ do
896+ local pkg_req=" ${pips_to_check[$idx]} "
897+ tue-install-debug " Going to install $pkg_req "
898+ pips_to_install=" $pips_to_install $pkg_req "
899+ done
900+ fi
901+
902+ if [ -n " $pips_to_check_w_options " ]
903+ then
904+ local indexes_to_install=" "
905+ local pips_to_check_options_removed=" "
906+ for pkg in $pips_to_check_w_options
907+ do
908+ read -r -a pkg_split <<< " ${pkg//^/ }"
909+ pips_to_check_options_removed=" $pips_to_check_options_removed ${pkg_split[0]} "
910+ done
911+ # shellcheck disable=SC2086
912+ _tue-install-pip-check " $pv " $pips_to_check_options_removed
913+
914+ read -r -a pips_to_check_w_options <<< " $pips_to_check_w_options"
915+
916+ for idx in $indexes_to_install
917+ do
918+ local pkg_req=" ${pips_to_check_w_options[$idx]} "
919+ tue-install-debug " Going to install $pkg_req "
920+ pips_to_install_w_options=" $pips_to_install_w_options $pkg_req "
921+ done
922+ fi
923+
924+ if [ -n " $pips_to_install " ]
925+ then
926+ # shellcheck disable=SC2048,SC2086
927+ tue-install-pipe python" ${pv} " -m pip install --user $pips_to_install <<< yes || tue-install-error " An error occurred while installing pip${pv} packages."
928+ fi
929+
930+ if [ -n " $pips_to_install_w_options " ]
931+ then
932+ for pkg in $pips_to_install_w_options
933+ do
934+ # shellcheck disable=SC2048,SC2086
935+ tue-install-pipe python" ${pv} " -m pip install --user ${pkg// ^/ } <<< yes || tue-install-error " An error occurred while installing pip${pv} packages with options."
936+ done
937+ fi
938+
939+ if [ -n " $git_pips_to_install " ]
940+ then
941+ for pkg in $git_pips_to_install
942+ do
943+ # shellcheck disable=SC2048,SC2086
944+ tue-install-pipe python" ${pv} " -m pip install --user $pkg <<< yes || tue-install-error " An error occurred while installing pip${pv} git packages."
945+ done
946+ fi
947+ }
948+
949+ function _tue-install-pip-check
950+ {
951+ tue-install-debug " _tue-install-pip-check $* "
952+ local pv=$1
953+ shift
954+
955+ local pips_to_check=(" $@ " )
880956 local installed_versions
881957 if [ ${# pips_to_check[@]} -gt 0 ]
882958 then
883959 installed_versions=$( python" ${pv} " " $TUE_INSTALL_SCRIPTS_DIR " /check-pip-pkg-installed-version.py " ${pips_to_check[@]} " )
884960 local error_code=$?
885961 if [ " $error_code " -gt 1 ]
886962 then
887- tue-install-error " tue -install-pip${pv} -now : $installed_versions "
963+ tue-install-error " _tue -install-pip${pv} -check : $installed_versions "
888964 fi
889965 fi
890966 read -r -a installed_versions <<< " $installed_versions"
@@ -901,26 +977,11 @@ function _tue-install-pip-now
901977 pkg_installed=" ${pkg_installed// ^/ } "
902978 if [[ " $error_code " -eq 1 && " $pkg_installed " == " None" ]]
903979 then
904- pips_to_install =" $pips_to_install $pkg_req "
980+ indexes_to_install =" $indexes_to_install $idx " # indexes_to_install is a "global" variable from tue-install-pip-now
905981 else
906982 tue-install-debug " $pkg_req is already installed, $pkg_installed "
907983 fi
908984 done
909-
910- if [ -n " $pips_to_install " ]
911- then
912- # shellcheck disable=SC2048,SC2086
913- tue-install-pipe python" ${pv} " -m pip install --user $pips_to_install <<< yes || tue-install-error " An error occurred while installing pip${pv} packages."
914- fi
915-
916- if [ -n " $git_pips_to_install " ]
917- then
918- for pkg in $git_pips_to_install
919- do
920- # shellcheck disable=SC2048,SC2086
921- tue-install-pipe python" ${pv} " -m pip install --user $pkg <<< yes || tue-install-error " An error occurred while installing pip${pv} packages."
922- done
923- fi
924985}
925986
926987# Needed for backward compatibility
0 commit comments