Files
cibuildwheel/test/test_subdir_package.py
T

57 lines
1.6 KiB
Python
Raw Normal View History

2020-06-18 02:00:30 +02:00
from pathlib import Path
2020-05-03 14:09:47 +01:00
import jinja2
2020-05-02 22:42:35 +01:00
from . import utils
from .test_projects import TestProject
from .test_projects.c import SPAM_C_TEMPLATE
subdir_package_project = TestProject()
2021-05-03 11:45:43 -04:00
subdir_package_project.files["src/spam/spam.c"] = jinja2.Template(SPAM_C_TEMPLATE)
subdir_package_project.template_context["spam_c_top_level_add"] = ""
subdir_package_project.template_context["spam_c_function_add"] = ""
2023-10-27 01:21:20 -04: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",
)
2021-05-03 11:45:43 -04:00
"""
2023-10-27 01:21:20 -04:00
subdir_package_project.files["src/spam/test/run_tests.py"] = r"""
print('run_tests.py executed!')
2021-05-03 11:45:43 -04:00
"""
2023-10-27 01:21:20 -04:00
subdir_package_project.files["bin/before_build.py"] = r"""
print('before_build.py executed!')
2021-05-03 11:45:43 -04:00
"""
2020-05-03 14:08:57 +01:00
def test(capfd, tmp_path):
2021-05-03 11:45:43 -04:00
project_dir = tmp_path / "project"
subdir_package_project.generate(project_dir)
2021-05-03 11:45:43 -04:00
package_dir = Path("src", "spam")
# build the wheels
2021-04-30 17:56:34 -04:00
actual_wheels = utils.cibuildwheel_run(
project_dir,
package_dir=package_dir,
add_env={
2021-05-03 11:45:43 -04:00
"CIBW_BEFORE_BUILD": "python {project}/bin/before_build.py",
"CIBW_TEST_COMMAND": "python {package}/test/run_tests.py",
2021-04-30 17:56:34 -04:00
},
2024-05-26 12:41:20 +02:00
single_python=True,
2021-04-30 17:56:34 -04:00
)
# check that the expected wheels are produced
2024-05-26 12:41:20 +02:00
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
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