chore(tests): run a project with tests using build[uv] frontend (#1880)
This commit is contained in:
@@ -22,6 +22,7 @@ from .util import (
|
||||
BuildSelector,
|
||||
NonPlatformWheelError,
|
||||
call,
|
||||
combine_constraints,
|
||||
download,
|
||||
ensure_node,
|
||||
extract_zip,
|
||||
@@ -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",
|
||||
|
||||
+9
-9
@@ -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()
|
||||
|
||||
@@ -34,7 +34,7 @@ class TestBeforeTest(TestCase):
|
||||
"""
|
||||
|
||||
|
||||
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"
|
||||
@@ -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)
|
||||
@@ -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,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
+3
-4
@@ -8,8 +8,8 @@ basic_project = test_projects.new_c_project(
|
||||
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
|
||||
@@ -24,8 +24,7 @@ basic_project.files["pyproject.toml"] = """
|
||||
requires = [
|
||||
"setuptools >= 42",
|
||||
"setuptools_scm[toml]>=4.1.2",
|
||||
"wheel",
|
||||
"requests==2.27.0"
|
||||
"jmespath==0.10.0"
|
||||
]
|
||||
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
Reference in New Issue
Block a user