feat: build[uv] (#1856)
This commit is contained in:
+11
-2
@@ -6,7 +6,7 @@ from typing import Generator
|
||||
|
||||
import pytest
|
||||
|
||||
from cibuildwheel.util import detect_ci_provider
|
||||
from cibuildwheel.util import detect_ci_provider, find_uv
|
||||
|
||||
from .utils import EMULATED_ARCHS, platform
|
||||
|
||||
@@ -31,12 +31,21 @@ def pytest_addoption(parser) -> None:
|
||||
@pytest.fixture(
|
||||
params=[{"CIBW_BUILD_FRONTEND": "pip"}, {"CIBW_BUILD_FRONTEND": "build"}], ids=["pip", "build"]
|
||||
)
|
||||
def build_frontend_env(request) -> dict[str, str]:
|
||||
def build_frontend_env_nouv(request) -> dict[str, str]:
|
||||
if platform == "pyodide":
|
||||
pytest.skip("Can't use pip as build frontend for pyodide platform")
|
||||
|
||||
return request.param # type: ignore[no-any-return]
|
||||
|
||||
|
||||
@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]"}
|
||||
|
||||
return build_frontend_env_nouv
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def docker_cleanup() -> Generator[None, None, None]:
|
||||
def get_images() -> set[str]:
|
||||
|
||||
@@ -53,7 +53,7 @@ def get_versions_from_constraint_file(constraint_file):
|
||||
|
||||
|
||||
@pytest.mark.parametrize("python_version", ["3.6", "3.8", "3.10"])
|
||||
def test_pinned_versions(tmp_path, python_version, build_frontend_env):
|
||||
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":
|
||||
@@ -79,7 +79,7 @@ def test_pinned_versions(tmp_path, python_version, build_frontend_env):
|
||||
add_env={
|
||||
"CIBW_BUILD": build_pattern,
|
||||
"CIBW_ENVIRONMENT": cibw_environment_option,
|
||||
**build_frontend_env,
|
||||
**build_frontend_env_nouv,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -93,7 +93,7 @@ def test_pinned_versions(tmp_path, python_version, build_frontend_env):
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
|
||||
def test_dependency_constraints_file(tmp_path, build_frontend_env):
|
||||
def test_dependency_constraints_file(tmp_path, build_frontend_env_nouv):
|
||||
if utils.platform == "linux":
|
||||
pytest.skip("linux doesn't pin individual tool versions, it pins manylinux images instead")
|
||||
|
||||
@@ -130,7 +130,7 @@ def test_dependency_constraints_file(tmp_path, build_frontend_env):
|
||||
"CIBW_ENVIRONMENT": cibw_environment_option,
|
||||
"CIBW_DEPENDENCY_VERSIONS": str(constraints_file),
|
||||
"CIBW_SKIP": "cp36-*",
|
||||
**build_frontend_env,
|
||||
**build_frontend_env_nouv,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ def test_universal2_testing_on_x86_64(tmp_path, capfd, skip_arm64_test):
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
|
||||
def test_universal2_testing_on_arm64(tmp_path, capfd):
|
||||
def test_universal2_testing_on_arm64(build_frontend_env, tmp_path, capfd):
|
||||
# cibuildwheel should test the universal2 wheel on both x86_64 and arm64, when run on arm64
|
||||
if utils.platform != "macos":
|
||||
pytest.skip("this test is only relevant to macos")
|
||||
@@ -187,15 +187,16 @@ def test_universal2_testing_on_arm64(tmp_path, capfd):
|
||||
add_env={
|
||||
"CIBW_ARCHS": "universal2",
|
||||
# check that a native dependency is correctly installed, once per each testing arch
|
||||
"CIBW_TEST_REQUIRES": "numpy",
|
||||
"CIBW_TEST_COMMAND": '''python -c "import numpy, platform; print(f'running tests on {platform.machine()} with numpy {numpy.__version__}')"''',
|
||||
"CIBW_TEST_REQUIRES": "--only-binary :all: pillow>=10.3", # pillow>=10.3 provides wheels for macOS 10.10, not 10.9
|
||||
"CIBW_TEST_COMMAND": '''python -c "import PIL, platform; print(f'running tests on {platform.machine()} with pillow {PIL.__version__}')"''',
|
||||
**build_frontend_env,
|
||||
},
|
||||
single_python=True,
|
||||
)
|
||||
|
||||
captured = capfd.readouterr()
|
||||
assert "running tests on arm64" in captured.out
|
||||
assert "running tests on x86_64" in captured.out
|
||||
assert "running tests on arm64 with pillow" in captured.out
|
||||
assert "running tests on x86_64 with pillow" in captured.out
|
||||
|
||||
python_tag = "cp{}{}".format(*utils.SINGLE_PYTHON_VERSION)
|
||||
expected_wheels = [w for w in ALL_MACOS_WHEELS if python_tag in w and "universal2" in w]
|
||||
|
||||
Reference in New Issue
Block a user