-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Short-circuit get_requires hooks when there are no extra build dependencies #4973
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
base: main
Are you sure you want to change the base?
Conversation
…encies The PEP 517 get_requires_for_build_(wheel|sdist) hooks function by running the egg_info command with a patched Distribution that raises a special exception when build dependencies (from setup_requires) are about to be installed. This works great at minimizing the overhead of the requires hooks... except when there are no dynamic build dependencies. In such a situation, the injected install_build_eggs() shim that raises SetupRequirementsError is never invoked, thus the entire egg_info command will execute. This often results in substantial overhead for modern projects that use [build-system].requires and not setup_requires.
I have no idea why this is causing the prepare metadata hooks to blow up. If anyone else has any ideas, I'm all ears. I'm utterly stumped. |
Oh, it looks like the |
I do believe that's the case. Soon, however, the biggest dependencies on egg_info (easy_install) should be removed, which gets us much closer to being able to consolidate the metadata handling behavior in dist_info instead of egg_info, so maybe there's hope. |
It is a bit more nuanced, I believe,
I think that this part of the source code is very fragile... Ultimately this happens because it is not very straight forward to align PEP 517-style build hooks with existing In https://github.com/pypa/setuptools/compare/debt/refactoring-build_meta-patches?expand=1, I am studying if we can reduce the patching... Let's see if it find the same errors happening... |
That branch looks quite promising! Let me know if you turn it into a PR and I'll be happy to verify whether it improves |
I may do this next week when I have a bit more time. But what I am worried is that the interfacing of the backend and I also don't know if the approach in https://github.com/pypa/setuptools/compare/debt/refactoring-build_meta-patches?expand=1 is something that would be suitable for the long term vision in setuptools... |
Summary of changes
The PEP 517
get_requires_for_build_(wheel|sdist)
hooks function by running theegg_info
command with a patched Distribution that raises a special exception when build dependencies (fromsetup_requires
) are about to be installed.This works great at minimizing the overhead of the requires hooks... except when there are no dynamic build dependencies. In such a situation, the injected
install_build_eggs()
shim that raisesSetupRequirementsError
is never invoked, thus the entireegg_info
command will execute. This often results in substantial overhead for modern projects that use[build-system].requires
and notsetup_requires
.With this simple script at the root of the pip project, this change brings the execution time from ~300ms to ~100ms.
This helps a fair bit with reducing the overhead with PEP 517 processing.