@@ -22,19 +22,15 @@ for ((i=0; i<rows; i++)); do
2222done
2323
2424for (( i= 0 ; i< rows; i++ )) ; do
25- CURRENT_VERSION=$( pip show " ${packages_array[$i,0]} " | grep ' ^Version:' | awk ' {print $2}' )
26- if [[ -z " $CURRENT_VERSION " ]]; then
27- echo " No version for ${packages_array[$i,0]} found in upstream i.e. base image."
28- CURRENT_VERSION=" 0"
29- fi
25+ CURRENT_VERSION=$( pip show " ${packages_array[$i,0]} " --disable-pip-version-check | grep ' ^Version:' | awk ' {print $2}' )
3026 REQUIRED_VERSION=" ${packages_array[$i,1]} "
3127 GREATER_VERSION_A=$(( echo ${REQUIRED_VERSION} ; echo ${CURRENT_VERSION} ) | sort - V | tail - 1 )
3228 # Check if the required_version is greater than current_version
3329 if [[ $CURRENT_VERSION != $GREATER_VERSION_A ]]; then
3430 echo "${packages_array[$i,0]} version v${CURRENT_VERSION} installed by the base image is not greater or equal to the required: v${REQUIRED_VERSION} "
3531 # Check whether conda channel has a greater or equal version available, so install from conda, otherwise use pip package manager
3632 channel_name="anaconda"
37- CONDA_VERSION=$(conda search "${packages_array[$i,0]} " - c "$channel_name " | \
33+ CONDA_VERSION=$(conda search --override-channels "${packages_array[$i,0]} " - c "$channel_name " | \
3834 grep -E '^[[:alnum:]]' | \
3935 awk '{print $2 }' | \
4036 sort -V | \
@@ -47,13 +43,13 @@ for ((i=0; i<rows; i++)); do
4743 fi
4844 GREATER_VERSION_B=$((echo ${REQUIRED_VERSION} ; echo ${CONDA_VERSION} ) | sort - V | tail - 1 )
4945 if [[ $CONDA_VERSION == $GREATER_VERSION_B ]]; then
50- echo -e "Conda Version: ${CONDA_VERSION} is greater than or equal to the required version: ${REQUIRED_VERSION} . \n";
51- echo "Installing ${packages_array[$i,0]} from source from conda channel for ${REQUIRED_VERSION} ..."
46+ echo -e "Found Version v ${CONDA_VERSION} in the Conda channel which is greater than or equal to the required version: v ${REQUIRED_VERSION} . \n";
47+ echo "Installing ${packages_array[$i,0]} from source from conda channel for v ${REQUIRED_VERSION} ..."
5248 conda install "${packages_array[$i,0]} == ${CONDA_VERSION} "
5349 elif [[ $REQUIRED_VERSION == $GREATER_VERSION_B ]]; then
54- echo -e "Required version: ${REQUIRED_VERSION} is greater than the conda version: ${CONDA_VERSION} . \n";
55- echo "Installing ${packages_array[$i,0]} from source from pip package manager for ${REQUIRED_VERSION} ..."
56- python3 -m pip install --upgrade "${packages_array[$i,0]} == ${REQUIRED_VERSION} "
50+ echo -e "Required version: v ${REQUIRED_VERSION} is greater than the version found in the Conda channel v ${CONDA_VERSION} . \n";
51+ echo "Installing ${packages_array[$i,0]} from source from pip package manager for v ${REQUIRED_VERSION} ..."
52+ python3 -m pip install --upgrade --no-cache-dir "${packages_array[$i,0]} == ${REQUIRED_VERSION} "
5753 fi
5854 fi
5955done
0 commit comments