Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pip 24.1 or higher compatible #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,16 @@ get_package_versions() {
{ [ "${pip_version_major}" -eq 20 ] && [ "${pip_version_minor}" -ge 3 ]; }; then
pip_install_args+=("--use-deprecated=legacy-resolver")
fi
version_output_raw=$("${ASDF_PYAPP_RESOLVED_PYTHON_PATH}" -m pip install ${pip_install_args[@]+"${pip_install_args[@]}"} "${package}==" 2>&1) || true

local regex='.*from versions:(.*)\)'
local regex
if [ "${pip_version_major}" -ge 24 ] && [ "${pip_version_minor}" -ge 1 ]; then
version_output_raw=$("${ASDF_PYAPP_RESOLVED_PYTHON_PATH}" -m pip index versions ${pip_install_args[@]+"${pip_install_args[@]}"} "${package}" 2>&1) || true
regex='.*Available versions:(.*)'
else
version_output_raw=$("${ASDF_PYAPP_RESOLVED_PYTHON_PATH}" -m pip install ${pip_install_args[@]+"${pip_install_args[@]}"} "${package}==" 2>&1) || true
regex='.*from versions:(.*)\)'
fi

if [[ $version_output_raw =~ $regex ]]; then
local version_substring="${BASH_REMATCH[1]//','/}"
# trim whitespace with 'xargs echo' and convert spaces to newlines with 'tr'
Expand Down