From 1aca7a6adf643afde027778f1acbde7226dcea72 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sat, 14 Aug 2010 00:28:36 +0200 Subject: [PATCH] Ensure that all Python processes use the same version of Python. --- bin/ebuild-helpers/dohtml | 8 +++----- bin/ebuild-helpers/portageq | 8 +++----- bin/ebuild-ipc | 6 ++---- bin/ebuild.sh | 22 ++++++++------------- bin/misc-functions.sh | 8 ++++---- pym/portage/__init__.py | 2 ++ pym/portage/tests/ebuild/test_ipc_daemon.py | 2 ++ 7 files changed, 24 insertions(+), 32 deletions(-) diff --git a/bin/ebuild-helpers/dohtml b/bin/ebuild-helpers/dohtml index e1ab7d970..6de730c6d 100755 --- a/bin/ebuild-helpers/dohtml +++ b/bin/ebuild-helpers/dohtml @@ -1,15 +1,13 @@ #!/bin/bash -# Copyright 2009 Gentoo Foundation +# Copyright 2009-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin} PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym} -# Set EPYTHON variable as empty so that dohtml.py doesn't try -# to use potentially unsupported version of Python. -EPYTHON= PYTHONPATH=$PORTAGE_PYM_PATH${PYTHONPATH:+:}$PYTHONPATH \ - "$PORTAGE_BIN_PATH/dohtml.py" "$@" +PYTHONPATH=$PORTAGE_PYM_PATH${PYTHONPATH:+:}$PYTHONPATH \ + "$PORTAGE_PYTHON" "$PORTAGE_BIN_PATH/dohtml.py" "$@" ret=$? [[ $ret -ne 0 ]] && helpers_die "$0 failed" diff --git a/bin/ebuild-helpers/portageq b/bin/ebuild-helpers/portageq index 3a06fdd68..8dee54c32 100755 --- a/bin/ebuild-helpers/portageq +++ b/bin/ebuild-helpers/portageq @@ -1,10 +1,8 @@ #!/bin/bash -# Copyright 2009 Gentoo Foundation +# Copyright 2009-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin} PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym} -# Set EPYTHON variable as empty so that portageq doesn't try -# to use potentially unsupported version of Python. -EPYTHON= PYTHONPATH=$PORTAGE_PYM_PATH${PYTHONPATH:+:}$PYTHONPATH \ - exec "$PORTAGE_BIN_PATH/portageq" "$@" +PYTHONPATH=$PORTAGE_PYM_PATH${PYTHONPATH:+:}$PYTHONPATH \ + exec "$PORTAGE_PYTHON" "$PORTAGE_BIN_PATH/portageq" "$@" diff --git a/bin/ebuild-ipc b/bin/ebuild-ipc index b828a35cd..45d0f15b8 100755 --- a/bin/ebuild-ipc +++ b/bin/ebuild-ipc @@ -4,7 +4,5 @@ PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin} PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym} -# Set EPYTHON variable as empty so that ebuild-ipc.py doesn't try -# to use potentially unsupported version of Python. -EPYTHON= PYTHONPATH=$PORTAGE_PYM_PATH${PYTHONPATH:+:}$PYTHONPATH \ - exec "$PORTAGE_BIN_PATH/ebuild-ipc.py" "$@" +PYTHONPATH=$PORTAGE_PYM_PATH${PYTHONPATH:+:}$PYTHONPATH \ + exec "$PORTAGE_PYTHON" "$PORTAGE_BIN_PATH/ebuild-ipc.py" "$@" diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 9af7e3867..6a2eeb1e6 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 1999-2009 Gentoo Foundation +# Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 PORTAGE_BIN_PATH="${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}" @@ -164,10 +164,8 @@ has_version() { return $? fi - # Set EPYTHON variable as empty so that portageq doesn't try - # to use potentially unsupported version of Python. - EPYTHON= PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \ - "${PORTAGE_BIN_PATH}"/portageq has_version "${ROOT}" "$1" + PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \ + "$PORTAGE_PYTHON" "${PORTAGE_BIN_PATH}/portageq" has_version "${ROOT}" "$1" local retval=$? case "${retval}" in 0) @@ -187,10 +185,8 @@ portageq() { die "portageq calls are not allowed in the global scope" fi - # Set EPYTHON variable as empty so that portageq doesn't try - # to use potentially unsupported version of Python. - EPYTHON= PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \ - "${PORTAGE_BIN_PATH}/portageq" "$@" + PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \ + "$PORTAGE_PYTHON" "${PORTAGE_BIN_PATH}/portageq" "$@" } @@ -211,10 +207,8 @@ best_version() { return $? fi - # Set EPYTHON variable as empty so that portageq doesn't try - # to use potentially unsupported version of Python. - EPYTHON= PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \ - "${PORTAGE_BIN_PATH}/portageq" 'best_version' "${ROOT}" "$1" + PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \ + "$PORTAGE_PYTHON" "${PORTAGE_BIN_PATH}/portageq" 'best_version' "${ROOT}" "$1" local retval=$? case "${retval}" in 0) @@ -1734,7 +1728,7 @@ filter_readonly_variables() { " fi - EPYTHON= "${PORTAGE_BIN_PATH}"/filter-bash-environment.py "${filtered_vars}" || die "filter-bash-environment.py failed" + "$PORTAGE_PYTHON" "${PORTAGE_BIN_PATH}"/filter-bash-environment.py "${filtered_vars}" || die "filter-bash-environment.py failed" } # @FUNCTION: preprocess_ebuild_env diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index c965495b6..8207006ed 100755 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 1999-2009 Gentoo Foundation +# Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # # Miscellaneous shell functions that make use of the ebuild env but don't need @@ -489,7 +489,7 @@ install_qa_check() { done [[ $reset_debug = 1 ]] && set -x f=$(cat "${PORTAGE_LOG_FILE}" | \ - EPYTHON= "$PORTAGE_BIN_PATH"/check-implicit-pointer-usage.py || die "check-implicit-pointer-usage.py failed") + "$PORTAGE_PYTHON" "$PORTAGE_BIN_PATH"/check-implicit-pointer-usage.py || die "check-implicit-pointer-usage.py failed") if [[ -n ${f} ]] ; then # In the future this will be a forced "die". In preparation, @@ -778,8 +778,8 @@ dyn_package() { tar $tar_options -cf - $PORTAGE_BINPKG_TAR_OPTS -C "${D}" . | \ bzip2 -cf > "$PORTAGE_BINPKG_TMPFILE" assert "failed to pack binary package: '$PORTAGE_BINPKG_TMPFILE'" - EPYTHON= PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \ - "$PORTAGE_BIN_PATH"/xpak-helper.py recompose \ + PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \ + "$PORTAGE_PYTHON" "$PORTAGE_BIN_PATH"/xpak-helper.py recompose \ "$PORTAGE_BINPKG_TMPFILE" "$PORTAGE_BUILDDIR/build-info" if [ $? -ne 0 ]; then rm -f "${PORTAGE_BINPKG_TMPFILE}" diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index a6760b245..fb4c66cb1 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -325,6 +325,8 @@ except (ImportError, OSError) as e: # END OF IMPORTS -- END OF IMPORTS -- END OF IMPORTS -- END OF IMPORTS -- END # =========================================================================== +os.environ['PORTAGE_PYTHON'] = sys.executable + def _ensure_default_encoding(): default_encoding = sys.getdefaultencoding().lower().replace('-', '_') diff --git a/pym/portage/tests/ebuild/test_ipc_daemon.py b/pym/portage/tests/ebuild/test_ipc_daemon.py index de548c6f1..4b7406deb 100644 --- a/pym/portage/tests/ebuild/test_ipc_daemon.py +++ b/pym/portage/tests/ebuild/test_ipc_daemon.py @@ -1,6 +1,7 @@ # Copyright 2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +import os import shutil import tempfile from portage import os @@ -19,6 +20,7 @@ class IpcDaemonTestCase(TestCase): tmpdir = tempfile.mkdtemp() try: env = {} + env['PORTAGE_PYTHON'] = os.environ['PORTAGE_PYTHON'] env['PORTAGE_BIN_PATH'] = PORTAGE_BIN_PATH env['PORTAGE_PYM_PATH'] = PORTAGE_PYM_PATH env['PORTAGE_BUILDDIR'] = tmpdir -- 2.26.2