Esempio n. 1
0
def test_project_global_override_default_platform(tmp_path, platform):
    pyproject_toml = tmp_path / "pyproject.toml"
    pyproject_toml.write_text("""
[tool.cibuildwheel]
repair-wheel-command = "repair-project-global"
""")
    options_reader = OptionsReader(pyproject_toml, platform=platform)
    assert options_reader.get(
        "repair-wheel-command") == "repair-project-global"
Esempio n. 2
0
def test_disallowed_a(tmp_path):
    pyproject_toml = tmp_path / "pyproject.toml"
    pyproject_toml.write_text("""
[tool.cibuildwheel.windows]
manylinux-x86_64-image = "manylinux1"
""")
    disallow = {"windows": {"manylinux-x86_64-image"}}
    OptionsReader(pyproject_toml, platform="linux", disallow=disallow)
    with pytest.raises(ConfigOptionError):
        OptionsReader(pyproject_toml, platform="windows", disallow=disallow)
Esempio n. 3
0
def test_unsupported_join(tmp_path):
    pyproject_toml = tmp_path / "pyproject.toml"
    pyproject_toml.write_text("""
[tool.cibuildwheel]
build = ["1", "2"]
""")
    options_reader = OptionsReader(pyproject_toml, platform="linux")

    assert "1, 2" == options_reader.get("build", sep=", ")
    with pytest.raises(ConfigOptionError):
        options_reader.get("build")
Esempio n. 4
0
def test_env_global_override_project_platform(tmp_path, platform, monkeypatch):
    monkeypatch.setenv("CIBW_REPAIR_WHEEL_COMMAND", "repair-env-global")
    pyproject_toml = tmp_path / "pyproject.toml"
    pyproject_toml.write_text("""
[tool.cibuildwheel.linux]
repair-wheel-command = "repair-project-linux"
[tool.cibuildwheel.windows]
repair-wheel-command = "repair-project-windows"
[tool.cibuildwheel.macos]
repair-wheel-command = "repair-project-macos"
""")
    options_reader = OptionsReader(pyproject_toml, platform=platform)
    assert options_reader.get("repair-wheel-command") == "repair-env-global"
Esempio n. 5
0
def test_global_platform_order(tmp_path, platform):
    pyproject_toml = tmp_path / "pyproject.toml"
    pyproject_toml.write_text("""
[tool.cibuildwheel.linux]
repair-wheel-command = "repair-project-linux"
[tool.cibuildwheel.windows]
repair-wheel-command = "repair-project-windows"
[tool.cibuildwheel.macos]
repair-wheel-command = "repair-project-macos"
[tool.cibuildwheel]
repair-wheel-command = "repair-project-global"
""")
    options_reader = OptionsReader(pyproject_toml, platform=platform)
    assert options_reader.get(
        "repair-wheel-command") == f"repair-project-{platform}"
Esempio n. 6
0
def test_unexpected_table(tmp_path):
    pyproject_toml = tmp_path / "pyproject.toml"
    pyproject_toml.write_text("""
[tool.cibuildwheel.linus]
repair-wheel-command = "repair-project-linux"
""")
    with pytest.raises(ConfigOptionError):
        OptionsReader(pyproject_toml, platform="linux")
Esempio n. 7
0
def test_overrides_not_a_list(tmp_path, platform):
    pyproject_toml: Path = tmp_path / "pyproject.toml"

    pyproject_toml.write_text("""\
[tool.cibuildwheel]
build = ["cp38*", "cp37*"]
[tool.cibuildwheel.overrides]
select = "cp37*"
test-command = "pyproject-override"
""")

    with pytest.raises(ConfigOptionError):
        OptionsReader(config_file_path=pyproject_toml, platform=platform)
Esempio n. 8
0
def test_underscores_in_key(tmp_path):
    # Note that platform contents are only checked when running
    # for that platform.
    pyproject_toml = tmp_path / "pyproject.toml"
    pyproject_toml.write_text("""
[tool.cibuildwheel]
repair_wheel_command = "repair-project-linux"
""")

    with pytest.raises(ConfigOptionError) as excinfo:
        OptionsReader(pyproject_toml, platform="linux")

    assert "repair-wheel-command" in str(excinfo.value)
Esempio n. 9
0
def test_unexpected_key(tmp_path):
    # Note that platform contents are only checked when running
    # for that platform.
    pyproject_toml = tmp_path / "pyproject.toml"
    pyproject_toml.write_text(
        """
[tool.cibuildwheel]
repairs-wheel-command = "repair-project-linux"
"""
    )

    with pytest.raises(ConfigOptionError):
        OptionsReader(pyproject_toml, platform="linux")
