pypa/pip

Validate build dependencies when using `--no-build-isolation`

mariocj89 opened this issue ยท 5 comments

What's the problem this feature will solve?

Prevent builds from running when all required build dependencies are not present.

Describe the solution you'd like

pip fails to build with a descriptive message when a build dependency is missing, providing a nicer user experience (IMHO).

Alternative Solutions

  1. Use python-build which does exactly that.
  2. Manually parse pyproject.toml + generate egg info, get additional build requires and validate those are in the environment.

Additional context
I see the pip docs on --no-build-isolation state "Build dependencies specified by PEP 518 must be already installed if this option is used.". I was wondering whether pip would like to mimic the behaviour that python-build has on --no-isolation(Fail nicely if build dependencies are not present) and if so I'm happy to try and push a patch.

Related: #6718

A sanity check to make sure the user actually sets up the environment correctly makes sense to me.

@mariocj89 and I are interested in helping out with this,
@uranusjr @pradyunsg please make sure to tag the issue appropriately?

@uranusjr @pradyunsg would you be able to please give a few pointers on where I should start looking in the code and what this change is going to look like?

https://github.com/pypa/pip/blob/main/src/pip/_internal/operations/build/wheel.py and https://github.com/pypa/pip/blob/main/src/pip/_internal/operations/build/metadata.py -- that's where you wanna look for PEP 517 build logic.

If you wanna have a longer chat/discussion about this code, ping me sometime during a work day. :)

The change needed here is calling build_env.check_requirements(build_deps) at some point in the codebase, since https://github.com/pypa/pip/blob/main/src/pip/_internal/build_env.py#L158 has the relevant logic already IIUC.

I'm pretty sure the things to figure out here are:

  1. Where to make that call.
  2. How to get build_deps to make that call.