From 204f96e1efde63a5ba8f9e26aa00e5810b1a64bf Mon Sep 17 00:00:00 2001 From: Monty Taylor <mordred@inaugust.com> Date: Tue, 26 Sep 2017 16:16:33 -0500 Subject: [PATCH] Handle projects without setup.py or valid setup.cfg project-config has tox jobs but does not have a setup.py. This confuses the siblings code. First - check for a setup.cfg and if one is not there just give up. Second - we switched to just reading setup.cfg in the other part of the module. Do that for determining package name as well. Change-Id: I1f33261871791863e77789b522fc6f7db3f3cdbb --- .../library/tox_install_sibling_packages.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/roles/tox-siblings/library/tox_install_sibling_packages.py b/roles/tox-siblings/library/tox_install_sibling_packages.py index 9b2084c99..1b9df5689 100644 --- a/roles/tox-siblings/library/tox_install_sibling_packages.py +++ b/roles/tox-siblings/library/tox_install_sibling_packages.py @@ -100,15 +100,23 @@ def main(): project_dir = module.params['project_dir'] projects = module.params['projects'] + if not os.path.exists(os.path.join(project_dir, 'setup.cfg')): + module.exit_json(changed=False, msg="No setup.cfg, no action needed") + + # Who are we? + try: + c = configparser.ConfigParser() + c.read(os.path.join(project_dir, 'setup.cfg')) + package_name = c.get('metadata', 'name') + except Exception: + module.exit_json( + changed=False, msg="No name in setup.cfg, skipping siblings") + tox_python = '{project_dir}/.tox/{envlist}/bin/python'.format( project_dir=project_dir, envlist=envlist) # Write a log file into the .tox dir so that it'll get picked up log_file = '{project_dir}/.tox/{envlist}/log/siblings.txt'.format( project_dir=project_dir, envlist=envlist) - # Who are we? - package_name = subprocess.check_output( - ['.tox/{envlist}/bin/python'.format(envlist=envlist), - 'setup.py', '--name'], cwd=project_dir).strip() log = list() log.append(