From 1270a904de996b7c0477179002e4f822bcf2f817 Mon Sep 17 00:00:00 2001 From: Andy Neff Date: Mon, 18 Nov 2024 19:05:27 -0500 Subject: [PATCH] Add ability to get latest version of minor Signed-off-by: Andy Neff --- linux/just_files/just_install_functions.bsh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/linux/just_files/just_install_functions.bsh b/linux/just_files/just_install_functions.bsh index 46d988fa..3afcf1e1 100644 --- a/linux/just_files/just_install_functions.bsh +++ b/linux/just_files/just_install_functions.bsh @@ -289,7 +289,7 @@ function conda-install() # install conda bash "${CONDA_INSTALLER}" -b -p "${conda_dir}" -s - # Conda installer doesn't support spacer, PERIOD! + # Conda installer doesn't support spaces, PERIOD! # ERROR: Cannot install into directories with spaces # conda executable @@ -351,7 +351,7 @@ function conda-install() # * else: system level conda if available, then temporary miniconda3 download # # :Arguments: * [``--dir {dir}``] - Python install directory -# * [``--version {version}``] - Python version for install (default= ``${PYTHON_VERSION:-3.6.9}``) +# * [``--version {version}``] - Python version for install (default= ``${PYTHON_VERSION:-3.6.9}``). Specifying ``3.x`` will auto select the latest in the 3.x versions. # * [``--conda {CONDA}``] - Conda executable # * [``--conda-installer {INSTALLER}``] - Conda installer # * [``--download``] - Download miniconda @@ -385,6 +385,14 @@ function conda-python-install() --list list_versions \ -- ${@+"${@}"} + local minor_version_pattern='^([0-9]+)\.([0-9]+)$' + local install_version="==${python_ver}" + local check_version=("${install_version}") + if [[ ${python_ver} =~ ${minor_version_pattern} ]]; then + check_version=(">=${BASH_REMATCH[0]}" "<${BASH_REMATCH[1]}.$((${BASH_REMATCH[2]}+1))") + install_version="${check_version[0]},${check_version[1]}" + fi + if [ "${list_versions}" != "0" ]; then # This has worked since at least 2016, so fairly stable download_to_stdout https://anaconda.org/anaconda/python/files | sed -n${sed_flag_rE} 's|^ *|\1|p' @@ -439,7 +447,7 @@ function conda-python-install() if [ -r "${conda_activate-}" ]; then source "${conda_activate}" fi - "${CONDA}" create -y -p "${python_dir}" "python==${python_ver}" ${packages[@]+"${packages[@]}"} + "${CONDA}" create -y -p "${python_dir}" "python${install_version}" ${packages[@]+"${packages[@]}"} ) local python_exe_footer if [ "${OS-}" = "Windows_NT" ]; then @@ -460,7 +468,7 @@ function conda-python-install() echo "Python ${python_version} installed at \"${python_exe}\"" >&2 # Make sure python meets request - if ! meet_requirements "${python_version}" "==${python_ver}"; then + if ! meet_requirements "${python_version}" "${check_version[@]}"; then echo "Python version ${python_version} is not the requested version ${python_ver}" >&2 JUST_IGNORE_EXIT_CODES=1 return 1