Skip to content

[FR] CIBW_BUILD_ISOLATION or similar #1580

@abravalheri

Description

@abravalheri

It would be nice if we could have a CIBW_BUILD_ISOLATION=false, equivalent to python -m build --no-isolation and pip wheel --no-deps --no-build-isolation.

The context for this FR is testing: some projects (like build-backends or build-backend plugins, e.g. setuptools-rust) have integration tests that use cibuildwheel; and during those tests we want to install the working versions of one of the build requirements from the source directory instead of fetching from PyPI.

The only alternative that we have nowadays is PIP_NO_BUILD_ISOLATION (no build equivalent as far as I know). However, I found that PIP_NO_BUILD_ISOLATION is tricky to use (in PyO3/setuptools-rust#352, it took me a long time to figure out how to make it work and solve the errors). I can highlight the following reasons:

  1. It is not supported by build

  2. You have to set it inside CIBW_ENVIRONMENT (forgetting to do that is a silly mistake if you understand how cibuildwheel works, but nevertheless, very easy to forget and let it happen/difficult for beginners to figure it out)

  3. PIP_NO_BUILD_ISOLATION is counter-intuitive: see PIP_NO_BUILD_ISOLATION behaves opposite to how it reads pip#5735

  4. When PIP_NO_BUILD_ISOLATION=false is set, every call to pip install (e.g. the ones in CIBW_BEFORE_BUILD to install the build dependencies) will also be subject to the "no isolation" rule.
    This make a supposedly simple operation (i.e., installing build dependencies using a pip install command) error prone. For example, the following CIBW_BEFORE_BUILD may result in errors (depending on the versions of Python/setuptools/wheel/pip already present on the build container/VM):

    CIBW_BEFORE_BUILD: pip install -U pip>=23.2.1 setuptools>=68.0.0 wheel>=0.41.1 -e .

    (Instead to make it work, after a few ours of debugging, you might have to split the command into a succession of independent pip installs).

    It would be better if CIBW_BEFORE_BUILD is not affected by PIP_NO_BUILD_ISOLATION (it gives less margins for surprise/errors).
    CIBW_BUILD_ISOLATION=false would be better because it would not affect CIBW_BEFORE_BUILD (less margin for surprise/errors).

An alternative to CIBW_BUILD_ISOLATION=true, would be allowing customising the build command CIBW_BUILD_CMD, as suggested in #442 (however that comes with a different set of considerations/issues as discussed in the other issue).

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