-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_requires_for_build_wheel
hook is invoked without passing config_settings
#12273
Comments
Ah, while I did search the Pip issue tracker and didn't find anything, I only looked at
|
From pypa/build#264 (comment) I thought this bug wan't present in pip. The bug is setuptools injects the contents of Fixing it has caused some issues (also see pypa/build#264) for build users due to setuptool's bug, pypa/setuptools#3896, though I'm hoping someone will actually just go and fix the bug now that more people are able to see it. There are a couple of user-facing workarounds, so AFAIK those affected have been able to use the workarounds. If this bug is present in pip (which does make sense since setuptools doesn't handle custom wheel related options when this is handled correctly according to PEP 517), then maybe a short wait to see if it gets fixed in setuptools now that build exposes it by behaving correctly would be best. It would be nice if the reply to the bug reports could just be "update setuptools" instead of I think an author could possibly add these custom options to the other commands (just It is very import to fix soonish, though, as all other backends expect to be able to see all the options for all the hooks. Scikit-build-core, for example, has several that could affect the requirement list. It is clearly a part of the PEP that config_settings is passed to these hooks, and other backends that are designed around the PEP expect it. PS: There are also author-level workarounds. You can add do-nothing handling to all the commands that see these config-settings. You can also follow https://setuptools.pypa.io/en/latest/build_meta.html#dynamic-build-dependencies-and-other-build-meta-tweaks (also the recommended way to customize according to the PEP) and add the following wrapper: # _custom_build/backend.py
from setuptools import build_meta as _orig
from setuptools.build_meta import *
def get_requires_for_build_wheel(config_settings=None):
return _orig.get_requires_for_build_wheel()
def get_requires_for_build_sdist(config_settings=None):
return _orig.get_requires_for_build_sdist()
def get_requires_for_build_editable(config_settings=None):
return _orig. get_requires_for_build_editable() [build-system]
requires = ["setuptools"]
build-backend = "backend"
backend-path = ["_custom_build"] This literally does what pip is currently doing and build used to do. |
@rgommers normally config settings should be injected in these methods via the |
Description
The exact invocation is here:
pip/src/pip/_internal/distributions/sdist.py
Line 101 in 83ca10a
A few lines below that there's an invocation of
get_requires_for_build_editable
with the same problem.PEP 517 clearly states that
config_settings
must be passes to all hooks, so not doing so looks like a bug to me.Context: I noticed because I had an optional system dependency in the
numpy
build and the config-settings flag to disable usage of that flag wasn't doing anything. On inspection of my CI build log, the flag wasn't being passed in, which led me to search thepip
code base for all calls to theget_requires_for_build_wheel
hook. The missing argument in the call insdist.py
indeed explains the failure I was seeing.More context:
meson-python
has a dependency on Linux onpatchelf
in some cases, and to determine whether installingpatchelf
from PyPI was necessary, a build configure step could be triggered (see these lines of code). That situation should be rare, which probably explains why no one noticed the missingconfig_settings
argument. That code is now changed, so the problem no longer affectsmeson-python
users.Expected behavior
All calls to
get_requires_for_build_wheel
andget_requires_for_build_editable
always pass inconfig_settings
.pip version
23.2.1
Python version
3.11
OS
Linux
How to Reproduce
The actual reproducer was inside a dev build of numpy, which is nontrivial to reproduce. However, I don't think it's necessary to reproduce that particular failure - from the line of code I identified above and PEP 517, it seems clear that this is a bug and that passing in
config_settings
will fix the bug.If a reproducer is needed for testing, it'd be better to write a standalone minimal reproducer.
Output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: