Skip to content

Commit

Permalink
chore(tests): run a project with tests using build[uv] frontend (#1880
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mayeut committed Jun 17, 2024
1 parent 932529c commit c1b8a12
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
7 changes: 2 additions & 5 deletions cibuildwheel/pyodide.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
BuildSelector,
NonPlatformWheelError,
call,
combine_constraints,
download,
ensure_node,
extract_zip,
Expand Down Expand Up @@ -285,11 +286,7 @@ def build(options: Options, tmp_path: Path) -> None:

build_env = env.copy()
if build_options.dependency_constraints:
our_constraints = str(constraints_path)
user_constraints = build_env.get("PIP_CONSTRAINT")
build_env["PIP_CONSTRAINT"] = " ".join(
c for c in [our_constraints, user_constraints] if c
)
combine_constraints(build_env, constraints_path, identifier_tmp_dir)
build_env["VIRTUALENV_PIP"] = pip_version
call(
"pyodide",
Expand Down
18 changes: 9 additions & 9 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ def pytest_addoption(parser) -> None:
)


@pytest.fixture(
params=[{"CIBW_BUILD_FRONTEND": "pip"}, {"CIBW_BUILD_FRONTEND": "build"}], ids=["pip", "build"]
)
def build_frontend_env_nouv(request) -> dict[str, str]:
if platform == "pyodide":
@pytest.fixture(params=["pip", "build"])
def build_frontend_env_nouv(request: pytest.FixtureRequest) -> dict[str, str]:
frontend = request.param
if platform == "pyodide" and frontend == "pip":
pytest.skip("Can't use pip as build frontend for pyodide platform")

return request.param # type: ignore[no-any-return]
return {"CIBW_BUILD_FRONTEND": frontend}


@pytest.fixture()
def build_frontend_env(build_frontend_env_nouv: dict[str, str]) -> dict[str, str]:
if build_frontend_env_nouv["CIBW_BUILD_FRONTEND"] == "build" and find_uv() is not None:
return {"CIBW_BUILD_FRONTEND": "build[uv]"}
frontend = build_frontend_env_nouv["CIBW_BUILD_FRONTEND"]
if frontend != "build" or platform == "pyodide" or find_uv() is None:
return build_frontend_env_nouv

return build_frontend_env_nouv
return {"CIBW_BUILD_FRONTEND": "build[uv]"}


@pytest.fixture()
Expand Down
5 changes: 3 additions & 2 deletions test/test_before_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_prefix(self):
"""


def test(tmp_path):
def test(tmp_path, build_frontend_env):
project_dir = tmp_path / "project"
before_test_project.generate(project_dir)
test_project_dir = project_dir / "dependency"
Expand All @@ -49,7 +49,7 @@ def test(tmp_path):
before_test_steps.extend(
["pyodide build {project}/dependency", "pip install --find-links dist/ spam"]
)
else:
elif build_frontend_env["CIBW_BUILD_FRONTEND"] in {"pip", "build"}:
before_test_steps.append("python -m pip install {project}/dependency")

before_test = " && ".join(before_test_steps)
Expand All @@ -66,6 +66,7 @@ def test(tmp_path):
# mac/linux.
"CIBW_TEST_COMMAND": f"false || {utils.invoke_pytest()} {{project}}/test",
"CIBW_TEST_COMMAND_WINDOWS": "pytest {project}/test",
**build_frontend_env,
},
)

Expand Down
4 changes: 3 additions & 1 deletion test/test_dependency_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ def get_versions_from_constraint_file(constraint_file):
return dict(re.findall(VERSION_REGEX, constraint_file_text))


@pytest.mark.parametrize("python_version", ["3.6", "3.8", "3.10"])
@pytest.mark.parametrize("python_version", ["3.6", "3.8", "3.12"])
def test_pinned_versions(tmp_path, python_version, build_frontend_env_nouv):
if utils.platform == "linux":
pytest.skip("linux doesn't pin individual tool versions, it pins manylinux images instead")
if python_version == "3.6" and utils.platform == "macos" and platform.machine() == "arm64":
pytest.skip("macOS arm64 does not support Python 3.6")
if python_version != "3.12" and utils.platform == "pyodide":
pytest.skip(f"pyodide does not support Python {python_version}")

project_dir = tmp_path / "project"
project_with_expected_version_checks.generate(project_dir)
Expand Down
7 changes: 3 additions & 4 deletions test/test_pep518.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
setup_py_add=textwrap.dedent(
"""
# Will fail if PEP 518 does work
import requests
assert requests.__version__ == "2.27.0", "Requests found but wrong version ({0})".format(requests.__version__)
import jmespath
assert jmespath.__version__ == "0.10.0", "'jmespath' found but wrong version ({0})".format(jmespath.__version__)
# Just making sure environment is still set
import os
Expand All @@ -24,8 +24,7 @@
requires = [
"setuptools >= 42",
"setuptools_scm[toml]>=4.1.2",
"wheel",
"requests==2.27.0"
"jmespath==0.10.0"
]
build-backend = "setuptools.build_meta"
Expand Down

0 comments on commit c1b8a12

Please sign in to comment.