2020-04-10 17:42:39 +01:00
|
|
|
import os
|
2020-05-03 14:09:47 +01:00
|
|
|
|
|
|
|
|
import jinja2
|
|
|
|
|
|
2020-05-02 22:42:35 +01:00
|
|
|
from . import utils
|
2020-05-17 16:54:33 +01:00
|
|
|
from .test_projects import TestProject
|
|
|
|
|
from .test_projects.c import SPAM_C_TEMPLATE
|
2020-04-10 17:42:39 +01:00
|
|
|
|
2020-05-17 16:54:33 +01:00
|
|
|
subdir_package_project = TestProject()
|
2020-05-02 21:00:58 +01:00
|
|
|
|
2020-05-15 12:28:34 +01:00
|
|
|
subdir_package_project.files['src/spam/spam.c'] = jinja2.Template(SPAM_C_TEMPLATE)
|
2020-05-03 14:09:47 +01:00
|
|
|
subdir_package_project.template_context['spam_c_top_level_add'] = ''
|
|
|
|
|
subdir_package_project.template_context['spam_c_function_add'] = ''
|
2020-05-02 21:00:58 +01:00
|
|
|
|
|
|
|
|
subdir_package_project.files['src/spam/setup.py'] = r'''
|
|
|
|
|
from setuptools import Extension, setup
|
|
|
|
|
|
|
|
|
|
setup(
|
|
|
|
|
name="spam",
|
|
|
|
|
ext_modules=[Extension('spam', sources=['spam.c'])],
|
|
|
|
|
version="0.1.0",
|
|
|
|
|
)
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
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'''
|
|
|
|
|
print('before_build.py executed!')
|
|
|
|
|
'''
|
2020-04-10 17:42:39 +01:00
|
|
|
|
|
|
|
|
|
2020-05-03 14:08:57 +01:00
|
|
|
def test(capfd, tmp_path):
|
|
|
|
|
project_dir = tmp_path / 'project'
|
2020-05-02 21:00:58 +01:00
|
|
|
subdir_package_project.generate(project_dir)
|
|
|
|
|
|
2020-06-06 20:05:09 +02:00
|
|
|
package_dir = os.path.join('src', 'spam')
|
2020-04-10 17:42:39 +01:00
|
|
|
# build the wheels
|
|
|
|
|
actual_wheels = utils.cibuildwheel_run(project_dir, package_dir=package_dir, add_env={
|
2020-04-11 09:39:25 +01:00
|
|
|
'CIBW_BEFORE_BUILD': 'python {project}/bin/before_build.py',
|
2020-04-10 17:42:39 +01:00
|
|
|
'CIBW_TEST_COMMAND': 'python {package}/test/run_tests.py',
|
2020-05-02 22:42:35 +01:00
|
|
|
# this shouldn't depend on the version of python, so build only CPython 3.6
|
2020-04-10 17:42:39 +01:00
|
|
|
'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]
|
|
|
|
|
assert set(actual_wheels) == set(expected_wheels)
|
2020-04-12 23:15:49 +01:00
|
|
|
|
|
|
|
|
captured = capfd.readouterr()
|
|
|
|
|
assert "before_build.py executed!" in captured.out
|
|
|
|
|
assert "run_tests.py executed!" in captured.out
|