From 0124d174bee508fa1982d5e42ec331e4288acc22 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 2 Feb 2020 14:33:36 +0000 Subject: [PATCH] Raise a warning if .so files were found in a project that fails to build Fix #139 --- cibuildwheel/linux.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index eb420516..30841794 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -1,5 +1,5 @@ from __future__ import print_function -import os, subprocess, sys, uuid +import os, subprocess, sys, uuid, textwrap from collections import namedtuple from .util import prepare_command, get_build_verbosity_extra_flags @@ -173,8 +173,36 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef run_docker(['cp', os.path.abspath(project_dir) + '/.', container_name + ':/project']) run_docker(['start', '-i', '-a', container_name], stdin_str=bash_script) run_docker(['cp', container_name + ':/output/.', os.path.abspath(output_dir)]) - except subprocess.CalledProcessError: + except subprocess.CalledProcessError as error: + troubleshoot(project_dir, error) exit(1) finally: # Still gets executed, even when 'exit(1)' gets called run_docker(['rm', '--force', '-v', container_name]) + + +def troubleshoot(project_dir, error): + if (isinstance(error, subprocess.CalledProcessError) and 'start' in error.cmd): + # the bash script failed + print('Checking for common errors...') + so_files = [] + for root, dirs, files in os.walk(project_dir): + for name in files: + _, ext = os.path.splitext(name) + if ext == '.so': + so_files.append(os.path.join(root, name)) + + if so_files: + print(textwrap.dedent(''' + NOTE: Shared object (.so) files found in this project. + + These files might be built against the wrong OS, causing problems with + auditwheel. + + If you're using Cython and have previously done an in-place build, + remove those build files (*.so and *.c) before starting cibuildwheel. + ''')) + + print(' Files detected:') + print('\n'.join([' '+f for f in so_files])) + print('')