From 63992be26c441f0a4c494761595ff1c4ce3d6822 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 3 Feb 2020 17:21:30 +0000 Subject: [PATCH] Fedora stable installs are Py3 only --- bootstrap-salt.sh | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index c56c3a8..e9bcc07 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -3770,13 +3770,14 @@ install_fedora_deps() { fi __PACKAGES="${__PACKAGES:=}" - if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then - # Packages are named python3- - PY_PKG_VER=3 - else - PY_PKG_VER=2 + if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -lt 3 ]; then + echoerror "There are no Python 2 stable packages for Fedora, only Py3 packages" + return 1 fi + # Salt on Fedora is Py3 + PY_PKG_VER=3 + __PACKAGES="${__PACKAGES} dnf-utils libyaml procps-ng python${PY_PKG_VER}-crypto python${PY_PKG_VER}-jinja2" __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-msgpack python${PY_PKG_VER}-requests python${PY_PKG_VER}-zmq" __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-pip python${PY_PKG_VER}-m2crypto python${PY_PKG_VER}-pyyaml" @@ -3810,31 +3811,27 @@ install_fedora_stable() { # shellcheck disable=SC2086 __dnf_install_noinput ${__PACKAGES} || return 1 - if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then - if __check_command_exists python3; then - __python="python3" - fi - elif [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 2 ]; then - if __check_command_exists python2; then - __python="python2" - fi - else - if ! __check_command_exists python; then - echoerror "Unable to find a python binary?!" - return 1 - fi - # Let's hope it's the right one - __python="python" + __python="python3" + if ! __check_command_exists python3; then + echoerror "Could not find a python3 binary?!" + return 1 fi if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then __check_pip_allowed "You need to allow pip based installations (-P) for Tornado <5.0 in order to install Salt" __installed_tornado_rpm=$(rpm -qa | grep python${PY_PKG_VER}-tornado) if [ -n "${__installed_tornado_rpm}" ]; then + echodebug "Removing system package ${__installed_tornado_rpm}" rpm -e --nodeps "${__installed_tornado_rpm}" || return 1 fi - echodebug "Running '${__python}' -m pip install 'tornado<5.0'" - "${__python}" -m pip install --target /usr/lib/python3.7/site-packages "tornado<5" || return 1 + __get_site_packages_dir_code=$(cat << EOM +import site +print([d for d in site.getsitepackages() if d.startswith('/usr/lib/python')][0]) +EOM +) + __target_path=$(${__python} -c "${__get_site_packages_dir_code}") + echodebug "Running '${__python}' -m pip install --target ${__target_path} 'tornado<5.0'" + "${__python}" -m pip install --target "${__target_path}" "tornado<5" || return 1 fi return 0