style: apply black via pre-commit run -a
This commit is contained in:
committed by
Henry Schreiner
parent
9cbed6a9be
commit
178aaea6c7
@@ -8,12 +8,14 @@ from cibuildwheel.logger import Logger
|
||||
from . import test_projects, utils
|
||||
|
||||
basic_project = test_projects.new_c_project(
|
||||
setup_py_add=textwrap.dedent('''
|
||||
setup_py_add=textwrap.dedent(
|
||||
'''
|
||||
import os
|
||||
|
||||
if os.environ.get("CIBUILDWHEEL", "0") != "1":
|
||||
raise Exception("CIBUILDWHEEL environment variable is not set to 1")
|
||||
''')
|
||||
'''
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -55,8 +57,11 @@ def test_build_identifiers(tmp_path):
|
||||
# can be multiple wheels for each wheel, though, so we need to limit
|
||||
# the expected wheels
|
||||
if platform.machine() in ['x86_64', 'i686']:
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if '-manylinux' not in w or '-manylinux1' in w]
|
||||
expected_wheels = [
|
||||
w
|
||||
for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if '-manylinux' not in w or '-manylinux1' in w
|
||||
]
|
||||
else:
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
build_identifiers = utils.cibuildwheel_get_build_identifiers(project_dir)
|
||||
|
||||
+28
-17
@@ -6,7 +6,8 @@ import pytest
|
||||
from . import test_projects, utils
|
||||
|
||||
project_with_before_build_asserts = test_projects.new_c_project(
|
||||
setup_py_add=textwrap.dedent(r'''
|
||||
setup_py_add=textwrap.dedent(
|
||||
r'''
|
||||
# assert that the Python version as written to text_info.txt in the CIBW_BEFORE_ALL step
|
||||
# is the same one as is currently running.
|
||||
with open("text_info.txt") as f:
|
||||
@@ -14,7 +15,8 @@ project_with_before_build_asserts = test_projects.new_c_project(
|
||||
|
||||
print("## stored text: " + stored_text)
|
||||
assert stored_text == "sample text 123"
|
||||
''')
|
||||
'''
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -27,13 +29,16 @@ def test(tmp_path):
|
||||
|
||||
# build the wheels
|
||||
before_all_command = '''python -c "import os;open('{project}/text_info.txt', 'w').write('sample text '+os.environ.get('TEST_VAL', ''))"'''
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
# write python version information to a temporary file, this is
|
||||
# checked in setup.py
|
||||
'CIBW_BEFORE_ALL': before_all_command,
|
||||
'CIBW_BEFORE_ALL_LINUX': f'{before_all_command} && python -c "import sys; assert sys.version_info >= (3, 6)"',
|
||||
'CIBW_ENVIRONMENT': "TEST_VAL='123'"
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
# write python version information to a temporary file, this is
|
||||
# checked in setup.py
|
||||
'CIBW_BEFORE_ALL': before_all_command,
|
||||
'CIBW_BEFORE_ALL_LINUX': f'{before_all_command} && python -c "import sys; assert sys.version_info >= (3, 6)"',
|
||||
'CIBW_ENVIRONMENT': "TEST_VAL='123'",
|
||||
},
|
||||
)
|
||||
|
||||
# also check that we got the right wheels
|
||||
(project_dir / 'text_info.txt').unlink()
|
||||
@@ -46,20 +51,26 @@ def test_failing_command(tmp_path):
|
||||
test_projects.new_c_project().generate(project_dir)
|
||||
|
||||
with pytest.raises(subprocess.CalledProcessError):
|
||||
utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_BEFORE_ALL': 'false',
|
||||
'CIBW_BEFORE_ALL_WINDOWS': 'exit /b 1',
|
||||
})
|
||||
utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_BEFORE_ALL': 'false',
|
||||
'CIBW_BEFORE_ALL_WINDOWS': 'exit /b 1',
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def test_cwd(tmp_path):
|
||||
project_dir = tmp_path / 'project'
|
||||
test_projects.new_c_project().generate(project_dir)
|
||||
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_BEFORE_ALL': f'''python -c "import os; assert os.getcwd() == {str(project_dir)!r}"''',
|
||||
'CIBW_BEFORE_ALL_LINUX': '''python -c "import os; assert os.getcwd() == '/project'"''',
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_BEFORE_ALL': f'''python -c "import os; assert os.getcwd() == {str(project_dir)!r}"''',
|
||||
'CIBW_BEFORE_ALL_LINUX': '''python -c "import os; assert os.getcwd() == '/project'"''',
|
||||
},
|
||||
)
|
||||
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
+31
-18
@@ -6,7 +6,8 @@ import pytest
|
||||
from . import test_projects, utils
|
||||
|
||||
project_with_before_build_asserts = test_projects.new_c_project(
|
||||
setup_py_add=textwrap.dedent(r'''
|
||||
setup_py_add=textwrap.dedent(
|
||||
r'''
|
||||
import os
|
||||
|
||||
# assert that the Python version as written to pythonversion.txt in the CIBW_BEFORE_BUILD step
|
||||
@@ -26,7 +27,8 @@ project_with_before_build_asserts = test_projects.new_c_project(
|
||||
print('sys.executable', sys.executable)
|
||||
# windows/mac are case insensitive
|
||||
assert os.path.realpath(stored_executable).lower() == os.path.realpath(sys.executable).lower()
|
||||
''')
|
||||
'''
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -34,16 +36,21 @@ def test(tmp_path):
|
||||
project_dir = tmp_path / 'project'
|
||||
project_with_before_build_asserts.generate(project_dir)
|
||||
|
||||
before_build = ('''python -c "import sys; open('{output_dir}pythonversion.txt', 'w').write(sys.version)" && '''
|
||||
'''python -c "import sys; open('{output_dir}pythonexecutable.txt', 'w').write(sys.executable)"''')
|
||||
before_build = (
|
||||
'''python -c "import sys; open('{output_dir}pythonversion.txt', 'w').write(sys.version)" && '''
|
||||
'''python -c "import sys; open('{output_dir}pythonexecutable.txt', 'w').write(sys.executable)"'''
|
||||
)
|
||||
|
||||
# build the wheels
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
# write python version information to a temporary file, this is
|
||||
# checked in setup.py
|
||||
'CIBW_BEFORE_BUILD': before_build.format(output_dir='/tmp/'),
|
||||
'CIBW_BEFORE_BUILD_WINDOWS': before_build.format(output_dir=r'c:\\'),
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
# write python version information to a temporary file, this is
|
||||
# checked in setup.py
|
||||
'CIBW_BEFORE_BUILD': before_build.format(output_dir='/tmp/'),
|
||||
'CIBW_BEFORE_BUILD_WINDOWS': before_build.format(output_dir=r'c:\\'),
|
||||
},
|
||||
)
|
||||
|
||||
# also check that we got the right wheels
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
@@ -55,20 +62,26 @@ def test_failing_command(tmp_path):
|
||||
test_projects.new_c_project().generate(project_dir)
|
||||
|
||||
with pytest.raises(subprocess.CalledProcessError):
|
||||
utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_BEFORE_BUILD': 'false',
|
||||
'CIBW_BEFORE_BUILD_WINDOWS': 'exit /b 1',
|
||||
})
|
||||
utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_BEFORE_BUILD': 'false',
|
||||
'CIBW_BEFORE_BUILD_WINDOWS': 'exit /b 1',
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def test_cwd(tmp_path):
|
||||
project_dir = tmp_path / 'project'
|
||||
test_projects.new_c_project().generate(project_dir)
|
||||
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_BEFORE_BUILD': f'''python -c "import os; assert os.getcwd() == {str(project_dir)!r}"''',
|
||||
'CIBW_BEFORE_BUILD_LINUX': '''python -c "import os; assert os.getcwd() == '/project'"''',
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_BEFORE_BUILD': f'''python -c "import os; assert os.getcwd() == {str(project_dir)!r}"''',
|
||||
'CIBW_BEFORE_BUILD_LINUX': '''python -c "import os; assert os.getcwd() == '/project'"''',
|
||||
},
|
||||
)
|
||||
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
+17
-12
@@ -1,7 +1,9 @@
|
||||
from . import test_projects, utils
|
||||
|
||||
before_test_project = test_projects.new_c_project()
|
||||
before_test_project.files['test/spam_test.py'] = r'''
|
||||
before_test_project.files[
|
||||
'test/spam_test.py'
|
||||
] = r'''
|
||||
import sys
|
||||
import os
|
||||
from unittest import TestCase
|
||||
@@ -40,17 +42,20 @@ def test(tmp_path):
|
||||
test_projects.new_c_project().generate(test_project_dir)
|
||||
|
||||
# build the wheels
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
# write python version information to a temporary file, this is
|
||||
# checked in setup.py
|
||||
'CIBW_BEFORE_TEST': '''python -c "import sys; open('/tmp/pythonversion.txt', 'w').write(sys.version)" && python -c "import sys; open('/tmp/pythonprefix.txt', 'w').write(sys.prefix)" && python -m pip install {project}/dependency''',
|
||||
'CIBW_BEFORE_TEST_WINDOWS': '''python -c "import sys; open('c:\\pythonversion.txt', 'w').write(sys.version)" && python -c "import sys; open('c:\\pythonprefix.txt', 'w').write(sys.prefix)" && python -m pip install {project}/dependency''',
|
||||
'CIBW_TEST_REQUIRES': 'nose',
|
||||
# the 'false ||' bit is to ensure this command runs in a shell on
|
||||
# mac/linux.
|
||||
'CIBW_TEST_COMMAND': 'false || nosetests {project}/test',
|
||||
'CIBW_TEST_COMMAND_WINDOWS': 'nosetests {project}/test',
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
# write python version information to a temporary file, this is
|
||||
# checked in setup.py
|
||||
'CIBW_BEFORE_TEST': '''python -c "import sys; open('/tmp/pythonversion.txt', 'w').write(sys.version)" && python -c "import sys; open('/tmp/pythonprefix.txt', 'w').write(sys.prefix)" && python -m pip install {project}/dependency''',
|
||||
'CIBW_BEFORE_TEST_WINDOWS': '''python -c "import sys; open('c:\\pythonversion.txt', 'w').write(sys.version)" && python -c "import sys; open('c:\\pythonprefix.txt', 'w').write(sys.prefix)" && python -m pip install {project}/dependency''',
|
||||
'CIBW_TEST_REQUIRES': 'nose',
|
||||
# the 'false ||' bit is to ensure this command runs in a shell on
|
||||
# mac/linux.
|
||||
'CIBW_TEST_COMMAND': 'false || nosetests {project}/test',
|
||||
'CIBW_TEST_COMMAND_WINDOWS': 'nosetests {project}/test',
|
||||
},
|
||||
)
|
||||
|
||||
# also check that we got the right wheels
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
|
||||
+14
-8
@@ -3,13 +3,15 @@ import textwrap
|
||||
from . import test_projects, utils
|
||||
|
||||
project_with_skip_asserts = test_projects.new_c_project(
|
||||
setup_py_add=textwrap.dedent(r'''
|
||||
setup_py_add=textwrap.dedent(
|
||||
r'''
|
||||
# explode if run on Python 2.7 or Python 3.7 (these should be skipped)
|
||||
if sys.version_info[0:2] == (2, 7):
|
||||
raise Exception("Python 2.7 should not be built")
|
||||
if sys.version_info[0:2] == (3, 7):
|
||||
raise Exception("Python 3.7 should be skipped")
|
||||
''')
|
||||
'''
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -18,12 +20,16 @@ def test(tmp_path):
|
||||
project_with_skip_asserts.generate(project_dir)
|
||||
|
||||
# build the wheels
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_BUILD': 'cp3?-*',
|
||||
'CIBW_SKIP': 'cp37-*',
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_BUILD': 'cp3?-*',
|
||||
'CIBW_SKIP': 'cp37-*',
|
||||
},
|
||||
)
|
||||
|
||||
# check that we got the right wheels. There should be no 2.7 or 3.7.
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if ('-cp3' in w) and ('-cp37' not in w)]
|
||||
expected_wheels = [
|
||||
w for w in utils.expected_wheels('spam', '0.1.0') if ('-cp3' in w) and ('-cp37' not in w)
|
||||
]
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
+23
-12
@@ -91,8 +91,11 @@ def test_cpp11(tmp_path):
|
||||
add_env = {'CIBW_SKIP': 'cp27-win* pp27-win32'}
|
||||
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if 'cp27-cp27m-win' not in w and 'pp27-pypy_73-win32' not in w]
|
||||
expected_wheels = [
|
||||
w
|
||||
for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if 'cp27-cp27m-win' not in w and 'pp27-pypy_73-win32' not in w
|
||||
]
|
||||
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
@@ -115,9 +118,11 @@ def test_cpp14(tmp_path):
|
||||
add_env = {'CIBW_SKIP': 'cp27-win* pp27-win32'}
|
||||
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if 'cp27-cp27m-win' not in w
|
||||
and 'pp27-pypy_73-win32' not in w]
|
||||
expected_wheels = [
|
||||
w
|
||||
for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if 'cp27-cp27m-win' not in w and 'pp27-pypy_73-win32' not in w
|
||||
]
|
||||
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
@@ -129,7 +134,9 @@ cpp17_project = cpp_test_project.copy()
|
||||
cpp17_project.template_context['extra_compile_args'] = (
|
||||
['/std:c++17', '/wd5033'] if utils.platform == 'windows' else ['-std=c++17', '-Wno-register']
|
||||
)
|
||||
cpp17_project.template_context['spam_cpp_top_level_add'] = r'''
|
||||
cpp17_project.template_context[
|
||||
'spam_cpp_top_level_add'
|
||||
] = r'''
|
||||
#include <utility>
|
||||
auto a = std::pair(5.0, false);
|
||||
'''
|
||||
@@ -152,9 +159,11 @@ def test_cpp17(tmp_path):
|
||||
add_env['MACOSX_DEPLOYMENT_TARGET'] = '10.13'
|
||||
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0', macosx_deployment_target='10.13')
|
||||
if 'cp27-cp27m-win' not in w
|
||||
and '-pp' not in w]
|
||||
expected_wheels = [
|
||||
w
|
||||
for w in utils.expected_wheels('spam', '0.1.0', macosx_deployment_target='10.13')
|
||||
if 'cp27-cp27m-win' not in w and '-pp' not in w
|
||||
]
|
||||
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
@@ -204,8 +213,10 @@ 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', exclude_27=False)
|
||||
if 'cp27-cp27m-win' in w
|
||||
or 'pp27-pypy_73-win32' in w]
|
||||
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
|
||||
]
|
||||
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
@@ -8,7 +8,8 @@ import cibuildwheel.util
|
||||
from . import test_projects, utils
|
||||
|
||||
project_with_expected_version_checks = test_projects.new_c_project(
|
||||
setup_py_add=textwrap.dedent(r'''
|
||||
setup_py_add=textwrap.dedent(
|
||||
r'''
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -30,7 +31,8 @@ project_with_expected_version_checks = test_projects.new_c_project(
|
||||
assert '{}=={}'.format(package_name, expected_version) in versions, (
|
||||
'error: {} version should equal {}'.format(package_name, expected_version)
|
||||
)
|
||||
''')
|
||||
'''
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -41,8 +43,7 @@ def get_versions_from_constraint_file(constraint_file):
|
||||
constraint_file_text = constraint_file.read_text(encoding='utf8')
|
||||
|
||||
return {
|
||||
package: version
|
||||
for package, version in re.findall(VERSION_REGEX, constraint_file_text)
|
||||
package: version for package, version in re.findall(VERSION_REGEX, constraint_file_text)
|
||||
}
|
||||
|
||||
|
||||
@@ -54,9 +55,7 @@ def test_pinned_versions(tmp_path, python_version):
|
||||
if utils.platform == 'windows' and python_version == '2.7':
|
||||
pytest.skip('Windows requires a workaround')
|
||||
|
||||
is_macos_11_or_later = (
|
||||
utils.platform == 'macos' and utils.get_macos_version() >= (10, 16)
|
||||
)
|
||||
is_macos_11_or_later = utils.platform == 'macos' and utils.get_macos_version() >= (10, 16)
|
||||
|
||||
if is_macos_11_or_later and python_version == '3.5':
|
||||
pytest.skip('CPython 3.5 doesn\'t work on macOS Big Sur+')
|
||||
@@ -89,29 +88,34 @@ def test_pinned_versions(tmp_path, python_version):
|
||||
env_name = f'EXPECTED_{package.upper()}_VERSION'
|
||||
build_environment[env_name] = constraint_versions[package]
|
||||
|
||||
cibw_environment_option = ' '.join(
|
||||
f'{k}={v}' for k, v in build_environment.items()
|
||||
)
|
||||
cibw_environment_option = ' '.join(f'{k}={v}' for k, v in build_environment.items())
|
||||
|
||||
# build and test the wheels
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_BUILD': build_pattern,
|
||||
'CIBW_ENVIRONMENT': cibw_environment_option,
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_BUILD': build_pattern,
|
||||
'CIBW_ENVIRONMENT': cibw_environment_option,
|
||||
},
|
||||
)
|
||||
|
||||
# also check that we got the right wheels
|
||||
if python_version == '2.7':
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if '-cp27' in w or '-pp27' in w]
|
||||
expected_wheels = [
|
||||
w for w in utils.expected_wheels('spam', '0.1.0') if '-cp27' in w or '-pp27' in w
|
||||
]
|
||||
elif python_version == '3.5':
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if '-cp35' in w or '-pp35' in w]
|
||||
expected_wheels = [
|
||||
w for w in utils.expected_wheels('spam', '0.1.0') if '-cp35' in w or '-pp35' in w
|
||||
]
|
||||
elif python_version == '3.6':
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if '-cp36' in w or '-pp36' in w]
|
||||
expected_wheels = [
|
||||
w for w in utils.expected_wheels('spam', '0.1.0') if '-cp36' in w or '-pp36' in w
|
||||
]
|
||||
elif python_version == '3.8':
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if '-cp38' in w or '-pp38' in w]
|
||||
expected_wheels = [
|
||||
w for w in utils.expected_wheels('spam', '0.1.0') if '-cp38' in w or '-pp38' in w
|
||||
]
|
||||
else:
|
||||
raise ValueError('unhandled python version')
|
||||
|
||||
@@ -137,14 +141,18 @@ def test_dependency_constraints_file(tmp_path, python_version):
|
||||
}
|
||||
|
||||
constraints_file = tmp_path / 'constraints.txt'
|
||||
constraints_file.write_text(textwrap.dedent(
|
||||
'''
|
||||
constraints_file.write_text(
|
||||
textwrap.dedent(
|
||||
'''
|
||||
pip=={pip}
|
||||
setuptools=={setuptools}
|
||||
wheel=={wheel}
|
||||
virtualenv=={virtualenv}
|
||||
'''.format(**tool_versions)
|
||||
))
|
||||
'''.format(
|
||||
**tool_versions
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
build_environment = {}
|
||||
|
||||
@@ -152,23 +160,28 @@ def test_dependency_constraints_file(tmp_path, python_version):
|
||||
env_name = f'EXPECTED_{package_name.upper()}_VERSION'
|
||||
build_environment[env_name] = version
|
||||
|
||||
cibw_environment_option = ' '.join(
|
||||
f'{k}={v}' for k, v in build_environment.items()
|
||||
)
|
||||
cibw_environment_option = ' '.join(f'{k}={v}' for k, v in build_environment.items())
|
||||
|
||||
# build and test the wheels
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_BUILD': '[cp]p27-*' if python_version == '2.7' else '[cp]p3?-*',
|
||||
'CIBW_ENVIRONMENT': cibw_environment_option,
|
||||
'CIBW_DEPENDENCY_VERSIONS': str(constraints_file),
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_BUILD': '[cp]p27-*' if python_version == '2.7' else '[cp]p3?-*',
|
||||
'CIBW_ENVIRONMENT': cibw_environment_option,
|
||||
'CIBW_DEPENDENCY_VERSIONS': str(constraints_file),
|
||||
},
|
||||
)
|
||||
|
||||
# also check that we got the right wheels
|
||||
if python_version == '2.7':
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if '-cp27' in w or '-pp27' in w]
|
||||
expected_wheels = [
|
||||
w for w in utils.expected_wheels('spam', '0.1.0') if '-cp27' in w or '-pp27' in w
|
||||
]
|
||||
else:
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if '-cp27' not in w and '-pp27' not in w]
|
||||
expected_wheels = [
|
||||
w
|
||||
for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if '-cp27' not in w and '-pp27' not in w
|
||||
]
|
||||
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
+20
-10
@@ -6,7 +6,8 @@ import pytest
|
||||
from . import test_projects, utils
|
||||
|
||||
dockcross_only_project = test_projects.new_c_project(
|
||||
setup_py_add=textwrap.dedent(r'''
|
||||
setup_py_add=textwrap.dedent(
|
||||
r'''
|
||||
import os
|
||||
|
||||
# check that we're running in the correct docker image as specified in the
|
||||
@@ -15,7 +16,8 @@ dockcross_only_project = test_projects.new_c_project(
|
||||
raise Exception(
|
||||
"/dockcross directory not found. Is this test running in the correct docker image?"
|
||||
)
|
||||
''')
|
||||
'''
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -23,18 +25,26 @@ def test(tmp_path):
|
||||
if utils.platform != 'linux':
|
||||
pytest.skip('the test is only relevant to the linux build')
|
||||
if platform.machine() not in ['x86_64', 'i686']:
|
||||
pytest.skip('this test is currently only possible on x86_64/i686 due to availability of alternative images')
|
||||
pytest.skip(
|
||||
'this test is currently only possible on x86_64/i686 due to availability of alternative images'
|
||||
)
|
||||
|
||||
project_dir = tmp_path / 'project'
|
||||
dockcross_only_project.generate(project_dir)
|
||||
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_MANYLINUX_X86_64_IMAGE': 'dockcross/manylinux2010-x64',
|
||||
'CIBW_MANYLINUX_I686_IMAGE': 'dockcross/manylinux2010-x86',
|
||||
'CIBW_SKIP': 'pp* cp27-* cp39-*',
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_MANYLINUX_X86_64_IMAGE': 'dockcross/manylinux2010-x64',
|
||||
'CIBW_MANYLINUX_I686_IMAGE': 'dockcross/manylinux2010-x86',
|
||||
'CIBW_SKIP': 'pp* cp27-* cp39-*',
|
||||
},
|
||||
)
|
||||
|
||||
# also check that we got the right wheels built
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if '-pp' not in w and '-cp39-' not in w and '-cp27-' not in w]
|
||||
expected_wheels = [
|
||||
w
|
||||
for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if '-pp' not in w and '-cp39-' not in w and '-cp27-' not in w
|
||||
]
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
+17
-9
@@ -6,7 +6,9 @@ from . import test_projects, utils
|
||||
|
||||
project_with_a_test = test_projects.new_c_project()
|
||||
|
||||
project_with_a_test.files['test/spam_test.py'] = r'''
|
||||
project_with_a_test.files[
|
||||
'test/spam_test.py'
|
||||
] = r'''
|
||||
import spam
|
||||
|
||||
def test_spam():
|
||||
@@ -21,11 +23,14 @@ def test(tmp_path):
|
||||
project_with_a_test.generate(project_dir)
|
||||
|
||||
# build and test the wheels
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_TEST_REQUIRES': 'pytest',
|
||||
'CIBW_TEST_COMMAND': 'pytest {project}/test',
|
||||
'CIBW_ARCHS': 'aarch64 ppc64le s390x',
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_TEST_REQUIRES': 'pytest',
|
||||
'CIBW_TEST_COMMAND': 'pytest {project}/test',
|
||||
'CIBW_ARCHS': 'aarch64 ppc64le s390x',
|
||||
},
|
||||
)
|
||||
|
||||
# also check that we got the right wheels
|
||||
expected_wheels = (
|
||||
@@ -45,9 +50,12 @@ def test_setting_arch_on_other_platforms(tmp_path, capfd):
|
||||
|
||||
# build and test the wheels
|
||||
with pytest.raises(subprocess.CalledProcessError):
|
||||
utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_ARCHS': 'aarch64',
|
||||
})
|
||||
utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_ARCHS': 'aarch64',
|
||||
},
|
||||
)
|
||||
|
||||
captured = capfd.readouterr()
|
||||
assert "Invalid archs option" in captured.err
|
||||
|
||||
+27
-14
@@ -7,7 +7,8 @@ import pytest
|
||||
from . import test_projects, utils
|
||||
|
||||
project_with_environment_asserts = test_projects.new_c_project(
|
||||
setup_py_add=textwrap.dedent(r'''
|
||||
setup_py_add=textwrap.dedent(
|
||||
r'''
|
||||
import os
|
||||
|
||||
# explode if environment isn't correct, as set in CIBW_ENVIRONMENT
|
||||
@@ -26,7 +27,8 @@ project_with_environment_asserts = test_projects.new_c_project(
|
||||
raise Exception('PATH should contain "/opt/cibw_test_path". It was "%s"' % PATH)
|
||||
if "$PATH" in PATH:
|
||||
raise Exception('$PATH should be expanded in PATH. It was "%s"' % PATH)
|
||||
''')
|
||||
'''
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -37,10 +39,13 @@ def test(tmp_path):
|
||||
# write some information into the CIBW_ENVIRONMENT, for expansion and
|
||||
# insertion into the environment by cibuildwheel. This is checked
|
||||
# in setup.py
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_ENVIRONMENT': '''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH=$PATH:/opt/cibw_test_path''',
|
||||
'CIBW_ENVIRONMENT_WINDOWS': '''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH="$PATH;/opt/cibw_test_path"''',
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_ENVIRONMENT': '''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH=$PATH:/opt/cibw_test_path''',
|
||||
'CIBW_ENVIRONMENT_WINDOWS': '''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH="$PATH;/opt/cibw_test_path"''',
|
||||
},
|
||||
)
|
||||
|
||||
# also check that we got the right wheels built
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
@@ -58,19 +63,27 @@ def test_overridden_path(tmp_path, capfd):
|
||||
# mess up PATH, somehow
|
||||
with pytest.raises(subprocess.CalledProcessError):
|
||||
if utils.platform == 'linux':
|
||||
utils.cibuildwheel_run(project_dir, output_dir=output_dir, add_env={
|
||||
'CIBW_BEFORE_ALL': 'mkdir new_path && touch new_path/python && chmod +x new_path/python',
|
||||
'CIBW_ENVIRONMENT': '''PATH="$(pwd)/new_path:$PATH"''',
|
||||
})
|
||||
utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
output_dir=output_dir,
|
||||
add_env={
|
||||
'CIBW_BEFORE_ALL': 'mkdir new_path && touch new_path/python && chmod +x new_path/python',
|
||||
'CIBW_ENVIRONMENT': '''PATH="$(pwd)/new_path:$PATH"''',
|
||||
},
|
||||
)
|
||||
else:
|
||||
new_path = tmp_path / 'another_bin'
|
||||
new_path.mkdir()
|
||||
(new_path / 'python').touch(mode=0o777)
|
||||
|
||||
utils.cibuildwheel_run(project_dir, output_dir=output_dir, add_env={
|
||||
'NEW_PATH': str(new_path),
|
||||
'CIBW_ENVIRONMENT': f'''PATH="$NEW_PATH{os.pathsep}$PATH"''',
|
||||
})
|
||||
utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
output_dir=output_dir,
|
||||
add_env={
|
||||
'NEW_PATH': str(new_path),
|
||||
'CIBW_ENVIRONMENT': f'''PATH="$NEW_PATH{os.pathsep}$PATH"''',
|
||||
},
|
||||
)
|
||||
|
||||
assert len(os.listdir(output_dir)) == 0
|
||||
captured = capfd.readouterr()
|
||||
|
||||
+32
-18
@@ -10,7 +10,7 @@ basic_project = test_projects.new_c_project()
|
||||
|
||||
ALL_MACOS_WHEELS = {
|
||||
*utils.expected_wheels('spam', '0.1.0', machine_arch='x86_64'),
|
||||
*utils.expected_wheels('spam', '0.1.0', machine_arch='arm64')
|
||||
*utils.expected_wheels('spam', '0.1.0', machine_arch='arm64'),
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,13 @@ def test_cross_compiled_build(tmp_path):
|
||||
project_dir = tmp_path / 'project'
|
||||
basic_project.generate(project_dir)
|
||||
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_BUILD': 'cp39-*',
|
||||
'CIBW_ARCHS': 'x86_64, universal2, arm64',
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_BUILD': 'cp39-*',
|
||||
'CIBW_ARCHS': 'x86_64, universal2, arm64',
|
||||
},
|
||||
)
|
||||
|
||||
expected_wheels = [w for w in ALL_MACOS_WHEELS if 'cp39' in w]
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
@@ -56,11 +59,14 @@ def test_cross_compiled_test(tmp_path, capfd, build_universal2):
|
||||
project_dir = tmp_path / 'project'
|
||||
basic_project.generate(project_dir)
|
||||
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_BUILD': 'cp39-*',
|
||||
'CIBW_TEST_COMMAND': '''python -c "import platform; print('running tests on ' + platform.machine())"''',
|
||||
'CIBW_ARCHS': 'universal2' if build_universal2 else 'x86_64 arm64',
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_BUILD': 'cp39-*',
|
||||
'CIBW_TEST_COMMAND': '''python -c "import platform; print('running tests on ' + platform.machine())"''',
|
||||
'CIBW_ARCHS': 'universal2' if build_universal2 else 'x86_64 arm64',
|
||||
},
|
||||
)
|
||||
|
||||
captured = capfd.readouterr()
|
||||
|
||||
@@ -69,9 +75,14 @@ def test_cross_compiled_test(tmp_path, capfd, build_universal2):
|
||||
assert 'running tests on x86_64' in captured.out
|
||||
assert 'running tests on arm64' not in captured.out
|
||||
if build_universal2:
|
||||
assert 'While universal2 wheels can be built on x86_64, the arm64 part of them cannot currently be tested' in captured.err
|
||||
assert (
|
||||
'While universal2 wheels can be built on x86_64, the arm64 part of them cannot currently be tested'
|
||||
in captured.err
|
||||
)
|
||||
else:
|
||||
assert 'While arm64 wheels can be built on x86_64, they cannot be tested' in captured.err
|
||||
assert (
|
||||
'While arm64 wheels can be built on x86_64, they cannot be tested' in captured.err
|
||||
)
|
||||
elif platform.machine() == 'arm64':
|
||||
# ensure that tests were run on both x86_64 and arm64
|
||||
assert 'running tests on x86_64' in captured.out
|
||||
@@ -97,12 +108,15 @@ def test_universal2_testing(tmp_path, capfd, skip_arm64_test):
|
||||
project_dir = tmp_path / 'project'
|
||||
basic_project.generate(project_dir)
|
||||
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_BUILD': 'cp39-*',
|
||||
'CIBW_TEST_COMMAND': '''python -c "import platform; print('running tests on ' + platform.machine())"''',
|
||||
'CIBW_ARCHS': 'universal2',
|
||||
'CIBW_TEST_SKIP': '*_universal2:arm64' if skip_arm64_test else '',
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_BUILD': 'cp39-*',
|
||||
'CIBW_TEST_COMMAND': '''python -c "import platform; print('running tests on ' + platform.machine())"''',
|
||||
'CIBW_ARCHS': 'universal2',
|
||||
'CIBW_TEST_SKIP': '*_universal2:arm64' if skip_arm64_test else '',
|
||||
},
|
||||
)
|
||||
|
||||
captured = capfd.readouterr()
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ from . import test_projects, utils
|
||||
|
||||
# TODO: specify these at runtime according to manylinux_image
|
||||
project_with_manylinux_symbols = test_projects.new_c_project(
|
||||
spam_c_top_level_add=textwrap.dedent(r'''
|
||||
spam_c_top_level_add=textwrap.dedent(
|
||||
r'''
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -20,8 +21,10 @@ project_with_manylinux_symbols = test_projects.new_c_project(
|
||||
#if !__GLIBC_PREREQ(2, 5) /* manylinux1 is glibc 2.5 */
|
||||
#error "Must run on a glibc >= 2.5 linux environment"
|
||||
#endif
|
||||
'''),
|
||||
spam_c_function_add=textwrap.dedent(r'''
|
||||
'''
|
||||
),
|
||||
spam_c_function_add=textwrap.dedent(
|
||||
r'''
|
||||
#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 24)
|
||||
// nextupf is only available in manylinux_2_24+
|
||||
sts = (int)nextupf(0.0F);
|
||||
@@ -32,11 +35,14 @@ project_with_manylinux_symbols = test_projects.new_c_project(
|
||||
// malloc_info is only available on manylinux2010+
|
||||
sts = malloc_info(0, stdout);
|
||||
#endif
|
||||
'''),
|
||||
'''
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('manylinux_image', ['manylinux1', 'manylinux2010', 'manylinux2014', 'manylinux_2_24'])
|
||||
@pytest.mark.parametrize(
|
||||
'manylinux_image', ['manylinux1', 'manylinux2010', 'manylinux2014', 'manylinux_2_24']
|
||||
)
|
||||
def test(manylinux_image, tmp_path):
|
||||
if utils.platform != 'linux':
|
||||
pytest.skip('the docker test is only relevant to the linux build')
|
||||
@@ -68,7 +74,9 @@ def test(manylinux_image, tmp_path):
|
||||
add_env['CIBW_SKIP'] = 'cp27* pp*'
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
|
||||
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0', manylinux_versions=[manylinux_image])]
|
||||
expected_wheels = [
|
||||
w for w in utils.expected_wheels('spam', '0.1.0', manylinux_versions=[manylinux_image])
|
||||
]
|
||||
if manylinux_image in {'manylinux2014', 'manylinux_2_24'}:
|
||||
expected_wheels = [w for w in expected_wheels if '-cp27' not in w]
|
||||
if manylinux_image in {'manylinux1', 'manylinux2014', 'manylinux_2_24'}:
|
||||
|
||||
@@ -8,18 +8,28 @@ from pathlib import Path
|
||||
|
||||
def main():
|
||||
parser = ArgumentParser(
|
||||
prog="python -m test.test_projects",
|
||||
description='Generate a test project to check it out'
|
||||
prog="python -m test.test_projects", description='Generate a test project to check it out'
|
||||
)
|
||||
parser.add_argument('--open', action='store_true', help='''
|
||||
parser.add_argument(
|
||||
'--open',
|
||||
action='store_true',
|
||||
help='''
|
||||
Open the generated project in a file explorer
|
||||
''')
|
||||
parser.add_argument('PROJECT', help='''
|
||||
''',
|
||||
)
|
||||
parser.add_argument(
|
||||
'PROJECT',
|
||||
help='''
|
||||
Python path to a project object. E.g. test.test_0_basic.basic_project
|
||||
''')
|
||||
parser.add_argument('OUTPUT', nargs='?', help='''
|
||||
''',
|
||||
)
|
||||
parser.add_argument(
|
||||
'OUTPUT',
|
||||
nargs='?',
|
||||
help='''
|
||||
Path to output dir. If no dir is passed, a tempdir will be generated.
|
||||
''')
|
||||
''',
|
||||
)
|
||||
options = parser.parse_args()
|
||||
|
||||
module, _, name = options.PROJECT.rpartition('.')
|
||||
|
||||
@@ -14,6 +14,7 @@ class TestProject:
|
||||
|
||||
Write out to the filesystem using `generate`.
|
||||
'''
|
||||
|
||||
__test__ = False # Have pytest ignore this class on `from .test_projects import TestProject`
|
||||
|
||||
files: FilesDict
|
||||
|
||||
+24
-14
@@ -88,22 +88,32 @@ version = 0.1.0
|
||||
'''
|
||||
|
||||
|
||||
def new_c_project(*, spam_c_top_level_add='', spam_c_function_add='', setup_py_add='',
|
||||
setup_py_setup_args_add='', setup_cfg_add=''):
|
||||
def new_c_project(
|
||||
*,
|
||||
spam_c_top_level_add='',
|
||||
spam_c_function_add='',
|
||||
setup_py_add='',
|
||||
setup_py_setup_args_add='',
|
||||
setup_cfg_add='',
|
||||
):
|
||||
project = TestProject()
|
||||
|
||||
project.files.update({
|
||||
'spam.c': jinja2.Template(SPAM_C_TEMPLATE),
|
||||
'setup.py': jinja2.Template(SETUP_PY_TEMPLATE),
|
||||
'setup.cfg': jinja2.Template(SETUP_CFG_TEMPLATE),
|
||||
})
|
||||
project.files.update(
|
||||
{
|
||||
'spam.c': jinja2.Template(SPAM_C_TEMPLATE),
|
||||
'setup.py': jinja2.Template(SETUP_PY_TEMPLATE),
|
||||
'setup.cfg': jinja2.Template(SETUP_CFG_TEMPLATE),
|
||||
}
|
||||
)
|
||||
|
||||
project.template_context.update({
|
||||
'spam_c_top_level_add': spam_c_top_level_add,
|
||||
'spam_c_function_add': spam_c_function_add,
|
||||
'setup_py_add': setup_py_add,
|
||||
'setup_py_setup_args_add': setup_py_setup_args_add,
|
||||
'setup_cfg_add': setup_cfg_add,
|
||||
})
|
||||
project.template_context.update(
|
||||
{
|
||||
'spam_c_top_level_add': spam_c_top_level_add,
|
||||
'spam_c_function_add': spam_c_function_add,
|
||||
'setup_py_add': setup_py_add,
|
||||
'setup_py_setup_args_add': setup_py_setup_args_add,
|
||||
'setup_cfg_add': setup_cfg_add,
|
||||
}
|
||||
)
|
||||
|
||||
return project
|
||||
|
||||
@@ -6,7 +6,9 @@ import pytest
|
||||
from . import utils
|
||||
|
||||
pure_python_project = test_projects.TestProject()
|
||||
pure_python_project.files['setup.py'] = '''
|
||||
pure_python_project.files[
|
||||
'setup.py'
|
||||
] = '''
|
||||
from setuptools import Extension, setup
|
||||
|
||||
setup(
|
||||
@@ -16,7 +18,9 @@ setup(
|
||||
)
|
||||
'''
|
||||
|
||||
pure_python_project.files['spam.py'] = '''
|
||||
pure_python_project.files[
|
||||
'spam.py'
|
||||
] = '''
|
||||
def a_function():
|
||||
pass
|
||||
'''
|
||||
|
||||
+4
-2
@@ -3,7 +3,8 @@ import textwrap
|
||||
from . import test_projects, utils
|
||||
|
||||
project_with_ssl_tests = test_projects.new_c_project(
|
||||
setup_py_add=textwrap.dedent(r'''
|
||||
setup_py_add=textwrap.dedent(
|
||||
r'''
|
||||
import ssl
|
||||
|
||||
if sys.version_info[0] == 2:
|
||||
@@ -15,7 +16,8 @@ project_with_ssl_tests = test_projects.new_c_project(
|
||||
data = urlopen("https://www.nist.gov", context=context)
|
||||
data = urlopen("https://raw.githubusercontent.com/joerick/cibuildwheel/master/CI.md", context=context)
|
||||
data = urlopen("https://raw.githubusercontent.com/joerick/cibuildwheel/master/CI.md")
|
||||
''')
|
||||
'''
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
+20
-11
@@ -12,7 +12,9 @@ subdir_package_project.files['src/spam/spam.c'] = jinja2.Template(SPAM_C_TEMPLAT
|
||||
subdir_package_project.template_context['spam_c_top_level_add'] = ''
|
||||
subdir_package_project.template_context['spam_c_function_add'] = ''
|
||||
|
||||
subdir_package_project.files['src/spam/setup.py'] = r'''
|
||||
subdir_package_project.files[
|
||||
'src/spam/setup.py'
|
||||
] = r'''
|
||||
from setuptools import Extension, setup
|
||||
|
||||
setup(
|
||||
@@ -22,11 +24,15 @@ setup(
|
||||
)
|
||||
'''
|
||||
|
||||
subdir_package_project.files['src/spam/test/run_tests.py'] = r'''
|
||||
subdir_package_project.files[
|
||||
'src/spam/test/run_tests.py'
|
||||
] = r'''
|
||||
print('run_tests.py executed!')
|
||||
'''
|
||||
|
||||
subdir_package_project.files['bin/before_build.py'] = r'''
|
||||
subdir_package_project.files[
|
||||
'bin/before_build.py'
|
||||
] = r'''
|
||||
print('before_build.py executed!')
|
||||
'''
|
||||
|
||||
@@ -37,16 +43,19 @@ def test(capfd, tmp_path):
|
||||
|
||||
package_dir = Path('src', 'spam')
|
||||
# build the wheels
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, package_dir=package_dir, add_env={
|
||||
'CIBW_BEFORE_BUILD': 'python {project}/bin/before_build.py',
|
||||
'CIBW_TEST_COMMAND': 'python {package}/test/run_tests.py',
|
||||
# this shouldn't depend on the version of python, so build only CPython 3.6
|
||||
'CIBW_BUILD': 'cp36-*',
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
package_dir=package_dir,
|
||||
add_env={
|
||||
'CIBW_BEFORE_BUILD': 'python {project}/bin/before_build.py',
|
||||
'CIBW_TEST_COMMAND': 'python {package}/test/run_tests.py',
|
||||
# this shouldn't depend on the version of python, so build only CPython 3.6
|
||||
'CIBW_BUILD': 'cp36-*',
|
||||
},
|
||||
)
|
||||
|
||||
# check that the expected wheels are produced
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if 'cp36' in w]
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0') if 'cp36' in w]
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
captured = capfd.readouterr()
|
||||
|
||||
+42
-26
@@ -7,13 +7,17 @@ import pytest
|
||||
from . import test_projects, utils
|
||||
|
||||
project_with_a_test = test_projects.new_c_project(
|
||||
setup_cfg_add=textwrap.dedent(r'''
|
||||
setup_cfg_add=textwrap.dedent(
|
||||
r'''
|
||||
[options.extras_require]
|
||||
test = nose
|
||||
''')
|
||||
'''
|
||||
)
|
||||
)
|
||||
|
||||
project_with_a_test.files['test/spam_test.py'] = r'''
|
||||
project_with_a_test.files[
|
||||
'test/spam_test.py'
|
||||
] = r'''
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
@@ -75,13 +79,16 @@ def test(tmp_path):
|
||||
project_with_a_test.generate(project_dir)
|
||||
|
||||
# build and test the wheels
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_TEST_REQUIRES': 'nose',
|
||||
# the 'false ||' bit is to ensure this command runs in a shell on
|
||||
# mac/linux.
|
||||
'CIBW_TEST_COMMAND': 'false || nosetests {project}/test',
|
||||
'CIBW_TEST_COMMAND_WINDOWS': 'COLOR 00 || nosetests {project}/test',
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_TEST_REQUIRES': 'nose',
|
||||
# the 'false ||' bit is to ensure this command runs in a shell on
|
||||
# mac/linux.
|
||||
'CIBW_TEST_COMMAND': 'false || nosetests {project}/test',
|
||||
'CIBW_TEST_COMMAND_WINDOWS': 'COLOR 00 || nosetests {project}/test',
|
||||
},
|
||||
)
|
||||
|
||||
# also check that we got the right wheels
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
@@ -93,13 +100,16 @@ def test_extras_require(tmp_path):
|
||||
project_with_a_test.generate(project_dir)
|
||||
|
||||
# build and test the wheels
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_TEST_EXTRAS': 'test',
|
||||
# the 'false ||' bit is to ensure this command runs in a shell on
|
||||
# mac/linux.
|
||||
'CIBW_TEST_COMMAND': 'false || nosetests {project}/test',
|
||||
'CIBW_TEST_COMMAND_WINDOWS': 'COLOR 00 || nosetests {project}/test',
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
'CIBW_TEST_EXTRAS': 'test',
|
||||
# the 'false ||' bit is to ensure this command runs in a shell on
|
||||
# mac/linux.
|
||||
'CIBW_TEST_COMMAND': 'false || nosetests {project}/test',
|
||||
'CIBW_TEST_COMMAND_WINDOWS': 'COLOR 00 || nosetests {project}/test',
|
||||
},
|
||||
)
|
||||
|
||||
# also check that we got the right wheels
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
@@ -107,7 +117,9 @@ def test_extras_require(tmp_path):
|
||||
|
||||
|
||||
project_with_a_failing_test = test_projects.new_c_project()
|
||||
project_with_a_failing_test.files['test/spam_test.py'] = r'''
|
||||
project_with_a_failing_test.files[
|
||||
'test/spam_test.py'
|
||||
] = r'''
|
||||
from unittest import TestCase
|
||||
|
||||
class TestSpam(TestCase):
|
||||
@@ -123,13 +135,17 @@ def test_failing_test(tmp_path):
|
||||
project_with_a_failing_test.generate(project_dir)
|
||||
|
||||
with pytest.raises(subprocess.CalledProcessError):
|
||||
utils.cibuildwheel_run(project_dir, output_dir=output_dir, add_env={
|
||||
'CIBW_TEST_REQUIRES': 'nose',
|
||||
'CIBW_TEST_COMMAND': 'nosetests {project}/test',
|
||||
# manylinux1 has a version of bash that's been shown to have
|
||||
# problems with this, so let's check that.
|
||||
'CIBW_MANYLINUX_I686_IMAGE': 'manylinux1',
|
||||
'CIBW_MANYLINUX_X86_64_IMAGE': 'manylinux1',
|
||||
})
|
||||
utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
output_dir=output_dir,
|
||||
add_env={
|
||||
'CIBW_TEST_REQUIRES': 'nose',
|
||||
'CIBW_TEST_COMMAND': 'nosetests {project}/test',
|
||||
# manylinux1 has a version of bash that's been shown to have
|
||||
# problems with this, so let's check that.
|
||||
'CIBW_MANYLINUX_I686_IMAGE': 'manylinux1',
|
||||
'CIBW_MANYLINUX_X86_64_IMAGE': 'manylinux1',
|
||||
},
|
||||
)
|
||||
|
||||
assert len(os.listdir(output_dir)) == 0
|
||||
|
||||
@@ -9,7 +9,9 @@ so_file_project = TestProject()
|
||||
|
||||
so_file_project.files['libnothing.so'] = ''
|
||||
|
||||
so_file_project.files['setup.py'] = '''
|
||||
so_file_project.files[
|
||||
'setup.py'
|
||||
] = '''
|
||||
raise Exception('this build will fail')
|
||||
'''
|
||||
|
||||
|
||||
@@ -5,11 +5,13 @@ import pytest
|
||||
from . import test_projects, utils
|
||||
|
||||
project_with_unicode = test_projects.new_c_project(
|
||||
spam_c_function_add=textwrap.dedent(r'''
|
||||
spam_c_function_add=textwrap.dedent(
|
||||
r'''
|
||||
{
|
||||
Py_XDECREF(PyUnicode_FromStringAndSize("foo", 4));
|
||||
}
|
||||
'''),
|
||||
'''
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -21,9 +23,9 @@ def test(tmp_path):
|
||||
project_with_unicode.generate(project_dir)
|
||||
|
||||
# build the wheels
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
'CIBW_TEST_COMMAND': 'python -c "import spam"'
|
||||
})
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir, add_env={'CIBW_TEST_COMMAND': 'python -c "import spam"'}
|
||||
)
|
||||
|
||||
# check that the expected wheels are produced
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
|
||||
+20
-5
@@ -78,7 +78,14 @@ def cibuildwheel_run(project_path, package_dir='.', env=None, add_env=None, outp
|
||||
|
||||
with TemporaryDirectoryIfNone(output_dir) as _output_dir:
|
||||
subprocess.run(
|
||||
[sys.executable, '-m', 'cibuildwheel', '--output-dir', str(_output_dir), str(package_dir)],
|
||||
[
|
||||
sys.executable,
|
||||
'-m',
|
||||
'cibuildwheel',
|
||||
'--output-dir',
|
||||
str(_output_dir),
|
||||
str(package_dir),
|
||||
],
|
||||
env=env,
|
||||
cwd=project_path,
|
||||
check=True,
|
||||
@@ -100,9 +107,15 @@ def _get_arm64_macosx_deployment_target(macosx_deployment_target: str) -> str:
|
||||
return macosx_deployment_target
|
||||
|
||||
|
||||
def expected_wheels(package_name, package_version, manylinux_versions=None,
|
||||
macosx_deployment_target='10.9', machine_arch=None, *,
|
||||
exclude_27=platform == 'windows'):
|
||||
def expected_wheels(
|
||||
package_name,
|
||||
package_version,
|
||||
manylinux_versions=None,
|
||||
macosx_deployment_target='10.9',
|
||||
machine_arch=None,
|
||||
*,
|
||||
exclude_27=platform == 'windows',
|
||||
):
|
||||
'''
|
||||
Returns a list of expected wheels from a run of cibuildwheel.
|
||||
'''
|
||||
@@ -164,7 +177,9 @@ def expected_wheels(package_name, package_version, manylinux_versions=None,
|
||||
|
||||
elif platform == 'macos':
|
||||
if python_abi_tag == 'cp39-cp39' and machine_arch == 'arm64':
|
||||
arm64_macosx_deployment_target = _get_arm64_macosx_deployment_target(macosx_deployment_target)
|
||||
arm64_macosx_deployment_target = _get_arm64_macosx_deployment_target(
|
||||
macosx_deployment_target
|
||||
)
|
||||
platform_tags = [
|
||||
f'macosx_{macosx_deployment_target.replace(".", "_")}_universal2',
|
||||
f'macosx_{arm64_macosx_deployment_target.replace(".", "_")}_arm64',
|
||||
|
||||
Reference in New Issue
Block a user