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,
|
BuildSelector,
|
||||||
NonPlatformWheelError,
|
NonPlatformWheelError,
|
||||||
call,
|
call,
|
||||||
|
combine_constraints,
|
||||||
download,
|
download,
|
||||||
ensure_node,
|
ensure_node,
|
||||||
extract_zip,
|
extract_zip,
|
||||||
@@ -285,11 +286,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
|||||||
|
|
||||||
build_env = env.copy()
|
build_env = env.copy()
|
||||||
if build_options.dependency_constraints:
|
if build_options.dependency_constraints:
|
||||||
our_constraints = str(constraints_path)
|
combine_constraints(build_env, constraints_path, identifier_tmp_dir)
|
||||||
user_constraints = build_env.get("PIP_CONSTRAINT")
|
|
||||||
build_env["PIP_CONSTRAINT"] = " ".join(
|
|
||||||
c for c in [our_constraints, user_constraints] if c
|
|
||||||
)
|
|
||||||
build_env["VIRTUALENV_PIP"] = pip_version
|
build_env["VIRTUALENV_PIP"] = pip_version
|
||||||
call(
|
call(
|
||||||
"pyodide",
|
"pyodide",
|
||||||
|
|||||||
+9
-9
@@ -28,22 +28,22 @@ def pytest_addoption(parser) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(
|
@pytest.fixture(params=["pip", "build"])
|
||||||
params=[{"CIBW_BUILD_FRONTEND": "pip"}, {"CIBW_BUILD_FRONTEND": "build"}], ids=["pip", "build"]
|
def build_frontend_env_nouv(request: pytest.FixtureRequest) -> dict[str, str]:
|
||||||
)
|
frontend = request.param
|
||||||
def build_frontend_env_nouv(request) -> dict[str, str]:
|
if platform == "pyodide" and frontend == "pip":
|
||||||
if platform == "pyodide":
|
|
||||||
pytest.skip("Can't use pip as build frontend for pyodide platform")
|
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()
|
@pytest.fixture()
|
||||||
def build_frontend_env(build_frontend_env_nouv: dict[str, str]) -> dict[str, str]:
|
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:
|
frontend = build_frontend_env_nouv["CIBW_BUILD_FRONTEND"]
|
||||||
return {"CIBW_BUILD_FRONTEND": "build[uv]"}
|
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()
|
@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"
|
project_dir = tmp_path / "project"
|
||||||
before_test_project.generate(project_dir)
|
before_test_project.generate(project_dir)
|
||||||
test_project_dir = project_dir / "dependency"
|
test_project_dir = project_dir / "dependency"
|
||||||
@@ -49,7 +49,7 @@ def test(tmp_path):
|
|||||||
before_test_steps.extend(
|
before_test_steps.extend(
|
||||||
["pyodide build {project}/dependency", "pip install --find-links dist/ spam"]
|
["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_steps.append("python -m pip install {project}/dependency")
|
||||||
|
|
||||||
before_test = " && ".join(before_test_steps)
|
before_test = " && ".join(before_test_steps)
|
||||||
@@ -66,6 +66,7 @@ def test(tmp_path):
|
|||||||
# mac/linux.
|
# mac/linux.
|
||||||
"CIBW_TEST_COMMAND": f"false || {utils.invoke_pytest()} {{project}}/test",
|
"CIBW_TEST_COMMAND": f"false || {utils.invoke_pytest()} {{project}}/test",
|
||||||
"CIBW_TEST_COMMAND_WINDOWS": "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))
|
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):
|
def test_pinned_versions(tmp_path, python_version, build_frontend_env_nouv):
|
||||||
if utils.platform == "linux":
|
if utils.platform == "linux":
|
||||||
pytest.skip("linux doesn't pin individual tool versions, it pins manylinux images instead")
|
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":
|
if python_version == "3.6" and utils.platform == "macos" and platform.machine() == "arm64":
|
||||||
pytest.skip("macOS arm64 does not support Python 3.6")
|
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_dir = tmp_path / "project"
|
||||||
project_with_expected_version_checks.generate(project_dir)
|
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(
|
setup_py_add=textwrap.dedent(
|
||||||
"""
|
"""
|
||||||
# Will fail if PEP 518 does work
|
# Will fail if PEP 518 does work
|
||||||
import requests
|
import jmespath
|
||||||
assert requests.__version__ == "2.27.0", "Requests found but wrong version ({0})".format(requests.__version__)
|
assert jmespath.__version__ == "0.10.0", "'jmespath' found but wrong version ({0})".format(jmespath.__version__)
|
||||||
|
|
||||||
# Just making sure environment is still set
|
# Just making sure environment is still set
|
||||||
import os
|
import os
|
||||||
@@ -24,8 +24,7 @@ basic_project.files["pyproject.toml"] = """
|
|||||||
requires = [
|
requires = [
|
||||||
"setuptools >= 42",
|
"setuptools >= 42",
|
||||||
"setuptools_scm[toml]>=4.1.2",
|
"setuptools_scm[toml]>=4.1.2",
|
||||||
"wheel",
|
"jmespath==0.10.0"
|
||||||
"requests==2.27.0"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
|||||||
Reference in New Issue
Block a user