From 69e1d8452523e5a914685892985569bffc305697 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 14 Jun 2019 13:07:49 +0100 Subject: [PATCH 1/3] Workaround nox's install only flag To get some information from the system, which we then use to choose the appropriate static requirements file, we need to run some commands, something that nox will refuse to do if `--install-only` is passed. We work around it by manually patching the value of `session._runner.global_config.install_only` for the commands that we MUST run, and only those and then we set it back to the value it had before. For additional information about why we have to do this, please see: https://github.com/theacodes/nox/pull/181 --- noxfile.py | 66 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/noxfile.py b/noxfile.py index f4d954b8cc..17026fef47 100644 --- a/noxfile.py +++ b/noxfile.py @@ -57,15 +57,22 @@ def _get_session_python_version_info(session): try: version_info = session._runner._real_python_version_info except AttributeError: - session_py_version = session.run( - 'python', '-c' - 'import sys; sys.stdout.write("{}.{}.{}".format(*sys.version_info))', - silent=True, - log=False, - bypass_install_only=True - ) - version_info = tuple(int(part) for part in session_py_version.split('.') if part.isdigit()) - session._runner._real_python_version_info = version_info + old_install_only_value = session._runner.global_config.install_only + try: + # Force install only to be false for the following chunk of code + # For additional information as to why see: + # https://github.com/theacodes/nox/pull/181 + session._runner.global_config.install_only = False + session_py_version = session.run( + 'python', '-c' + 'import sys; sys.stdout.write("{}.{}.{}".format(*sys.version_info))', + silent=True, + log=False, + ) + version_info = tuple(int(part) for part in session_py_version.split('.') if part.isdigit()) + session._runner._real_python_version_info = version_info + finally: + session._runner.global_config.install_only = old_install_only_value return version_info @@ -73,14 +80,21 @@ def _get_session_python_site_packages_dir(session): try: site_packages_dir = session._runner._site_packages_dir except AttributeError: - site_packages_dir = session.run( - 'python', '-c' - 'import sys; from distutils.sysconfig import get_python_lib; sys.stdout.write(get_python_lib())', - silent=True, - log=False, - bypass_install_only=True - ) - session._runner._site_packages_dir = site_packages_dir + old_install_only_value = session._runner.global_config.install_only + try: + # Force install only to be false for the following chunk of code + # For additional information as to why see: + # https://github.com/theacodes/nox/pull/181 + session._runner.global_config.install_only = False + site_packages_dir = session.run( + 'python', '-c' + 'import sys; from distutils.sysconfig import get_python_lib; sys.stdout.write(get_python_lib())', + silent=True, + log=False, + ) + session._runner._site_packages_dir = site_packages_dir + finally: + session._runner.global_config.install_only = old_install_only_value return site_packages_dir @@ -96,11 +110,19 @@ def _get_distro_info(session): distro = session._runner._distro except AttributeError: # The distro package doesn't output anything for Windows - session.install('--progress-bar=off', 'distro', silent=PIP_INSTALL_SILENT) - output = session.run('distro', '-j', silent=True, bypass_install_only=True) - distro = json.loads(output.strip()) - session.log('Distro information:\n%s', pprint.pformat(distro)) - session._runner._distro = distro + old_install_only_value = session._runner.global_config.install_only + try: + # Force install only to be false for the following chunk of code + # For additional information as to why see: + # https://github.com/theacodes/nox/pull/181 + session._runner.global_config.install_only = False + session.install('--progress-bar=off', 'distro', silent=PIP_INSTALL_SILENT) + output = session.run('distro', '-j', silent=True) + distro = json.loads(output.strip()) + session.log('Distro information:\n%s', pprint.pformat(distro)) + session._runner._distro = distro + finally: + session._runner.global_config.install_only = old_install_only_value return distro From f442b338b187cef2696dd47e1014704210f3d78d Mon Sep 17 00:00:00 2001 From: Ch3LL Date: Tue, 18 Jun 2019 09:51:50 -0400 Subject: [PATCH 2/3] Revert "Enable logging for test runs on py3" This reverts commit 9339425dba3a3aab7510c236805d3b30fd0d1b7f. --- tests/integration/files/log_handlers/runtests_log_handler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/files/log_handlers/runtests_log_handler.py b/tests/integration/files/log_handlers/runtests_log_handler.py index b208a6e226..94f976e0a6 100644 --- a/tests/integration/files/log_handlers/runtests_log_handler.py +++ b/tests/integration/files/log_handlers/runtests_log_handler.py @@ -34,6 +34,8 @@ __virtualname__ = 'runtests_log_handler' def __virtual__(): if 'runtests_log_port' not in __opts__: return False, "'runtests_log_port' not in options" + if six.PY3: + return False, "runtests external logging handler is temporarily disabled for Python 3 tests" return True From 8c8f0ac0e481fa0d580b09c0c3d09c15033d5d3c Mon Sep 17 00:00:00 2001 From: Ch3LL Date: Tue, 18 Jun 2019 09:55:44 -0400 Subject: [PATCH 3/3] import six runtests log handler --- tests/integration/files/log_handlers/runtests_log_handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/files/log_handlers/runtests_log_handler.py b/tests/integration/files/log_handlers/runtests_log_handler.py index 94f976e0a6..9b8e82cfb9 100644 --- a/tests/integration/files/log_handlers/runtests_log_handler.py +++ b/tests/integration/files/log_handlers/runtests_log_handler.py @@ -23,6 +23,7 @@ from multiprocessing import Queue import msgpack # Import Salt libs +from salt.ext import six from salt.utils.platform import is_darwin import salt.log.setup