Merge remote-tracking branch 'origin/main' into henryiii/refactor/namespace
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
from packaging.specifiers import SpecifierSet
|
||||
|
||||
from cibuildwheel.util import BuildSelector
|
||||
@@ -10,6 +9,7 @@ def test_build():
|
||||
assert build_selector("cp36-manylinux_x86_64")
|
||||
assert build_selector("cp37-manylinux_x86_64")
|
||||
assert build_selector("cp310-manylinux_x86_64")
|
||||
assert not build_selector("cp311-manylinux_x86_64")
|
||||
assert build_selector("pp36-manylinux_x86_64")
|
||||
assert build_selector("pp37-manylinux_x86_64")
|
||||
assert build_selector("cp36-manylinux_i686")
|
||||
@@ -28,11 +28,11 @@ def test_build():
|
||||
assert build_selector("cp36-win_amd64")
|
||||
assert build_selector("cp37-win_amd64")
|
||||
assert build_selector("cp310-win_amd64")
|
||||
assert not build_selector("cp311-win_amd64")
|
||||
assert not build_selector("pp36-win_amd64")
|
||||
assert not build_selector("pp37-win_amd64")
|
||||
|
||||
|
||||
@pytest.mark.skip("this test only makes sense when we have a prerelease python to test with")
|
||||
def test_build_filter_pre():
|
||||
build_selector = BuildSelector(
|
||||
build_config="cp3*-* *-manylinux*",
|
||||
@@ -41,9 +41,9 @@ def test_build_filter_pre():
|
||||
)
|
||||
|
||||
assert build_selector("cp37-manylinux_x86_64")
|
||||
assert build_selector("cp310-manylinux_x86_64")
|
||||
assert build_selector("cp311-manylinux_x86_64")
|
||||
assert build_selector("cp37-win_amd64")
|
||||
assert build_selector("cp310-win_amd64")
|
||||
assert build_selector("cp311-win_amd64")
|
||||
|
||||
|
||||
def test_skip():
|
||||
@@ -136,3 +136,14 @@ def test_build_limited_python_patch():
|
||||
|
||||
assert build_selector("cp36-manylinux_x86_64")
|
||||
assert build_selector("cp37-manylinux_x86_64")
|
||||
|
||||
|
||||
def test_testing_selector():
|
||||
# local import to avoid pytest trying to collect this as a test class!
|
||||
from cibuildwheel.util import TestSelector
|
||||
|
||||
test_selector = TestSelector(skip_config="cp36-*")
|
||||
|
||||
assert not test_selector("cp36-win_amd64")
|
||||
assert test_selector("cp37-manylinux_x86_64")
|
||||
assert test_selector("cp311-manylinux_x86_64")
|
||||
|
||||
@@ -32,7 +32,7 @@ def fake_package_dir(monkeypatch):
|
||||
real_path_exists = Path.exists
|
||||
|
||||
def mock_path_exists(path):
|
||||
if path == MOCK_PACKAGE_DIR / "setup.py":
|
||||
if str(path).endswith(str(MOCK_PACKAGE_DIR / "setup.py")):
|
||||
return True
|
||||
else:
|
||||
return real_path_exists(path)
|
||||
|
||||
@@ -3,7 +3,7 @@ import random
|
||||
import shutil
|
||||
import subprocess
|
||||
import textwrap
|
||||
from pathlib import Path, PurePath
|
||||
from pathlib import Path, PurePath, PurePosixPath
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -178,7 +178,7 @@ def test_dir_operations(tmp_path: Path):
|
||||
test_file = test_dir / "test.dat"
|
||||
shutil.copyfile(original_test_file, test_file)
|
||||
|
||||
dst_dir = PurePath("/tmp/test_dir")
|
||||
dst_dir = PurePosixPath("/tmp/test_dir")
|
||||
dst_file = dst_dir / "test.dat"
|
||||
container.copy_into(test_dir, dst_dir)
|
||||
|
||||
|
||||
@@ -24,13 +24,13 @@ def test_output_dir(platform, intercepted_build_args, monkeypatch):
|
||||
|
||||
main()
|
||||
|
||||
assert intercepted_build_args.args[0].globals.output_dir == OUTPUT_DIR
|
||||
assert intercepted_build_args.args[0].globals.output_dir == OUTPUT_DIR.resolve()
|
||||
|
||||
|
||||
def test_output_dir_default(platform, intercepted_build_args, monkeypatch):
|
||||
main()
|
||||
|
||||
assert intercepted_build_args.args[0].globals.output_dir == Path("wheelhouse")
|
||||
assert intercepted_build_args.args[0].globals.output_dir == Path("wheelhouse").resolve()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("also_set_environment", [False, True])
|
||||
@@ -43,7 +43,7 @@ def test_output_dir_argument(also_set_environment, platform, intercepted_build_a
|
||||
|
||||
main()
|
||||
|
||||
assert intercepted_build_args.args[0].globals.output_dir == OUTPUT_DIR
|
||||
assert intercepted_build_args.args[0].globals.output_dir == OUTPUT_DIR.resolve()
|
||||
|
||||
|
||||
def test_build_selector(platform, intercepted_build_args, monkeypatch, allow_empty):
|
||||
@@ -80,6 +80,7 @@ def test_empty_selector(platform, intercepted_build_args, monkeypatch):
|
||||
("x86_64", "manylinux2010", "quay.io/pypa/manylinux2010_x86_64:*"),
|
||||
("x86_64", "manylinux2014", "quay.io/pypa/manylinux2014_x86_64:*"),
|
||||
("x86_64", "manylinux_2_24", "quay.io/pypa/manylinux_2_24_x86_64:*"),
|
||||
("x86_64", "manylinux_2_28", "quay.io/pypa/manylinux_2_28_x86_64:*"),
|
||||
("x86_64", "custom_image", "custom_image"),
|
||||
("i686", None, "quay.io/pypa/manylinux2014_i686:*"),
|
||||
("i686", "manylinux1", "quay.io/pypa/manylinux1_i686:*"),
|
||||
@@ -92,6 +93,7 @@ def test_empty_selector(platform, intercepted_build_args, monkeypatch):
|
||||
("pypy_x86_64", "manylinux2010", "quay.io/pypa/manylinux2010_x86_64:*"),
|
||||
("pypy_x86_64", "manylinux2014", "quay.io/pypa/manylinux2014_x86_64:*"),
|
||||
("pypy_x86_64", "manylinux_2_24", "quay.io/pypa/manylinux_2_24_x86_64:*"),
|
||||
("pypy_x86_64", "manylinux_2_28", "quay.io/pypa/manylinux_2_28_x86_64:*"),
|
||||
("pypy_x86_64", "custom_image", "custom_image"),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -60,14 +60,14 @@ def test_platform_argument(platform, intercepted_build_args, monkeypatch):
|
||||
|
||||
options = intercepted_build_args.args[0]
|
||||
|
||||
assert options.globals.package_dir == MOCK_PACKAGE_DIR
|
||||
assert options.globals.package_dir == MOCK_PACKAGE_DIR.resolve()
|
||||
|
||||
|
||||
def test_platform_environment(platform, intercepted_build_args, monkeypatch):
|
||||
main()
|
||||
options = intercepted_build_args.args[0]
|
||||
|
||||
assert options.globals.package_dir == MOCK_PACKAGE_DIR
|
||||
assert options.globals.package_dir == MOCK_PACKAGE_DIR.resolve()
|
||||
|
||||
|
||||
def test_archs_default(platform, intercepted_build_args, monkeypatch):
|
||||
|
||||
@@ -2,7 +2,7 @@ import platform as platform_module
|
||||
import subprocess
|
||||
import sys
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from pathlib import PurePosixPath
|
||||
from typing import cast
|
||||
from unittest import mock
|
||||
|
||||
@@ -53,7 +53,7 @@ def test_build_default_launches(mock_build_docker, fake_package_dir, monkeypatch
|
||||
# In Python 3.8+, this can be simplified to [0].kwargs
|
||||
kwargs = build_on_docker.call_args_list[0][1]
|
||||
assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["docker"]["docker_image"]
|
||||
assert kwargs["docker"]["cwd"] == Path("/project")
|
||||
assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
|
||||
assert not kwargs["docker"]["simulate_32_bit"]
|
||||
|
||||
identifiers = {x.identifier for x in kwargs["platform_configs"]}
|
||||
@@ -61,7 +61,7 @@ def test_build_default_launches(mock_build_docker, fake_package_dir, monkeypatch
|
||||
|
||||
kwargs = build_on_docker.call_args_list[1][1]
|
||||
assert "quay.io/pypa/manylinux2014_i686" in kwargs["docker"]["docker_image"]
|
||||
assert kwargs["docker"]["cwd"] == Path("/project")
|
||||
assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
|
||||
assert kwargs["docker"]["simulate_32_bit"]
|
||||
|
||||
identifiers = {x.identifier for x in kwargs["platform_configs"]}
|
||||
@@ -69,7 +69,7 @@ def test_build_default_launches(mock_build_docker, fake_package_dir, monkeypatch
|
||||
|
||||
kwargs = build_on_docker.call_args_list[2][1]
|
||||
assert "quay.io/pypa/musllinux_1_1_x86_64" in kwargs["docker"]["docker_image"]
|
||||
assert kwargs["docker"]["cwd"] == Path("/project")
|
||||
assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
|
||||
assert not kwargs["docker"]["simulate_32_bit"]
|
||||
|
||||
identifiers = {x.identifier for x in kwargs["platform_configs"]}
|
||||
@@ -79,7 +79,7 @@ def test_build_default_launches(mock_build_docker, fake_package_dir, monkeypatch
|
||||
|
||||
kwargs = build_on_docker.call_args_list[3][1]
|
||||
assert "quay.io/pypa/musllinux_1_1_i686" in kwargs["docker"]["docker_image"]
|
||||
assert kwargs["docker"]["cwd"] == Path("/project")
|
||||
assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
|
||||
assert kwargs["docker"]["simulate_32_bit"]
|
||||
|
||||
identifiers = {x.identifier for x in kwargs["platform_configs"]}
|
||||
@@ -119,7 +119,7 @@ before-all = "true"
|
||||
|
||||
kwargs = build_on_docker.call_args_list[0][1]
|
||||
assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["docker"]["docker_image"]
|
||||
assert kwargs["docker"]["cwd"] == Path("/project")
|
||||
assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
|
||||
assert not kwargs["docker"]["simulate_32_bit"]
|
||||
|
||||
identifiers = {x.identifier for x in kwargs["platform_configs"]}
|
||||
@@ -128,7 +128,7 @@ before-all = "true"
|
||||
|
||||
kwargs = build_on_docker.call_args_list[1][1]
|
||||
assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["docker"]["docker_image"]
|
||||
assert kwargs["docker"]["cwd"] == Path("/project")
|
||||
assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
|
||||
assert not kwargs["docker"]["simulate_32_bit"]
|
||||
|
||||
identifiers = {x.identifier for x in kwargs["platform_configs"]}
|
||||
@@ -139,7 +139,7 @@ before-all = "true"
|
||||
|
||||
kwargs = build_on_docker.call_args_list[2][1]
|
||||
assert "quay.io/pypa/manylinux_2_24_x86_64" in kwargs["docker"]["docker_image"]
|
||||
assert kwargs["docker"]["cwd"] == Path("/project")
|
||||
assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
|
||||
assert not kwargs["docker"]["simulate_32_bit"]
|
||||
identifiers = {x.identifier for x in kwargs["platform_configs"]}
|
||||
assert identifiers == {
|
||||
@@ -151,7 +151,7 @@ before-all = "true"
|
||||
|
||||
kwargs = build_on_docker.call_args_list[3][1]
|
||||
assert "quay.io/pypa/manylinux2014_i686" in kwargs["docker"]["docker_image"]
|
||||
assert kwargs["docker"]["cwd"] == Path("/project")
|
||||
assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
|
||||
assert kwargs["docker"]["simulate_32_bit"]
|
||||
|
||||
identifiers = {x.identifier for x in kwargs["platform_configs"]}
|
||||
@@ -159,7 +159,7 @@ before-all = "true"
|
||||
|
||||
kwargs = build_on_docker.call_args_list[4][1]
|
||||
assert "quay.io/pypa/musllinux_1_1_x86_64" in kwargs["docker"]["docker_image"]
|
||||
assert kwargs["docker"]["cwd"] == Path("/project")
|
||||
assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
|
||||
assert not kwargs["docker"]["simulate_32_bit"]
|
||||
|
||||
identifiers = {x.identifier for x in kwargs["platform_configs"]}
|
||||
@@ -169,7 +169,7 @@ before-all = "true"
|
||||
|
||||
kwargs = build_on_docker.call_args_list[5][1]
|
||||
assert "quay.io/pypa/musllinux_1_1_i686" in kwargs["docker"]["docker_image"]
|
||||
assert kwargs["docker"]["cwd"] == Path("/project")
|
||||
assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
|
||||
assert kwargs["docker"]["simulate_32_bit"]
|
||||
|
||||
identifiers = {x.identifier for x in kwargs["platform_configs"]}
|
||||
|
||||
@@ -34,7 +34,7 @@ def test_options_1(tmp_path, monkeypatch):
|
||||
f.write(PYPROJECT_1)
|
||||
|
||||
args = get_default_command_line_arguments()
|
||||
args.package_dir = str(tmp_path)
|
||||
args.package_dir = tmp_path
|
||||
|
||||
monkeypatch.setattr(platform_module, "machine", lambda: "x86_64")
|
||||
|
||||
@@ -77,7 +77,7 @@ def test_passthrough(tmp_path, monkeypatch):
|
||||
f.write(PYPROJECT_1)
|
||||
|
||||
args = get_default_command_line_arguments()
|
||||
args.package_dir = str(tmp_path)
|
||||
args.package_dir = tmp_path
|
||||
|
||||
monkeypatch.setattr(platform_module, "machine", lambda: "x86_64")
|
||||
monkeypatch.setenv("EXAMPLE_ENV", "ONE")
|
||||
@@ -105,7 +105,7 @@ def test_passthrough(tmp_path, monkeypatch):
|
||||
)
|
||||
def test_passthrough_evil(tmp_path, monkeypatch, env_var_value):
|
||||
args = get_default_command_line_arguments()
|
||||
args.package_dir = str(tmp_path)
|
||||
args.package_dir = tmp_path
|
||||
|
||||
monkeypatch.setattr(platform_module, "machine", lambda: "x86_64")
|
||||
monkeypatch.setenv("CIBW_ENVIRONMENT_PASS_LINUX", "ENV_VAR")
|
||||
|
||||
+4
-2
@@ -1,3 +1,5 @@
|
||||
from pathlib import Path
|
||||
|
||||
from cibuildwheel.options import CommandLineArguments
|
||||
|
||||
|
||||
@@ -7,8 +9,8 @@ def get_default_command_line_arguments() -> CommandLineArguments:
|
||||
allow_empty=False,
|
||||
archs=None,
|
||||
config_file="",
|
||||
output_dir=None,
|
||||
package_dir=".",
|
||||
output_dir=Path("wheelhouse"),
|
||||
package_dir=Path("."),
|
||||
prerelease_pythons=False,
|
||||
print_build_identifiers=False,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user