Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cibuildwheel/frontend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dataclasses
import os
import shlex
import typing
from collections.abc import Sequence
Expand Down Expand Up @@ -37,6 +38,15 @@ def options_summary(self) -> str | dict[str, str]:


def _get_verbosity_flags(level: int, frontend: BuildFrontendName) -> list[str]:
# The pseudo build-frontend provided by pyodide-build does not yet support
# tuning its verbosity level, see https://github.com/pyodide/pyodide-build/issues/222
# We can use the "PYODIDE" env var to detect if we're running in that context.
if os.environ.get("PYODIDE") == "1":
if level != 0:
log.warning(f"build_verbosity {level} is not supported for Pyodide builds. Ignoring.")

return []

if level < 0:
if frontend == "pip":
return ["-" + -level * "q"]
Expand Down
2 changes: 2 additions & 0 deletions cibuildwheel/platforms/pyodide.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ def build(options: Options, tmp_path: Path) -> None:
shell(before_build_prepared, env=env)

log.step("Building wheel...")
env["PYODIDE"] = "1"

extra_flags = get_build_frontend_extra_flags(
build_frontend, build_options.build_verbosity, build_options.config_settings
Expand All @@ -423,6 +424,7 @@ def build(options: Options, tmp_path: Path) -> None:
if constraints_path:
combine_constraints(build_env, constraints_path, identifier_tmp_dir)
build_env["VIRTUALENV_PIP"] = pip_version
build_env["PYODIDE"] = "1"
call(
"pyodide",
"build",
Expand Down
21 changes: 20 additions & 1 deletion unit_test/main_tests/main_options_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

from cibuildwheel.__main__ import main
from cibuildwheel.environment import ParsedEnvironment
from cibuildwheel.frontend import _split_config_settings, parse_config_settings
from cibuildwheel.frontend import (
_get_verbosity_flags,
_split_config_settings,
parse_config_settings,
)
from cibuildwheel.options import BuildOptions, _get_pinned_container_images
from cibuildwheel.selector import BuildSelector, EnableGroup
from cibuildwheel.util import resources
Expand Down Expand Up @@ -390,6 +394,21 @@ def test_build_verbosity(
assert build_options.build_verbosity == expected_verbosity


@pytest.mark.parametrize("verbosity", [0, 1, 2, -1, 3])
def test_get_verbosity_flags_pyodide(monkeypatch, capsys, verbosity):
monkeypatch.setenv("PYODIDE", "1")

assert _get_verbosity_flags(verbosity, "build") == []

_, err = capsys.readouterr()

if verbosity != 0:
assert "build_verbosity" in err
assert "not supported for Pyodide builds" in err
else:
assert "not supported for Pyodide builds" not in err


@pytest.mark.parametrize("platform_specific", [False, True])
def test_config_settings(platform_specific, platform, intercepted_build_args, monkeypatch):
config_settings = (
Expand Down
Loading