Esempio n. 10
0
def test_pyproject_2(tmp_path, platform):
    pyproject_toml: Path = tmp_path / "pyproject.toml"
    pyproject_toml.write_text(PYPROJECT_2)

    options_reader = OptionsReader(config_file_path=pyproject_toml, platform=platform)
    assert options_reader.get("test-command") == "pyproject"

    with options_reader.identifier("random"):
        assert options_reader.get("test-command") == "pyproject"

    with options_reader.identifier("cp37-something"):
        assert options_reader.get("test-command") == "pyproject-override"
Esempio n. 11
0
def test_environment_override_empty(tmp_path, monkeypatch):
    pyproject_toml = tmp_path / "pyproject.toml"
    pyproject_toml.write_text(
        """
[tool.cibuildwheel]
manylinux-i686-image = "manylinux1"
manylinux-x86_64-image = ""
"""
    )

    monkeypatch.setenv("CIBW_MANYLINUX_I686_IMAGE", "")
    monkeypatch.setenv("CIBW_MANYLINUX_AARCH64_IMAGE", "manylinux1")

    options_reader = OptionsReader(pyproject_toml, platform="linux")

    assert options_reader.get("manylinux-x86_64-image") == ""
    assert options_reader.get("manylinux-i686-image") == ""
    assert options_reader.get("manylinux-aarch64-image") == "manylinux1"

    assert options_reader.get("manylinux-x86_64-image", ignore_empty=True) == "manylinux2014"
    assert options_reader.get("manylinux-i686-image", ignore_empty=True) == "manylinux1"
    assert options_reader.get("manylinux-aarch64-image", ignore_empty=True) == "manylinux1"
Esempio n. 12
0
def test_envvar_override(tmp_path, platform, monkeypatch):
    monkeypatch.setenv("CIBW_BUILD", "cp38*")
    monkeypatch.setenv("CIBW_MANYLINUX_X86_64_IMAGE", "manylinux_2_24")
    monkeypatch.setenv("CIBW_TEST_COMMAND", "mytest")
    monkeypatch.setenv("CIBW_TEST_REQUIRES", "docs")
    monkeypatch.setenv("CIBW_TEST_REQUIRES_LINUX", "scod")

    config_file_path: Path = tmp_path / "pyproject.toml"
    config_file_path.write_text(PYPROJECT_1)

    options_reader = OptionsReader(config_file_path, platform=platform)

    assert options_reader.get("archs", sep=" ") == "auto"

    assert options_reader.get("build", sep=" ") == "cp38*"
    assert options_reader.get("manylinux-x86_64-image") == "manylinux_2_24"
    assert options_reader.get("manylinux-i686-image") == "manylinux2014"

    assert (
        options_reader.get("test-requires", sep=" ")
        == {"windows": "docs", "macos": "docs", "linux": "scod"}[platform]
    )
    assert options_reader.get("test-command") == "mytest"
Esempio n. 13
0
def test_simple_settings(tmp_path, platform, fname):
    config_file_path: Path = tmp_path / fname
    config_file_path.write_text(PYPROJECT_1)

    options_reader = OptionsReader(config_file_path, platform=platform)

    assert options_reader.get("build", env_plat=False, sep=" ") == "cp39*"

    assert options_reader.get("test-command") == "pyproject"
    assert options_reader.get("archs", sep=" ") == "auto"
    assert (options_reader.get("test-requires", sep=" ") == {
        "windows": "something",
        "macos": "else",
        "linux": "other many"
    }[platform])

    # Also testing options for support for both lists and tables
    assert (options_reader.get("environment",
                               table={
                                   "item": '{k}="{v}"',
                                   "sep": " "
                               }) == 'THING="OTHER" FOO="BAR"')
    assert (options_reader.get("environment",
                               sep="x",
                               table={
                                   "item": '{k}="{v}"',
                                   "sep": " "
                               }) == 'THING="OTHER" FOO="BAR"')
    assert options_reader.get("test-extras", sep=",") == "one,two"
    assert (options_reader.get("test-extras",
                               sep=",",
                               table={
                                   "item": '{k}="{v}"',
                                   "sep": " "
                               }) == "one,two")

    assert options_reader.get("manylinux-x86_64-image") == "manylinux1"
    assert options_reader.get("manylinux-i686-image") == "manylinux2014"

    with pytest.raises(ConfigOptionError):
        options_reader.get("environment", sep=" ")

    with pytest.raises(ConfigOptionError):
        options_reader.get("test-extras",
                           table={
                               "item": '{k}="{v}"',
                               "sep": " "
                           })
Esempio n. 14
0
def test_env_global_override_default_platform(tmp_path, platform, monkeypatch):
    monkeypatch.setenv("CIBW_REPAIR_WHEEL_COMMAND", "repair-env-global")
    options_reader = OptionsReader(platform=platform)
    assert options_reader.get("repair-wheel-command") == "repair-env-global"