feat: add --only (#1098)
* fix(style): use sub recommended replacement method See https://docs.python.org/3/library/re.html#re.escape Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * feat: add --build * refactor: switch to using --only Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * docs: cover --only Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * docs: undo change to --plat for auditwheel Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * (unrelated) speed up running the unit tests based on a profile run, this speeds up the unit tests by 3x * Remove `intercepted_build_args` reliance on `platform` fixture * Add test that checks if 'only' overrides env var options * Ensure that the --only command line option overrides env vars * Fix UnboundLocalError * Test cleanups * style: typing.cast instead of plain cast * feat: add only: to the GHA Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Joe Rickerby <joerick@mac.com>
This commit is contained in:
co-authored by
Joe Rickerby
parent
3a46bde3fb
commit
eb39da0b10
@@ -192,3 +192,73 @@ def test_archs_platform_all(platform, intercepted_build_args, monkeypatch):
|
||||
Architecture.arm64,
|
||||
Architecture.universal2,
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"only,plat",
|
||||
(
|
||||
("cp311-manylinux_x86_64", "linux"),
|
||||
("cp310-win_amd64", "windows"),
|
||||
("cp311-macosx_x86_64", "macos"),
|
||||
),
|
||||
)
|
||||
def test_only_argument(intercepted_build_args, monkeypatch, only, plat):
|
||||
monkeypatch.setenv("CIBW_BUILD", "unused")
|
||||
monkeypatch.setenv("CIBW_SKIP", "unused")
|
||||
monkeypatch.setattr(sys, "argv", sys.argv + ["--only", only])
|
||||
|
||||
main()
|
||||
|
||||
options = intercepted_build_args.args[0]
|
||||
assert options.globals.build_selector.build_config == only
|
||||
assert options.globals.build_selector.skip_config == ""
|
||||
assert options.platform == plat
|
||||
assert options.globals.architectures == Architecture.all_archs(plat)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("only", ("cp311-manylxinux_x86_64", "some_linux_thing"))
|
||||
def test_only_failed(monkeypatch, only):
|
||||
monkeypatch.setattr(sys, "argv", sys.argv + ["--only", only])
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
main()
|
||||
|
||||
|
||||
def test_only_no_platform(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
sys, "argv", sys.argv + ["--only", "cp311-manylinux_x86_64", "--platform", "macos"]
|
||||
)
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
main()
|
||||
|
||||
|
||||
def test_only_no_archs(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
sys, "argv", sys.argv + ["--only", "cp311-manylinux_x86_64", "--archs", "x86_64"]
|
||||
)
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
main()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"envvar_name,envvar_value",
|
||||
(
|
||||
("CIBW_BUILD", "cp310-*"),
|
||||
("CIBW_SKIP", "cp311-*"),
|
||||
("CIBW_ARCHS", "auto32"),
|
||||
("CIBW_PLATFORM", "macos"),
|
||||
),
|
||||
)
|
||||
def test_only_overrides_env_vars(monkeypatch, intercepted_build_args, envvar_name, envvar_value):
|
||||
monkeypatch.setattr(sys, "argv", sys.argv + ["--only", "cp311-manylinux_x86_64"])
|
||||
monkeypatch.setenv(envvar_name, envvar_value)
|
||||
|
||||
main()
|
||||
|
||||
options = intercepted_build_args.args[0]
|
||||
assert options.globals.build_selector.build_config == "cp311-manylinux_x86_64"
|
||||
assert options.globals.build_selector.skip_config == ""
|
||||
assert options.platform == "linux"
|
||||
assert options.globals.architectures == Architecture.all_archs("linux")
|
||||
|
||||
Reference in New Issue
Block a user