From ac3523132d6d6eee980dfe53bcc6671323a78155 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Thu, 13 Aug 2020 11:46:39 +0100 Subject: [PATCH 1/2] Add troubleshoot test --- cibuildwheel/linux.py | 4 ++-- test/test_troubleshooting.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test/test_troubleshooting.py diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index a328c608..6f4698b5 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -233,7 +233,7 @@ def build(options: BuildOptions) -> None: def troubleshoot(package_dir: Path, error: Exception) -> None: - if (isinstance(error, subprocess.CalledProcessError) and 'exec' in error.cmd): + if (isinstance(error, subprocess.CalledProcessError) and error.cmd[0:2] == ['pip', 'wheel']): # the bash script failed print('Checking for common errors...') so_files = list(package_dir.glob('**/*.so')) @@ -247,7 +247,7 @@ def troubleshoot(package_dir: Path, error: Exception) -> None: If you're using Cython and have previously done an in-place build, remove those build files (*.so and *.c) before starting cibuildwheel. - ''')) + '''), file=sys.stderr) print(' Files detected:') print('\n'.join([f' {f}' for f in so_files])) diff --git a/test/test_troubleshooting.py b/test/test_troubleshooting.py new file mode 100644 index 00000000..3d07dfb5 --- /dev/null +++ b/test/test_troubleshooting.py @@ -0,0 +1,28 @@ +import subprocess +import pytest +from .test_projects import TestProject +from . import utils + +so_file_project = TestProject() + +so_file_project.files['libnothing.so'] = '' + +so_file_project.files['setup.py'] = ''' +raise Exception('this build will fail') +''' + + +def test_failed_project_with_so_files(tmp_path, capfd): + if utils.platform != 'linux': + pytest.skip('this test is only relevant to the linux build') + + project_dir = tmp_path / 'project' + so_file_project.generate(project_dir) + + with pytest.raises(subprocess.CalledProcessError): + utils.cibuildwheel_run(project_dir) + + captured = capfd.readouterr() + print('out', captured.out) + print('err', captured.err) + assert "NOTE: Shared object (.so) files found in this project." in captured.err From f19c6065738d35601137da3b2aa3769bcc8e7989 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Thu, 13 Aug 2020 11:50:17 +0100 Subject: [PATCH 2/2] Fix comment --- cibuildwheel/linux.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 6f4698b5..bb80fda8 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -234,7 +234,7 @@ def build(options: BuildOptions) -> None: def troubleshoot(package_dir: Path, error: Exception) -> None: if (isinstance(error, subprocess.CalledProcessError) and error.cmd[0:2] == ['pip', 'wheel']): - # the bash script failed + # the 'pip wheel' step failed. print('Checking for common errors...') so_files = list(package_dir.glob('**/*.so'))