style: apply black via pre-commit run -a
This commit is contained in:
committed by
Henry Schreiner
parent
9cbed6a9be
commit
178aaea6c7
@@ -24,7 +24,9 @@ def test_build():
|
||||
|
||||
|
||||
def test_skip():
|
||||
build_selector = BuildSelector(build_config="*", skip_config="cp27-* cp3?-manylinux1_i686 cp36-win* *-win32")
|
||||
build_selector = BuildSelector(
|
||||
build_config="*", skip_config="cp27-* cp3?-manylinux1_i686 cp36-win* *-win32"
|
||||
)
|
||||
|
||||
assert not build_selector('cp27-manylinux1_x86_64')
|
||||
assert build_selector('cp36-manylinux1_x86_64')
|
||||
@@ -44,7 +46,9 @@ def test_skip():
|
||||
|
||||
|
||||
def test_build_and_skip():
|
||||
build_selector = BuildSelector(build_config="cp36-* cp37-macosx* *-manylinux1*", skip_config="cp27-* cp37-manylinux1_i686")
|
||||
build_selector = BuildSelector(
|
||||
build_config="cp36-* cp37-macosx* *-manylinux1*", skip_config="cp27-* cp37-manylinux1_i686"
|
||||
)
|
||||
|
||||
assert not build_selector('cp27-manylinux1_x86_64')
|
||||
assert build_selector('cp36-manylinux1_x86_64')
|
||||
@@ -74,7 +78,9 @@ def test_build_braces():
|
||||
|
||||
|
||||
def test_build_limited_python():
|
||||
build_selector = BuildSelector(build_config="*", skip_config="", requires_python=SpecifierSet(">=3.6"))
|
||||
build_selector = BuildSelector(
|
||||
build_config="*", skip_config="", requires_python=SpecifierSet(">=3.6")
|
||||
)
|
||||
|
||||
assert not build_selector('cp27-manylinux1_x86_64')
|
||||
assert build_selector('cp36-manylinux1_x86_64')
|
||||
@@ -91,7 +97,11 @@ def test_build_limited_python():
|
||||
|
||||
|
||||
def test_build_limited_python_partial():
|
||||
build_selector = BuildSelector(build_config="*", skip_config="", requires_python=SpecifierSet(">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"))
|
||||
build_selector = BuildSelector(
|
||||
build_config="*",
|
||||
skip_config="",
|
||||
requires_python=SpecifierSet(">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"),
|
||||
)
|
||||
|
||||
assert build_selector('cp27-manylinux1_x86_64')
|
||||
assert not build_selector('cp35-manylinux1_x86_64')
|
||||
@@ -99,7 +109,9 @@ def test_build_limited_python_partial():
|
||||
|
||||
|
||||
def test_build_limited_python_patch():
|
||||
build_selector = BuildSelector(build_config="*", skip_config="", requires_python=SpecifierSet(">=2.7.9"))
|
||||
build_selector = BuildSelector(
|
||||
build_config="*", skip_config="", requires_python=SpecifierSet(">=2.7.9")
|
||||
)
|
||||
|
||||
assert build_selector('cp27-manylinux1_x86_64')
|
||||
assert build_selector('cp36-manylinux1_x86_64')
|
||||
|
||||
@@ -2,9 +2,7 @@ import pytest
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
"--run-docker", action="store_true", default=False, help="run docker tests"
|
||||
)
|
||||
parser.addoption("--run-docker", action="store_true", default=False, help="run docker tests")
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
|
||||
@@ -10,8 +10,18 @@ def test_defaults():
|
||||
resources_dir = project_root / 'cibuildwheel' / 'resources'
|
||||
|
||||
assert dependency_constraints.base_file_path.samefile(resources_dir / 'constraints.txt')
|
||||
assert dependency_constraints.get_for_python_version('3.99').samefile(resources_dir / 'constraints.txt')
|
||||
assert dependency_constraints.get_for_python_version('3.9').samefile(resources_dir / 'constraints-python39.txt')
|
||||
assert dependency_constraints.get_for_python_version('3.6').samefile(resources_dir / 'constraints-python36.txt')
|
||||
assert dependency_constraints.get_for_python_version('3.5').samefile(resources_dir / 'constraints-python35.txt')
|
||||
assert dependency_constraints.get_for_python_version('2.7').samefile(resources_dir / 'constraints-python27.txt')
|
||||
assert dependency_constraints.get_for_python_version('3.99').samefile(
|
||||
resources_dir / 'constraints.txt'
|
||||
)
|
||||
assert dependency_constraints.get_for_python_version('3.9').samefile(
|
||||
resources_dir / 'constraints-python39.txt'
|
||||
)
|
||||
assert dependency_constraints.get_for_python_version('3.6').samefile(
|
||||
resources_dir / 'constraints-python36.txt'
|
||||
)
|
||||
assert dependency_constraints.get_for_python_version('3.5').samefile(
|
||||
resources_dir / 'constraints-python35.txt'
|
||||
)
|
||||
assert dependency_constraints.get_for_python_version('2.7').samefile(
|
||||
resources_dir / 'constraints-python27.txt'
|
||||
)
|
||||
|
||||
@@ -38,7 +38,12 @@ def test_no_lf():
|
||||
@pytest.mark.docker
|
||||
def test_environment():
|
||||
with DockerContainer(DEFAULT_IMAGE) as container:
|
||||
assert container.call(['sh', '-c', 'echo $TEST_VAR'], env={'TEST_VAR': '1'}, capture_output=True) == '1\n'
|
||||
assert (
|
||||
container.call(
|
||||
['sh', '-c', 'echo $TEST_VAR'], env={'TEST_VAR': '1'}, capture_output=True
|
||||
)
|
||||
== '1\n'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.docker
|
||||
@@ -51,28 +56,43 @@ def test_cwd():
|
||||
@pytest.mark.docker
|
||||
def test_container_removed():
|
||||
with DockerContainer(DEFAULT_IMAGE) as container:
|
||||
docker_containers_listing = subprocess.run('docker container ls', shell=True, check=True, stdout=subprocess.PIPE, universal_newlines=True).stdout
|
||||
docker_containers_listing = subprocess.run(
|
||||
'docker container ls',
|
||||
shell=True,
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
).stdout
|
||||
assert container.name in docker_containers_listing
|
||||
old_container_name = container.name
|
||||
|
||||
docker_containers_listing = subprocess.run('docker container ls', shell=True, check=True, stdout=subprocess.PIPE, universal_newlines=True).stdout
|
||||
docker_containers_listing = subprocess.run(
|
||||
'docker container ls',
|
||||
shell=True,
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
).stdout
|
||||
assert old_container_name not in docker_containers_listing
|
||||
|
||||
|
||||
@pytest.mark.docker
|
||||
def test_large_environment():
|
||||
# max environment variable size is 128kB
|
||||
long_env_var_length = 127*1024
|
||||
long_env_var_length = 127 * 1024
|
||||
large_environment = {
|
||||
'a': '0'*long_env_var_length,
|
||||
'b': '0'*long_env_var_length,
|
||||
'c': '0'*long_env_var_length,
|
||||
'd': '0'*long_env_var_length,
|
||||
'a': '0' * long_env_var_length,
|
||||
'b': '0' * long_env_var_length,
|
||||
'c': '0' * long_env_var_length,
|
||||
'd': '0' * long_env_var_length,
|
||||
}
|
||||
|
||||
with DockerContainer(DEFAULT_IMAGE) as container:
|
||||
# check the length of d
|
||||
assert container.call(['sh', '-c', 'echo ${#d}'], env=large_environment, capture_output=True) == f'{long_env_var_length}\n'
|
||||
assert (
|
||||
container.call(['sh', '-c', 'echo ${#d}'], env=large_environment, capture_output=True)
|
||||
== f'{long_env_var_length}\n'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.docker
|
||||
@@ -81,16 +101,33 @@ def test_binary_output():
|
||||
# note: the below embedded snippets are in python2
|
||||
|
||||
# check that we can pass though arbitrary binary data without erroring
|
||||
container.call(['/usr/bin/python2', '-c', textwrap.dedent('''
|
||||
container.call(
|
||||
[
|
||||
'/usr/bin/python2',
|
||||
'-c',
|
||||
textwrap.dedent(
|
||||
'''
|
||||
import sys
|
||||
sys.stdout.write(''.join(chr(n) for n in range(0, 256)))
|
||||
''')])
|
||||
'''
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
# check that we can capture arbitrary binary data
|
||||
output = container.call(['/usr/bin/python2', '-c', textwrap.dedent('''
|
||||
output = container.call(
|
||||
[
|
||||
'/usr/bin/python2',
|
||||
'-c',
|
||||
textwrap.dedent(
|
||||
'''
|
||||
import sys
|
||||
sys.stdout.write(''.join(chr(n % 256) for n in range(0, 512)))
|
||||
''')], capture_output=True)
|
||||
'''
|
||||
),
|
||||
],
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
data = bytes(output, encoding='utf8', errors='surrogateescape')
|
||||
|
||||
|
||||
@@ -6,9 +6,7 @@ from cibuildwheel.environment import parse_environment
|
||||
def test_basic_parsing():
|
||||
environment_recipe = parse_environment('VAR=1 VBR=2')
|
||||
|
||||
environment_dict = environment_recipe.as_dictionary(
|
||||
prev_environment={}
|
||||
)
|
||||
environment_dict = environment_recipe.as_dictionary(prev_environment={})
|
||||
environment_cmds = environment_recipe.as_shell_commands()
|
||||
|
||||
assert environment_dict == {'VAR': '1', 'VBR': '2'}
|
||||
@@ -18,9 +16,7 @@ def test_basic_parsing():
|
||||
def test_quotes():
|
||||
environment_recipe = parse_environment('A=1 VAR="1 NOT_A_VAR=2" VBR=\'vbr\'')
|
||||
|
||||
environment_dict = environment_recipe.as_dictionary(
|
||||
prev_environment={}
|
||||
)
|
||||
environment_dict = environment_recipe.as_dictionary(prev_environment={})
|
||||
environment_cmds = environment_recipe.as_shell_commands()
|
||||
|
||||
assert environment_dict == {'A': '1', 'VAR': '1 NOT_A_VAR=2', 'VBR': 'vbr'}
|
||||
@@ -30,9 +26,7 @@ def test_quotes():
|
||||
def test_inheritance():
|
||||
environment_recipe = parse_environment('PATH=$PATH:/usr/local/bin')
|
||||
|
||||
environment_dict = environment_recipe.as_dictionary(
|
||||
prev_environment={'PATH': '/usr/bin'}
|
||||
)
|
||||
environment_dict = environment_recipe.as_dictionary(prev_environment={'PATH': '/usr/bin'})
|
||||
environment_cmds = environment_recipe.as_shell_commands()
|
||||
|
||||
assert environment_dict == {'PATH': '/usr/bin:/usr/local/bin'}
|
||||
@@ -45,9 +39,7 @@ def test_shell_eval():
|
||||
env_copy = os.environ.copy()
|
||||
env_copy.pop('VAR', None)
|
||||
|
||||
environment_dict = environment_recipe.as_dictionary(
|
||||
prev_environment=env_copy
|
||||
)
|
||||
environment_dict = environment_recipe.as_dictionary(prev_environment=env_copy)
|
||||
environment_cmds = environment_recipe.as_shell_commands()
|
||||
|
||||
assert environment_dict['VAR'] == 'a test string'
|
||||
@@ -57,9 +49,7 @@ def test_shell_eval():
|
||||
def test_shell_eval_and_env():
|
||||
environment_recipe = parse_environment('VAR="$(echo "$PREV_VAR" string)"')
|
||||
|
||||
environment_dict = environment_recipe.as_dictionary(
|
||||
prev_environment={'PREV_VAR': '1 2 3'}
|
||||
)
|
||||
environment_dict = environment_recipe.as_dictionary(prev_environment={'PREV_VAR': '1 2 3'})
|
||||
environment_cmds = environment_recipe.as_shell_commands()
|
||||
|
||||
assert environment_dict == {'PREV_VAR': '1 2 3', 'VAR': '1 2 3 string'}
|
||||
@@ -69,9 +59,7 @@ def test_shell_eval_and_env():
|
||||
def test_empty_var():
|
||||
environment_recipe = parse_environment('CFLAGS=')
|
||||
|
||||
environment_dict = environment_recipe.as_dictionary(
|
||||
prev_environment={'CFLAGS': '-Wall'}
|
||||
)
|
||||
environment_dict = environment_recipe.as_dictionary(prev_environment={'CFLAGS': '-Wall'})
|
||||
environment_cmds = environment_recipe.as_shell_commands()
|
||||
|
||||
assert environment_dict == {'CFLAGS': ''}
|
||||
@@ -91,7 +79,9 @@ def test_no_vars():
|
||||
def test_no_vars_pass_through():
|
||||
environment_recipe = parse_environment('')
|
||||
|
||||
environment_dict = environment_recipe.as_dictionary(prev_environment={'CIBUILDWHEEL': 'awesome'})
|
||||
environment_dict = environment_recipe.as_dictionary(
|
||||
prev_environment={'CIBUILDWHEEL': 'awesome'}
|
||||
)
|
||||
|
||||
assert environment_dict == {'CIBUILDWHEEL': 'awesome'}
|
||||
|
||||
@@ -109,15 +99,15 @@ def test_substitution_with_backslash():
|
||||
environment_recipe = parse_environment('PATH2="somewhere_else;$PATH1"')
|
||||
|
||||
# pass the existing process env so PATH is available
|
||||
environment_dict = environment_recipe.as_dictionary(prev_environment={
|
||||
'PATH1': 'c:\\folder\\'
|
||||
})
|
||||
environment_dict = environment_recipe.as_dictionary(prev_environment={'PATH1': 'c:\\folder\\'})
|
||||
|
||||
assert environment_dict.get('PATH2') == 'somewhere_else;c:\\folder\\'
|
||||
|
||||
|
||||
def test_awkwardly_quoted_variable():
|
||||
environment_recipe = parse_environment('VAR2=something"like this""$VAR1"$VAR1$(echo "theres more")"$(echo "and more!")"')
|
||||
environment_recipe = parse_environment(
|
||||
'VAR2=something"like this""$VAR1"$VAR1$(echo "theres more")"$(echo "and more!")"'
|
||||
)
|
||||
|
||||
# pass the existing process env so PATH is available
|
||||
environment_dict = environment_recipe.as_dictionary({'VAR1': 'but wait'})
|
||||
|
||||
@@ -66,36 +66,38 @@ def test_empty_selector(platform, intercepted_build_args, monkeypatch):
|
||||
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:*'),
|
||||
('x86_64', 'manylinux2010', 'quay.io/pypa/manylinux2010_x86_64:*'),
|
||||
('x86_64', 'manylinux2014', 'quay.io/pypa/manylinux2014_x86_64:*'),
|
||||
('x86_64', 'manylinux_2_24', 'quay.io/pypa/manylinux_2_24_x86_64:*'),
|
||||
('x86_64', 'custom_image', 'custom_image'),
|
||||
('i686', None, 'quay.io/pypa/manylinux2010_i686:*'),
|
||||
('i686', 'manylinux1', 'quay.io/pypa/manylinux1_i686:*'),
|
||||
('i686', 'manylinux2010', 'quay.io/pypa/manylinux2010_i686:*'),
|
||||
('i686', 'manylinux2014', 'quay.io/pypa/manylinux2014_i686:*'),
|
||||
('i686', 'manylinux_2_24', 'quay.io/pypa/manylinux_2_24_i686:*'),
|
||||
('i686', 'custom_image', 'custom_image'),
|
||||
('pypy_x86_64', None, 'pypywheels/manylinux2010-pypy_x86_64:*'),
|
||||
('pypy_x86_64', 'manylinux1', 'manylinux1'), # Does not exist
|
||||
('pypy_x86_64', 'manylinux2010', 'pypywheels/manylinux2010-pypy_x86_64:*'),
|
||||
('pypy_x86_64', 'manylinux2014', 'manylinux2014'), # Does not exist (yet)
|
||||
('pypy_x86_64', 'custom_image', 'custom_image'),
|
||||
])
|
||||
def test_manylinux_images(architecture, image, full_image, platform, intercepted_build_args, monkeypatch):
|
||||
@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:*'),
|
||||
('x86_64', 'manylinux2010', 'quay.io/pypa/manylinux2010_x86_64:*'),
|
||||
('x86_64', 'manylinux2014', 'quay.io/pypa/manylinux2014_x86_64:*'),
|
||||
('x86_64', 'manylinux_2_24', 'quay.io/pypa/manylinux_2_24_x86_64:*'),
|
||||
('x86_64', 'custom_image', 'custom_image'),
|
||||
('i686', None, 'quay.io/pypa/manylinux2010_i686:*'),
|
||||
('i686', 'manylinux1', 'quay.io/pypa/manylinux1_i686:*'),
|
||||
('i686', 'manylinux2010', 'quay.io/pypa/manylinux2010_i686:*'),
|
||||
('i686', 'manylinux2014', 'quay.io/pypa/manylinux2014_i686:*'),
|
||||
('i686', 'manylinux_2_24', 'quay.io/pypa/manylinux_2_24_i686:*'),
|
||||
('i686', 'custom_image', 'custom_image'),
|
||||
('pypy_x86_64', None, 'pypywheels/manylinux2010-pypy_x86_64:*'),
|
||||
('pypy_x86_64', 'manylinux1', 'manylinux1'), # Does not exist
|
||||
('pypy_x86_64', 'manylinux2010', 'pypywheels/manylinux2010-pypy_x86_64:*'),
|
||||
('pypy_x86_64', 'manylinux2014', 'manylinux2014'), # Does not exist (yet)
|
||||
('pypy_x86_64', 'custom_image', 'custom_image'),
|
||||
],
|
||||
)
|
||||
def test_manylinux_images(
|
||||
architecture, image, full_image, platform, intercepted_build_args, monkeypatch
|
||||
):
|
||||
if image is not None:
|
||||
monkeypatch.setenv('CIBW_MANYLINUX_' + architecture.upper() + '_IMAGE', image)
|
||||
|
||||
main()
|
||||
|
||||
if platform == 'linux':
|
||||
assert fnmatch(
|
||||
intercepted_build_args.args[0].manylinux_images[architecture],
|
||||
full_image
|
||||
)
|
||||
assert fnmatch(intercepted_build_args.args[0].manylinux_images[architecture], full_image)
|
||||
else:
|
||||
assert intercepted_build_args.args[0].manylinux_images is None
|
||||
|
||||
@@ -113,7 +115,9 @@ def get_default_repair_command(platform):
|
||||
|
||||
@pytest.mark.parametrize('repair_command', [None, 'repair', 'repair -w {dest_dir} {wheel}'])
|
||||
@pytest.mark.parametrize('platform_specific', [False, True])
|
||||
def test_repair_command(repair_command, platform_specific, platform, intercepted_build_args, monkeypatch):
|
||||
def test_repair_command(
|
||||
repair_command, platform_specific, platform, intercepted_build_args, monkeypatch
|
||||
):
|
||||
if repair_command is not None:
|
||||
if platform_specific:
|
||||
monkeypatch.setenv('CIBW_REPAIR_WHEEL_COMMAND_' + platform.upper(), repair_command)
|
||||
@@ -127,11 +131,10 @@ def test_repair_command(repair_command, platform_specific, platform, intercepted
|
||||
assert intercepted_build_args.args[0].repair_command == expected_repair
|
||||
|
||||
|
||||
@pytest.mark.parametrize('environment', [
|
||||
{},
|
||||
{'something': 'value'},
|
||||
{'something': 'value', 'something_else': 'other_value'}
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
'environment',
|
||||
[{}, {'something': 'value'}, {'something': 'value', 'something_else': 'other_value'}],
|
||||
)
|
||||
@pytest.mark.parametrize('platform_specific', [False, True])
|
||||
def test_environment(environment, platform_specific, platform, intercepted_build_args, monkeypatch):
|
||||
env_string = ' '.join(f'{k}={v}' for k, v in environment.items())
|
||||
@@ -150,7 +153,9 @@ def test_environment(environment, platform_specific, platform, intercepted_build
|
||||
|
||||
@pytest.mark.parametrize('test_requires', [None, 'requirement other_requirement'])
|
||||
@pytest.mark.parametrize('platform_specific', [False, True])
|
||||
def test_test_requires(test_requires, platform_specific, platform, intercepted_build_args, monkeypatch):
|
||||
def test_test_requires(
|
||||
test_requires, platform_specific, platform, intercepted_build_args, monkeypatch
|
||||
):
|
||||
if test_requires is not None:
|
||||
if platform_specific:
|
||||
monkeypatch.setenv('CIBW_TEST_REQUIRES_' + platform.upper(), test_requires)
|
||||
@@ -175,12 +180,16 @@ def test_test_extras(test_extras, platform_specific, platform, intercepted_build
|
||||
|
||||
main()
|
||||
|
||||
assert intercepted_build_args.args[0].test_extras == ('[' + test_extras + ']' if test_extras else '')
|
||||
assert intercepted_build_args.args[0].test_extras == (
|
||||
'[' + test_extras + ']' if test_extras else ''
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('test_command', [None, 'test --command'])
|
||||
@pytest.mark.parametrize('platform_specific', [False, True])
|
||||
def test_test_command(test_command, platform_specific, platform, intercepted_build_args, monkeypatch):
|
||||
def test_test_command(
|
||||
test_command, platform_specific, platform, intercepted_build_args, monkeypatch
|
||||
):
|
||||
if test_command is not None:
|
||||
if platform_specific:
|
||||
monkeypatch.setenv('CIBW_TEST_COMMAND_' + platform.upper(), test_command)
|
||||
@@ -195,7 +204,9 @@ def test_test_command(test_command, platform_specific, platform, intercepted_bui
|
||||
|
||||
@pytest.mark.parametrize('before_build', [None, 'before --build'])
|
||||
@pytest.mark.parametrize('platform_specific', [False, True])
|
||||
def test_before_build(before_build, platform_specific, platform, intercepted_build_args, monkeypatch):
|
||||
def test_before_build(
|
||||
before_build, platform_specific, platform, intercepted_build_args, monkeypatch
|
||||
):
|
||||
if before_build is not None:
|
||||
if platform_specific:
|
||||
monkeypatch.setenv('CIBW_BEFORE_BUILD_' + platform.upper(), before_build)
|
||||
@@ -210,7 +221,9 @@ def test_before_build(before_build, platform_specific, platform, intercepted_bui
|
||||
|
||||
@pytest.mark.parametrize('build_verbosity', [None, 0, 2, -2, 4, -4])
|
||||
@pytest.mark.parametrize('platform_specific', [False, True])
|
||||
def test_build_verbosity(build_verbosity, platform_specific, platform, intercepted_build_args, monkeypatch):
|
||||
def test_build_verbosity(
|
||||
build_verbosity, platform_specific, platform, intercepted_build_args, monkeypatch
|
||||
):
|
||||
if build_verbosity is not None:
|
||||
if platform_specific:
|
||||
monkeypatch.setenv('CIBW_BUILD_VERBOSITY_' + platform.upper(), str(build_verbosity))
|
||||
@@ -225,13 +238,23 @@ def test_build_verbosity(build_verbosity, platform_specific, platform, intercept
|
||||
|
||||
|
||||
@pytest.mark.parametrize('option_name', ['CIBW_BUILD', 'CIBW_SKIP'])
|
||||
@pytest.mark.parametrize('option_value, build_selector_patterns', [
|
||||
('*-manylinux1_*', ['*-manylinux_*']),
|
||||
('*-macosx_10_6_intel', ['*-macosx_x86_64']),
|
||||
('*-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, allow_empty):
|
||||
@pytest.mark.parametrize(
|
||||
'option_value, build_selector_patterns',
|
||||
[
|
||||
('*-manylinux1_*', ['*-manylinux_*']),
|
||||
('*-macosx_10_6_intel', ['*-macosx_x86_64']),
|
||||
('*-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,
|
||||
allow_empty,
|
||||
):
|
||||
monkeypatch.setenv(option_name, option_value)
|
||||
|
||||
main()
|
||||
|
||||
@@ -167,8 +167,18 @@ def test_archs_platform_all(platform, intercepted_build_args, monkeypatch):
|
||||
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}
|
||||
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, Architecture.arm64, Architecture.universal2}
|
||||
assert build_options.architectures == {
|
||||
Architecture.x86_64,
|
||||
Architecture.arm64,
|
||||
Architecture.universal2,
|
||||
}
|
||||
|
||||
@@ -50,10 +50,14 @@ def test_override_env(platform, monkeypatch, intercepted_build_args):
|
||||
|
||||
def test_override_setup_cfg(platform, monkeypatch, intercepted_build_args, fake_package_dir):
|
||||
|
||||
fake_package_dir.joinpath("setup.cfg").write_text(textwrap.dedent("""
|
||||
fake_package_dir.joinpath("setup.cfg").write_text(
|
||||
textwrap.dedent(
|
||||
"""
|
||||
[options]
|
||||
python_requires = >=3.8
|
||||
"""))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
main()
|
||||
|
||||
@@ -67,10 +71,14 @@ def test_override_setup_cfg(platform, monkeypatch, intercepted_build_args, fake_
|
||||
|
||||
def test_override_pyproject_toml(platform, monkeypatch, intercepted_build_args, fake_package_dir):
|
||||
|
||||
fake_package_dir.joinpath("pyproject.toml").write_text(textwrap.dedent("""
|
||||
fake_package_dir.joinpath("pyproject.toml").write_text(
|
||||
textwrap.dedent(
|
||||
"""
|
||||
[project]
|
||||
requires-python = ">=3.8"
|
||||
"""))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
main()
|
||||
|
||||
@@ -84,14 +92,18 @@ def test_override_pyproject_toml(platform, monkeypatch, intercepted_build_args,
|
||||
|
||||
def test_override_setup_py_simple(platform, monkeypatch, intercepted_build_args, fake_package_dir):
|
||||
|
||||
fake_package_dir.joinpath("setup.py").write_text(textwrap.dedent("""
|
||||
fake_package_dir.joinpath("setup.py").write_text(
|
||||
textwrap.dedent(
|
||||
"""
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name = "other",
|
||||
python_requires = ">=3.7",
|
||||
)
|
||||
"""))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
main()
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ from cibuildwheel.projectfiles import get_requires_python_str, setup_py_python_r
|
||||
|
||||
def test_read_setup_py_simple(tmp_path):
|
||||
with open(tmp_path / "setup.py", "w") as f:
|
||||
f.write(dedent("""
|
||||
f.write(
|
||||
dedent(
|
||||
"""
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
@@ -14,7 +16,9 @@ def test_read_setup_py_simple(tmp_path):
|
||||
example = ["item", "other"],
|
||||
python_requires = "1.23",
|
||||
)
|
||||
"""))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
assert setup_py_python_requires(tmp_path.joinpath("setup.py").read_text()) == "1.23"
|
||||
assert get_requires_python_str(tmp_path) == "1.23"
|
||||
@@ -22,7 +26,9 @@ def test_read_setup_py_simple(tmp_path):
|
||||
|
||||
def test_read_setup_py_full(tmp_path):
|
||||
with open(tmp_path / "setup.py", "w") as f:
|
||||
f.write(dedent("""
|
||||
f.write(
|
||||
dedent(
|
||||
"""
|
||||
import setuptools
|
||||
|
||||
setuptools.randomfunc()
|
||||
@@ -33,7 +39,9 @@ def test_read_setup_py_full(tmp_path):
|
||||
example = ["item", "other"],
|
||||
python_requires = "1.24",
|
||||
)
|
||||
"""))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
assert setup_py_python_requires(tmp_path.joinpath("setup.py").read_text()) == "1.24"
|
||||
assert get_requires_python_str(tmp_path) == "1.24"
|
||||
@@ -41,7 +49,9 @@ def test_read_setup_py_full(tmp_path):
|
||||
|
||||
def test_read_setup_py_assign(tmp_path):
|
||||
with open(tmp_path / "setup.py", "w") as f:
|
||||
f.write(dedent("""
|
||||
f.write(
|
||||
dedent(
|
||||
"""
|
||||
from setuptools import setup
|
||||
|
||||
REQUIRES = "3.21"
|
||||
@@ -52,7 +62,9 @@ def test_read_setup_py_assign(tmp_path):
|
||||
example = ["item", "other"],
|
||||
python_requires = REQUIRES,
|
||||
)
|
||||
"""))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
assert setup_py_python_requires(tmp_path.joinpath("setup.py").read_text()) is None
|
||||
assert get_requires_python_str(tmp_path) is None
|
||||
@@ -60,7 +72,9 @@ def test_read_setup_py_assign(tmp_path):
|
||||
|
||||
def test_read_setup_py_None(tmp_path):
|
||||
with open(tmp_path / "setup.py", "w") as f:
|
||||
f.write(dedent("""
|
||||
f.write(
|
||||
dedent(
|
||||
"""
|
||||
from setuptools import setup
|
||||
|
||||
REQUIRES = None
|
||||
@@ -71,7 +85,9 @@ def test_read_setup_py_None(tmp_path):
|
||||
example = ["item", "other"],
|
||||
python_requires = None,
|
||||
)
|
||||
"""))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
assert setup_py_python_requires(tmp_path.joinpath("setup.py").read_text()) is None
|
||||
assert get_requires_python_str(tmp_path) is None
|
||||
@@ -79,7 +95,9 @@ def test_read_setup_py_None(tmp_path):
|
||||
|
||||
def test_read_setup_py_empty(tmp_path):
|
||||
with open(tmp_path / "setup.py", "w") as f:
|
||||
f.write(dedent("""
|
||||
f.write(
|
||||
dedent(
|
||||
"""
|
||||
from setuptools import setup
|
||||
|
||||
REQUIRES = "3.21"
|
||||
@@ -89,7 +107,9 @@ def test_read_setup_py_empty(tmp_path):
|
||||
other = 23,
|
||||
example = ["item", "other"],
|
||||
)
|
||||
"""))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
assert setup_py_python_requires(tmp_path.joinpath("setup.py").read_text()) is None
|
||||
assert get_requires_python_str(tmp_path) is None
|
||||
@@ -97,46 +117,62 @@ def test_read_setup_py_empty(tmp_path):
|
||||
|
||||
def test_read_setup_cfg(tmp_path):
|
||||
with open(tmp_path / "setup.cfg", "w") as f:
|
||||
f.write(dedent("""
|
||||
f.write(
|
||||
dedent(
|
||||
"""
|
||||
[options]
|
||||
python_requires = 1.234
|
||||
[metadata]
|
||||
something = other
|
||||
"""))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
assert get_requires_python_str(tmp_path) == "1.234"
|
||||
|
||||
|
||||
def test_read_setup_cfg_empty(tmp_path):
|
||||
with open(tmp_path / "setup.cfg", "w") as f:
|
||||
f.write(dedent("""
|
||||
f.write(
|
||||
dedent(
|
||||
"""
|
||||
[options]
|
||||
other = 1.234
|
||||
[metadata]
|
||||
something = other
|
||||
"""))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
assert get_requires_python_str(tmp_path) is None
|
||||
|
||||
|
||||
def test_read_pyproject_toml(tmp_path):
|
||||
with open(tmp_path / "pyproject.toml", "w") as f:
|
||||
f.write(dedent("""
|
||||
f.write(
|
||||
dedent(
|
||||
"""
|
||||
[project]
|
||||
requires-python = "1.654"
|
||||
|
||||
[tool.cibuildwheel]
|
||||
something = "other"
|
||||
"""))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
assert get_requires_python_str(tmp_path) == "1.654"
|
||||
|
||||
|
||||
def test_read_pyproject_toml_empty(tmp_path):
|
||||
with open(tmp_path / "pyproject.toml", "w") as f:
|
||||
f.write(dedent("""
|
||||
f.write(
|
||||
dedent(
|
||||
"""
|
||||
[project]
|
||||
other = 1.234
|
||||
"""))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
assert get_requires_python_str(tmp_path) is None
|
||||
|
||||
Reference in New Issue
Block a user