-
Notifications
You must be signed in to change notification settings - Fork 121
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
Support for metadata hook #130
Comments
Note the last sentence refeering to that hook in the PEP:
So basically, if you want to get the metadata you can call But are you having any particular issue? Perhaps I can help there. |
@FFY00 Not really much of an issue, it's just that my Assumption is the mother of all f-ups, I guess. It would be nice to have an API endpoint in |
Yeah, I believe most bugs and vulnerabilities in software are in some way or another due to bad assumptions 😅 We could totally add support for |
The frontend is not mandated to call it. The backend can always call it, if it wasn't called it yet during the build wheel call. This is what setuptools does. Can you clarify what is your |
I would agree that @MrMino should fall back to calling his own |
Actually, a thought occurs — PEP 517 always specifies that these hooks are called in their own independent processes, so actually calling the other hook may not be the same as having the front-end call it. Still, PEP 517 does say this:
Which pretty clearly indicates that the front-end is not required to call |
The pip unconditionally calls this function, not the backend implementation directly. |
@pganssle after building a build backend from scratch for the second time, this interpretation of the spec still doesn't make sense to me. Making it optional for the frontend means, that If I'm going to provide this hook and it hasn't been called, I'll have to call that code from It's getting called one way or another. Functionally there will be no difference, apart maybe from the fact that it's a separate process and the frontend has a way of specifying the area of the filesystem where the "preparing" should happen. Which, if we accept the optionality, it shouldn't really care about in the first place. Optionality for the frontend means that there's no practical difference for when it is there as opposed to when it's not. If this point is interpreted the way you propose, it ceases to have any normative content. Why is it even specified in the spec then? |
That is true for the use-case where you want to call |
@FFY00 That's one thing I haven't thought through. But on the first glance it still seems useless. The frontend has to use the metadata. It either:
That point would still seem to not serve much purpose. I'm not going to argue, I'm just looking for a way of making it less hand-wavy in my mind. |
What point? Option 1 serves to be a faster way of option 2. |
The issue here is when you have backends that take a long time, which is usually the case of backends that compile native code for eg. Those backends can opt in on this hook to result in a better experience for frontends. I can see the argument that it is a bit of work for forntends to implement this hook with the fallback to |
@gaborbernat If the hook is optional for the frontend, the point in the spec about it ceases to have any normative content, rendering it useless. For the |
No? But I guess that might depend on your backend's design... I would say most backends generate the metadata first and only then build stuff. |
@FFY00 Yes, for the frontend - it is. For if you have to unpack the wheel to get |
BTW. ensuring we're on the same page, I'm talking about it being "mandatory call for the frontend in case the hook is there". Optionality for the backend is mentioned directly in the spec and makes sense when there's no way of producing valid metadata before starting the build. |
I don't follow your thinking here 🤔 |
What I mean by "normative content" is a specification point, that establishes something that simplifies or improves implementations in some way, e.g. by reducing the amount of checks needed for two parties to be compatible. As opposed to rules that don't add anything, e.g. "parties may do X, or may do ¬X" - such statements have no substance to them. I proposed, that if you assume the hook to be an optional call for the frontend, this part of PEP-517 becomes logically equivalent to such tautology. The backend might add it, it might not - it changes nothing for neither party, as both have to stay compatible with each other's "non-hook" versions, so who cares.
I assumed that the build frontend depends on the metadata in some way, which I now realize might not be the case. It still seems like an unnecessary degree of freedom that complicates things for build backends though. |
The value of that section in a world where the hook is optional for both the front-end and the back-end (the world we live in...), is that if the hook exists, it must have the specified behavior and interface. In the case where the front-end just wants the metadata, it can check if the hook is implemented and if so use the generated metadata. In the case where the back-end needs a wheel, there is no reason to call |
The may parts are escape hatchets to speed up some operations. The benefit for users is faster turnaround, which should be enough motivation for the backends that can provide it to implement it. Without enforcing for every backend to provide it. Performance is important too, not just functionality and correctness. |
TL;DR - it now makes sense, sorry for bothering you needlessly, thanks for being patient 😉.
I assumed that every build frontend will need the metadata at some point, which I realized is not the case. If it would, not calling the hook doesn't make sense, as you would have to go out of your way slowing down the implementation by extracting the info from the resulting file instead of just adding the hook call. It now makes sense, I can happily concede on that point 😊.
It does not have any value if it doesn't serve any practical purpose, hence arguments above.
Err, I think you meant front-end there? Why would I need a wheel to build a wheel 😄 ? (important distinction between integration frontends and build frontends has not been made here yet, have we been talking past each other because of that?) |
I think this is not quite right, since if you know you need a wheel, you can skip the metadata call and build the wheel directly, then look at its metadata. The only reasons you'd call |
@pganssle But if that's the case, is there a reason not to do it in the frontend if the hook is there? That's not what breaks my argument: the fact that the build frontend might not care about metadata at all is. Having a convoluted method of getting metadata post-build does not mean the hook should be frontend-optional. If every build frontend has to care about metadata (which is the false premise I used in my argumentation), then not calling the hook is just plain wrong. Unless you want to go into the implementation around the IO, the behavior required for the frontend to satisfy the missing hook (unpacking I've misread the intention behind the hook, but I'd say the PEP could really use a section that outlines how these hooks are used and why they are optional. It's obvious when you're a maintainer of an integration frontend that has to build wheels, but I doubt that it's exclusively the target audience of the spec. |
So what’s the resolution here? I’m looking into implementing this now, but have a few questions how the interface:
|
Yes, I think so. As outlined here, this method is mainly for people wanting the metadata. If they want to build the distribution, they can call
The returned value should be what the backend returns. The user should provide a
I feel we should save this information internally, and have the hook use it if it is set.
No CLI in the normal command. I was going to comment in #198, but I like your proposal to expose the API as CLI, so we would expose it there. |
The fact that
PEP 517 indicates the name of the generated |
Am I missing something, or is
prepare_metadata_for_build_wheel()
not implemented?It seems like it's something that isn't specified in PEP-517, but I was of the impression, that metadata hook is a mandatory call for the frontend, which will call that hook before
build_wheel()
, if available. After all, it's not up to the build frontend whether metadata is needed, the responsibility for that decision lies on the code that actually builds the distribution.Am I correct in my interpretation of the spec?
The text was updated successfully, but these errors were encountered: