Merge remote-tracking branch 'origin/master' into macos-universal2
# Conflicts: # bin/sample_build.py # cibuildwheel/__main__.py # cibuildwheel/macos.py # cibuildwheel/util.py # cibuildwheel/windows.py
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import platform as platform_module
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -51,14 +52,27 @@ def fake_package_dir(monkeypatch):
|
||||
else:
|
||||
return real_path_exists(path)
|
||||
|
||||
args = ['cibuildwheel', str(MOCK_PACKAGE_DIR)]
|
||||
monkeypatch.setattr(Path, 'exists', mock_path_exists)
|
||||
monkeypatch.setattr(sys, 'argv', ['cibuildwheel', str(MOCK_PACKAGE_DIR)])
|
||||
monkeypatch.setattr(sys, 'argv', args)
|
||||
return args
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def allow_empty(request, monkeypatch, fake_package_dir):
|
||||
monkeypatch.setattr(sys, 'argv', fake_package_dir + ['--allow-empty'])
|
||||
|
||||
|
||||
@pytest.fixture(params=['linux', 'macos', 'windows'])
|
||||
def platform(request, monkeypatch):
|
||||
platform_value = request.param
|
||||
monkeypatch.setenv('CIBW_PLATFORM', platform_value)
|
||||
|
||||
if platform_value == 'windows':
|
||||
monkeypatch.setattr(platform_module, 'machine', lambda: 'AMD64')
|
||||
else:
|
||||
monkeypatch.setattr(platform_module, 'machine', lambda: 'x86_64')
|
||||
|
||||
return platform_value
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ def test_output_dir_argument(also_set_environment, platform, intercepted_build_a
|
||||
assert intercepted_build_args.args[0].output_dir == OUTPUT_DIR
|
||||
|
||||
|
||||
def test_build_selector(platform, intercepted_build_args, monkeypatch):
|
||||
def test_build_selector(platform, intercepted_build_args, monkeypatch, allow_empty):
|
||||
BUILD = 'some build* *-selector'
|
||||
SKIP = 'some skip* *-selector'
|
||||
|
||||
@@ -57,6 +57,15 @@ def test_build_selector(platform, intercepted_build_args, monkeypatch):
|
||||
# Unit tests for BuildSelector are in build_selector_test.py
|
||||
|
||||
|
||||
def test_empty_selector(platform, intercepted_build_args, monkeypatch):
|
||||
monkeypatch.setenv('CIBW_SKIP', '*')
|
||||
|
||||
with pytest.raises(SystemExit) as e:
|
||||
main()
|
||||
|
||||
assert e.value.code == 3
|
||||
|
||||
|
||||
@pytest.mark.parametrize('architecture, image, full_image', [
|
||||
('x86_64', None, 'quay.io/pypa/manylinux2010_x86_64:*'),
|
||||
('x86_64', 'manylinux1', 'quay.io/pypa/manylinux1_x86_64:*'),
|
||||
@@ -220,7 +229,7 @@ def test_build_verbosity(build_verbosity, platform_specific, platform, intercept
|
||||
('*-macosx_10_9_x86_64', ['*-macosx_x86_64']),
|
||||
('cp37-macosx_10_9_x86_64', ['cp37-macosx_x86_64']),
|
||||
])
|
||||
def test_build_selector_migrations(intercepted_build_args, monkeypatch, option_name, option_value, build_selector_patterns):
|
||||
def test_build_selector_migrations(intercepted_build_args, monkeypatch, option_name, option_value, build_selector_patterns, allow_empty):
|
||||
monkeypatch.setenv(option_name, option_value)
|
||||
|
||||
main()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import platform as platform_module
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
@@ -68,34 +67,39 @@ def test_platform_environment(platform, intercepted_build_args, monkeypatch):
|
||||
|
||||
|
||||
def test_archs_default(platform, intercepted_build_args, monkeypatch):
|
||||
monkeypatch.setattr(platform_module, 'machine', lambda: 'x86_64')
|
||||
|
||||
main()
|
||||
build_options = intercepted_build_args.args[0]
|
||||
|
||||
if platform == 'linux':
|
||||
assert build_options.architectures == {Architecture.x86_64, Architecture.i686}
|
||||
elif platform == 'windows':
|
||||
assert build_options.architectures == {Architecture.AMD64, Architecture.x86}
|
||||
else:
|
||||
assert build_options.architectures == {Architecture.x86_64}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('use_env_var', [False, True])
|
||||
def test_archs_argument(platform, intercepted_build_args, monkeypatch, use_env_var):
|
||||
monkeypatch.setattr(platform_module, 'machine', lambda: 'x86_64')
|
||||
|
||||
if use_env_var:
|
||||
monkeypatch.setenv('CIBW_ARCHS', 'ppc64le')
|
||||
else:
|
||||
monkeypatch.setenv('CIBW_ARCHS', 'unused')
|
||||
monkeypatch.setattr(sys, 'argv', sys.argv + ['--archs', 'ppc64le'])
|
||||
|
||||
main()
|
||||
build_options = intercepted_build_args.args[0]
|
||||
if platform in {'macos', 'windows'}:
|
||||
with pytest.raises(SystemExit) as exit:
|
||||
main()
|
||||
assert exit.value.args == (4,)
|
||||
|
||||
assert build_options.architectures == {Architecture.ppc64le}
|
||||
else:
|
||||
main()
|
||||
build_options = intercepted_build_args.args[0]
|
||||
assert build_options.architectures == {Architecture.ppc64le}
|
||||
|
||||
|
||||
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')
|
||||
@@ -110,3 +114,31 @@ def test_archs_platform_specific(platform, intercepted_build_args, monkeypatch):
|
||||
assert build_options.architectures == {Architecture.x86}
|
||||
elif platform == 'macos':
|
||||
assert build_options.architectures == {Architecture.x86_64}
|
||||
|
||||
|
||||
def test_archs_platform_native(platform, intercepted_build_args, monkeypatch):
|
||||
monkeypatch.setenv('CIBW_ARCHS', 'native')
|
||||
|
||||
main()
|
||||
build_options = intercepted_build_args.args[0]
|
||||
|
||||
if platform == 'linux':
|
||||
assert build_options.architectures == {Architecture.x86_64}
|
||||
elif platform == 'windows':
|
||||
assert build_options.architectures == {Architecture.AMD64}
|
||||
elif platform == 'macos':
|
||||
assert build_options.architectures == {Architecture.x86_64}
|
||||
|
||||
|
||||
def test_archs_platform_all(platform, intercepted_build_args, monkeypatch):
|
||||
monkeypatch.setenv('CIBW_ARCHS', 'all')
|
||||
|
||||
main()
|
||||
build_options = intercepted_build_args.args[0]
|
||||
|
||||
if platform == 'linux':
|
||||
assert build_options.architectures == {Architecture.x86_64, Architecture.i686, Architecture.aarch64, Architecture.ppc64le, Architecture.s390x}
|
||||
elif platform == 'windows':
|
||||
assert build_options.architectures == {Architecture.x86, Architecture.AMD64}
|
||||
elif platform == 'macos':
|
||||
assert build_options.architectures == {Architecture.x86_64}
|
||||
|
||||
Reference in New Issue
Block a user