Hari Sekhon 4 years ago
commit 1152d2f83b

@ -44,17 +44,24 @@ if false; then
fi
fi
# shellcheck disable=SC2034
python="${PYTHON:-python}"
#if command -v pip >/dev/null 2>&1; then
python="$(command -v "$python" || command -v "python3" || command -v "python2" || :)"
# shellcheck disable=SC2181
if [ $? != 0 ]; then
echo "ERROR: 'command -v $python' failed" >&2
exit 1
if [ -n "${PYTHON:-}" ]; then
python="$PYTHON"
else
#python="$(command -v "$python" || command -v "python3" || command -v "python2" || :)"
python="$(command -v python 2>/dev/null || :)"
python2="$(command -v python2 2>/dev/null || :)"
python3="$(command -v python3 2>/dev/null || :)"
if [ -z "$python" ]; then
if [ -n "$python3" ]; then
python="$python3"
elif [ -n "$python2" ]; then
python="$python2"
else
echo "ERROR: 'command -v python' failed to find python" >&2
exit 1
fi
fi
#fi
fi
if [ -n "${PIP:-}" ]; then
pip="$PIP"
@ -125,30 +132,40 @@ pip_python_version="$(echo "$pip_python_version" | grep -Eom1 '\(python [[:digit
export pip_python_major_version="${pip_python_version%%.*}"
set -eo pipefail
if [ -n "${python_version:-}" ] &&
[ -n "${pip_python_version:-}" ]; then
if [ "$python_version" != "$pip_python_version" ]; then
if [ "${python_version:0:1}" = 3 ] &&
[ -n "$pip3" ]; then
pip="$pip3"
elif [ "${python_version:0:1}" = 2 ] &&
[ -n "$pip2" ]; then
pip="$pip2"
else
echo
echo "Python major version '$python_version' != Pip major version '$pip_python_version' !!"
echo
echo "python = $python"
echo "pip = $pip"
echo
echo "Python PyPI modules will not be installed to the correct site-packages and will lead to import failures later on"
echo
echo "Fix your \$PATH or \$PYTHON / \$PIP to be aligned to the same installation"
echo
exit 1
check_python_pip_versions_match(){
if [ -n "${python_version:-}" ] &&
[ -n "${pip_python_version:-}" ]; then
if [ "$python_version" != "$pip_python_version" ]; then
if [ "${python_version:0:1}" = 3 ] &&
[ -n "$pip3" ]; then
pip="$pip3"
check_python_pip_versions_match
elif [ "${python_version:0:1}" = 2 ] &&
[ -n "$pip2" ]; then
pip="$pip2"
check_python_pip_versions_match
elif [ "${python_version:0:1}" = 2 ] &&
[ -n "$python3" ]; then
python="$python3"
check_python_pip_versions_match
else
echo
echo "Python major version '$python_version' != Pip major version '$pip_python_version' !!"
echo
echo "python = $python"
echo "pip = $pip"
echo
echo "Python PyPI modules will not be installed to the correct site-packages and will lead to import failures later on"
echo
echo "Fix your \$PATH or \$PYTHON / \$PIP to be aligned to the same installation"
echo
exit 1
fi
fi
fi
fi
}
check_python_pip_versions_match
inside_virtualenv(){
if [ -n "${VIRTUAL_ENV:-}" ] ||

@ -0,0 +1,29 @@
#
# Author: Hari Sekhon
# Date: 2019-03-16 20:35:14 +0000 (Sat, 16 Mar 2019)
#
# https://github.com/harisekhon/devops-bash-tools
#
# License: see accompanying LICENSE file
#
# https://www.linkedin.com/in/harisekhon
#
# ============================================================================ #
# Alpine Package Requirements
# ============================================================================ #
# Packages that don't error if failing to install
# Python is a mess and breaks with this on latest Alpine 3, so do as best effort
#
# python (missing):
# ERROR: unsatisfiable constraints:
# required by: world[python]
python
python2
python3
py-pip
py2-pip
py3-pip

@ -26,10 +26,16 @@ make
parallel
perl
perl-app-cpanminus
python
py-pip
ruby-dev # to build Travis CI gem
wget
which
zip
unzip
# causes errors now so moved to apk-packages-optional.txt to allow failures
#
# python (missing):
# ERROR: unsatisfiable constraints:
# required by: world[python]
#python
#py-pip

@ -80,8 +80,8 @@ if [ -n "${NO_FAIL:-}" ]; then
packages="$packages
$(sed 's/^python-/python2-/' <<< "$packages")
$(sed 's/^python-/python3-/' <<< "$packages")
$(sed '/^python[23]*-/d; s/^/python2-/' <<< "$packages")
$(sed '/^python[23]*-/d; s/^/python3-/' <<< "$packages")"
$(sed 's/^python[23]-/python2-/' <<< "$packages")
$(sed 's/^python[23]-/python3-/' <<< "$packages")"
echo "Expanding Python packages out to: $packages"
fi
fi

Loading…
Cancel
Save