From b7bc7fc59c1377337ab1cf1df72d417d66b72302 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Mon, 16 Aug 2010 21:22:14 +0200 Subject: [PATCH] Expand sys.executable earlier, so that change of sys.executable symlink between starting main Portage process and starting ebuild.sh process doesn't affect ebuild.sh subprocesses. --- pym/portage/__init__.py | 2 ++ pym/portage/package/ebuild/doebuild.py | 2 +- pym/portage/tests/ebuild/test_doebuild_spawn.py | 3 ++- pym/portage/tests/ebuild/test_ipc_daemon.py | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index a6534b12d..b2cbc0f0e 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 # =========================================================================== +_python_interpreter = os.path.realpath(sys.executable) + def _ensure_default_encoding(): default_encoding = sys.getdefaultencoding().lower().replace('-', '_') diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index 0b580e6d5..2451cea19 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -105,7 +105,7 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, mysettings["PORTAGE_MASTER_PID"] = str(os.getpid()) # Set requested Python interpreter for Portage helpers. - mysettings['PORTAGE_PYTHON'] = os.path.realpath(sys.executable) + mysettings['PORTAGE_PYTHON'] = portage._python_interpreter # We are disabling user-specific bashrc files. mysettings["BASH_ENV"] = INVALID_ENV_FILE diff --git a/pym/portage/tests/ebuild/test_doebuild_spawn.py b/pym/portage/tests/ebuild/test_doebuild_spawn.py index 8d40bf7ea..6e5c28a36 100644 --- a/pym/portage/tests/ebuild/test_doebuild_spawn.py +++ b/pym/portage/tests/ebuild/test_doebuild_spawn.py @@ -3,6 +3,7 @@ import sys from portage import os +from portage import _python_interpreter from portage import _shell_quote from portage.const import EBUILD_SH_BINARY from portage.package.ebuild.config import config @@ -40,7 +41,7 @@ class DoebuildSpawnTestCase(TestCase): metadata=metadata, root_config=root_config, type_name='ebuild') settings.setcpv(pkg) - settings['PORTAGE_PYTHON'] = os.path.realpath(sys.executable) + settings['PORTAGE_PYTHON'] = _python_interpreter settings['PORTAGE_BUILDDIR'] = os.path.join( settings['PORTAGE_TMPDIR'], cpv) settings['T'] = os.path.join( diff --git a/pym/portage/tests/ebuild/test_ipc_daemon.py b/pym/portage/tests/ebuild/test_ipc_daemon.py index a17760394..0a9a9a929 100644 --- a/pym/portage/tests/ebuild/test_ipc_daemon.py +++ b/pym/portage/tests/ebuild/test_ipc_daemon.py @@ -1,10 +1,10 @@ # Copyright 2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -import sys import shutil import tempfile from portage import os +from portage import _python_interpreter from portage.tests import TestCase from portage.const import PORTAGE_BIN_PATH from portage.const import PORTAGE_PYM_PATH @@ -28,7 +28,7 @@ class IpcDaemonTestCase(TestCase): if 'PORTAGE_GRPNAME' in os.environ: env['PORTAGE_GRPNAME'] = os.environ['PORTAGE_GRPNAME'] - env['PORTAGE_PYTHON'] = os.path.realpath(sys.executable) + env['PORTAGE_PYTHON'] = _python_interpreter env['PORTAGE_BIN_PATH'] = PORTAGE_BIN_PATH env['PORTAGE_PYM_PATH'] = PORTAGE_PYM_PATH env['PORTAGE_BUILDDIR'] = tmpdir -- 2.26.2