From cc0e7ec0a1020a9adb41fa2c33663731f078b075 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 22 Jan 2021 08:54:19 -0500 Subject: [PATCH] fix: review from @joerick --- cibuildwheel/__main__.py | 10 +++++----- test/test_cpp_standards.py | 2 +- test/utils.py | 7 ++++--- unit_test/main_tests/main_platform_test.py | 6 ------ 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index bcdfef8c..538d56f1 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -257,6 +257,11 @@ def main() -> None: print_preamble(platform, build_options) + if not identifiers: + print(f'cibuildwheel: No build identifiers selected: {build_selector}', file=sys.stderr) + if not args.allow_empty: + sys.exit(3) + if not output_dir.exists(): output_dir.mkdir(parents=True) @@ -269,11 +274,6 @@ def main() -> None: else: assert_never(platform) - if not identifiers: - print(f'cibuildwheel: No build identifiers selected: {build_selector}', file=sys.stderr) - if not args.allow_empty: - sys.exit(3) - def detect_obsolete_options() -> None: # Check the old 'MANYLINUX1_*_IMAGE' options diff --git a/test/test_cpp_standards.py b/test/test_cpp_standards.py index 8ab5becd..762414bf 100644 --- a/test/test_cpp_standards.py +++ b/test/test_cpp_standards.py @@ -202,7 +202,7 @@ def test_cpp17_py27_modern_msvc_workaround(tmp_path): add_env_x64['CIBW_BUILD'] = 'cp27-win_amd64' actual_wheels += utils.cibuildwheel_run(project_dir, add_env=add_env_x64) - expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0', filter_27=False) + expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0', exclude_27=False) if 'cp27-cp27m-win' in w or 'pp27-pypy_73-win32' in w] diff --git a/test/utils.py b/test/utils.py index 4fcdba47..8b11a0e6 100644 --- a/test/utils.py +++ b/test/utils.py @@ -77,7 +77,7 @@ def cibuildwheel_run(project_path, package_dir='.', env=None, add_env=None, outp def expected_wheels(package_name, package_version, manylinux_versions=None, macosx_deployment_target='10.9', machine_arch=None, *, - filter_27=IS_WINDOWS_RUNNING_ON_TRAVIS): + exclude_27=IS_WINDOWS_RUNNING_ON_TRAVIS): ''' Returns a list of expected wheels from a run of cibuildwheel. ''' @@ -135,8 +135,9 @@ def expected_wheels(package_name, package_version, manylinux_versions=None, for platform_tag in platform_tags: wheels.append(f'{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl') - if filter_27: - # Python 2.7 isn't supported on Travis. + # Travis on Windows does not support using the default Python 2.7 compiler, + # so we support skipping here. + if exclude_27: wheels = [w for w in wheels if '-cp27-' not in w and '-pp2' not in w] return wheels diff --git a/unit_test/main_tests/main_platform_test.py b/unit_test/main_tests/main_platform_test.py index 844cf811..aa004c5c 100644 --- a/unit_test/main_tests/main_platform_test.py +++ b/unit_test/main_tests/main_platform_test.py @@ -1,4 +1,3 @@ -import platform as platform_module import sys import pytest @@ -68,7 +67,6 @@ def test_platform_environment(platform, intercepted_build_args, monkeypatch): def test_archs_default(platform, intercepted_build_args, monkeypatch): - monkeypatch.setattr(platform_module, 'machine', lambda: 'AMD64' if platform == 'windows' else 'x86_64') main() build_options = intercepted_build_args.args[0] @@ -86,7 +84,6 @@ def test_archs_argument(platform, intercepted_build_args, monkeypatch, use_env_v if platform == 'windows': pytest.skip('Will have empty build selectors on Windows') - monkeypatch.setattr(platform_module, 'machine', lambda: 'x86_64') if use_env_var: monkeypatch.setenv('CIBW_ARCHS', 'ppc64le') else: @@ -100,7 +97,6 @@ def test_archs_argument(platform, intercepted_build_args, monkeypatch, use_env_v def test_archs_platform_specific(platform, intercepted_build_args, monkeypatch): - monkeypatch.setattr(platform_module, 'machine', lambda: 'x86_64') monkeypatch.setenv('CIBW_ARCHS', 'unused') monkeypatch.setenv('CIBW_ARCHS_LINUX', 'ppc64le') monkeypatch.setenv('CIBW_ARCHS_WINDOWS', 'x86') @@ -118,7 +114,6 @@ def test_archs_platform_specific(platform, intercepted_build_args, monkeypatch): def test_archs_platform_native(platform, intercepted_build_args, monkeypatch): - monkeypatch.setattr(platform_module, 'machine', lambda: 'AMD64' if platform == 'windows' else 'x86_64') monkeypatch.setenv('CIBW_ARCHS', 'native') main() @@ -133,7 +128,6 @@ def test_archs_platform_native(platform, intercepted_build_args, monkeypatch): def test_archs_platform_all(platform, intercepted_build_args, monkeypatch): - monkeypatch.setattr(platform_module, 'machine', lambda: 'x86_64') monkeypatch.setenv('CIBW_ARCHS', 'all') main()