diff --git a/.ci/ansible_tests.py b/.ci/ansible_tests.py index 4a7bedaeb..785b75604 100755 --- a/.ci/ansible_tests.py +++ b/.ci/ansible_tests.py @@ -79,7 +79,7 @@ def pause_if_interactive(): with ci_lib.Fold('ansible'): playbook = os.environ.get('PLAYBOOK', 'all.yml') try: - ci_lib.run('./run_ansible_playbook.py %s -i "%s" %s', + ci_lib.run('python -b ./run_ansible_playbook.py %s -i "%s" %s', playbook, HOSTS_DIR, ' '.join(sys.argv[1:])) except: pause_if_interactive() diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9a275a00c..75c05df94 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -157,7 +157,7 @@ jobs: exit 1 fi - "$PYTHON" -m tox -e "${{ matrix.tox_env }}" + "$PYTHON" -b -m tox -e "${{ matrix.tox_env }}" macos: # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md @@ -255,7 +255,7 @@ jobs: PYTHON="/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7" fi - "$PYTHON" -m tox -e "${{ matrix.tox_env }}" + "$PYTHON" -b -m tox -e "${{ matrix.tox_env }}" # https://github.com/marketplace/actions/alls-green check: diff --git a/ansible_mitogen/target.py b/ansible_mitogen/target.py index ee4cb398f..4318b234f 100644 --- a/ansible_mitogen/target.py +++ b/ansible_mitogen/target.py @@ -52,6 +52,7 @@ import traceback import types +import mitogen import mitogen.core import mitogen.parent import mitogen.service diff --git a/mitogen/master.py b/mitogen/master.py index 927ccaf11..b1ab68f7f 100644 --- a/mitogen/master.py +++ b/mitogen/master.py @@ -169,8 +169,8 @@ def is_stdlib_path(path): def get_child_modules(path, fullname): """ - Return the suffixes of submodules directly neated beneath of the package - directory at `path`. + Return the suffixes for any direct submodules in package named fullname, + located at path. :param str path: Path to the module's source code on disk, or some PEP-302-recognized @@ -1051,6 +1051,7 @@ def find_related_imports(self, fullname): if sys.modules.get(name) is not None and not is_stdlib_name(name) and u'six.moves' not in name # TODO: crap + and name != u'__main__' ) )) diff --git a/mitogen/parent.py b/mitogen/parent.py index f301a42c5..4e7a48cd8 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -1470,7 +1470,7 @@ def get_boot_command(self): # `import os` here, instead of stage 1, to save a few bytes. # `sys.path=...` for https://github.com/python/cpython/issues/115911. return self.get_python_argv() + [ - '-c', + '-b', '-c', 'import sys;sys.path=[p for p in sys.path if p];import binascii,os,zlib;' 'exec(zlib.decompress(binascii.a2b_base64("%s")))' % (encoded.decode(),), ] diff --git a/run_tests b/run_tests index 75663d15c..9b66e183f 100755 --- a/run_tests +++ b/run_tests @@ -40,7 +40,7 @@ fi --pattern '*_test.py' \ "$@" else - python -m unittest discover \ + python -b -m unittest discover \ --start-directory "tests" \ --pattern '*_test.py' \ "$@" @@ -61,7 +61,7 @@ fi --pattern '*_test.py' \ "$@" else - python -m unittest discover \ + python -b -m unittest discover \ --start-directory "tests/ansible" \ --pattern '*_test.py' \ "$@" diff --git a/tests/ansible/run_ansible_playbook.py b/tests/ansible/run_ansible_playbook.py index 04c0c9db1..63804425a 100755 --- a/tests/ansible/run_ansible_playbook.py +++ b/tests/ansible/run_ansible_playbook.py @@ -43,7 +43,8 @@ if 'ANSIBLE_ARGV' in os.environ: args = eval(os.environ['ANSIBLE_ARGV']) else: - args = ['ansible-playbook'] + bin_dir = os.path.dirname(sys.executable) + args = ['python', '-b', os.path.join(bin_dir, 'ansible-playbook')] args += ['-e', json.dumps(extra)] args += sys.argv[1:] diff --git a/tests/jail_test.py b/tests/jail_test.py index 5c0ad9469..732dbe8fe 100644 --- a/tests/jail_test.py +++ b/tests/jail_test.py @@ -14,10 +14,7 @@ def test_okay(self): stream = self.router.stream_by_id(context.context_id) argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV')) - self.assertEqual(argv[:4], [ - self.jexec_path, - 'somejail', - stream.conn.options.python_path, - '-c', - ]) + + self.assertEqual(argv[:3], [self.jexec_path, 'somejail', stream.conn.options.python_path]) + self.assertEqual(argv[-2], '-c') self.assertEqual('1', context.call(os.getenv, 'THIS_IS_STUB_JEXEC')) diff --git a/tox.ini b/tox.ini index bd2d65e98..26c17e98b 100644 --- a/tox.ini +++ b/tox.ini @@ -91,10 +91,10 @@ install_command = commands_pre = mode_debops_common: {toxinidir}/.ci/debops_common_install.py commands = - mode_ansible: {toxinidir}/.ci/ansible_tests.py + mode_ansible: python -b {toxinidir}/.ci/ansible_tests.py mode_debops_common: {toxinidir}/.ci/debops_common_tests.py - mode_localhost: {toxinidir}/.ci/localhost_ansible_tests.py - mode_mitogen: {toxinidir}/.ci/mitogen_tests.py + mode_localhost: python -b {toxinidir}/.ci/localhost_ansible_tests.py + mode_mitogen: python -b {toxinidir}/.ci/mitogen_tests.py passenv = ANSIBLE_* HOME @@ -106,7 +106,7 @@ setenv = NOCOVERAGE_REPORT = 1 PIP_CONSTRAINT={toxinidir}/tests/constraints.txt # Print warning on the first occurence at each module:linenno in Mitogen. Available Python 2.7, 3.2+. - PYTHONWARNINGS=default:::ansible_mitogen,default:::mitogen + PYTHONWARNINGS=default:::ansible,default:::ansible_mitogen,default:::mitogen # Ansible 6 - 8 (ansible-core 2.13 - 2.15) require Python 2.7 or >= 3.5 on targets ansible6: MITOGEN_TEST_DISTRO_SPECS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004 ansible7: MITOGEN_TEST_DISTRO_SPECS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004