Skip to content

cibuildwheel fails without diagnostic on dependency conflict #2570

@tttapa

Description

@tttapa

Description

If there are dependency conflicts between cibuildwheel's requirement files and a project's build-system.requires dependencies, the build process simply fails without any meaningful diagnostics.

For example, Conan has a urllib3 requirement that conflicts with


When trying to add Conan as a build requirement in pyproject.toml, cibuildwheel just terminates without giving any indication about the actual cause of the error:

FROM python:3.13-bookworm
RUN pip install cibuildwheel==3.1.4
RUN mkdir foo
RUN cat <<EOF > foo/pyproject.toml
[project]
name="foo"
version="1.2.3"
[build-system]
requires = ["conan==2.19.1"]
build-backend = "foo"
EOF
RUN cibuildwheel foo --only cp313-pyodide_wasm32
[...]
Building wheel...

+ pyodide build /foo --outdir=/tmp/cibw-run-mj54e87y/cp313-pyodide_wasm32/built_wheel

Traceback (most recent call last):
  File "/tmp/cibw-run-mj54e87y/cp313-pyodide_wasm32/build/venv/lib/python3.13/site-packages/pyodide_build/pypabuild.py", line 366, in build
    built = _build_in_isolated_env(
        build_env, srcdir, str(outdir), "wheel", config_settings
    )
  File "/tmp/cibw-run-mj54e87y/cp313-pyodide_wasm32/build/venv/lib/python3.13/site-packages/pyodide_build/pypabuild.py", line 168, in _build_in_isolated_env
    install_reqs(build_env, env, builder.build_system_requires)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/cibw-run-mj54e87y/cp313-pyodide_wasm32/build/venv/lib/python3.13/site-packages/pyodide_build/pypabuild.py", line 138, in install_reqs
    env.install(
    ~~~~~~~~~~~^
        remove_avoided_requirements(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
        )
        ^
    )
    ^
  File "/tmp/cibw-run-mj54e87y/cp313-pyodide_wasm32/build/venv/lib/python3.13/site-packages/build/env.py", line 136, in install
    self._env_backend.install_requirements(requirements)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/tmp/cibw-run-mj54e87y/cp313-pyodide_wasm32/build/venv/lib/python3.13/site-packages/build/env.py", line 265, in install_requirements
    run_subprocess(cmd)
    ~~~~~~~~~~~~~~^^^^^
  File "/tmp/cibw-run-mj54e87y/cp313-pyodide_wasm32/build/venv/lib/python3.13/site-packages/build/_ctx.py", line 71, in run_subprocess
    subprocess.run(cmd, capture_output=True, check=True, env=env)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/cibw-run-mj54e87y/cp313-pyodide_wasm32/build/base/pbs/python/lib/python3.13/subprocess.py", line 577, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/tmp/cibw-run-mj54e87y/cp313-pyodide_wasm32/build/venv/bin/python', '-m', 'pip', '--python', '/tmp/build-env-q1mdu4bs/bin/python', 'install', '--use-pep517', '--no-warn-script-location', '--no-compile', '-r', '/tmp/build-reqs-0nxveo_h.txt']' returned non-zero exit status 1.

ERROR Command '['/tmp/cibw-run-mj54e87y/cp313-pyodide_wasm32/build/venv/bin/python', '-m', 'pip', '--python', '/tmp/build-env-q1mdu4bs/bin/python', 'install', '--use-pep517', '--no-warn-script-location', '--no-compile', '-r', '/tmp/build-reqs-0nxveo_h.txt']' returned non-zero exit status 1.

                                                                       ✕ 3.62s
cibuildwheel: error: Command ['/tmp/cibw-run-mj54e87y/cp313-pyodide_wasm32/build/venv/bin/pyodide', 'build', '/foo', '--outdir=/tmp/cibw-run-mj54e87y/cp313-pyodide_wasm32/built_wheel'] failed with code 1. 

Preferably, this should print the pip output, along the lines of

ERROR: Cannot install -r cibw-req.txt (line 75), conan==2.19.1 and urllib3==2.5.0 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested urllib3==2.5.0
    requests 2.32.4 depends on urllib3<3 and >=1.21.1
    conan 2.19.1 depends on urllib3<2.1 and >=1.26.6

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

Build log

No response

CI config

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions