<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On Aug 26, 2017 2:17 PM, "Nathaniel Smith" <<a href="mailto:njs@pobox.com" target="_blank">njs@pobox.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>[removed Guido from CC]<br><div class="gmail_extra"><br><div class="gmail_quote">On Aug 26, 2017 02:29, "Paul Moore" <<a href="mailto:p.f.moore@gmail.com" target="_blank">p.f.moore@gmail.com</a>> wrote:<br type="attribution"><blockquote class="m_5240759413249574822m_-2680525334965624087quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_5240759413249574822m_-2680525334965624087quoted-text">On 26 August 2017 at 03:17, Guido van Rossum <<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>> wrote:<br>
> In pretty much any other context, if you have an operation that returns an<br>
> regular value or an error value, the error value should be None. (Exceptions<br>
> include e.g. returning a non-negative int or -1 for errors, or True for<br>
> success and False for errors.)<br>
<br>
</div>So, given that build_sdist returns the path of the newly built sdist,<br>
the correct way to signal "I didn't manage to build a sdist" would be<br>
to return None.<br>
<br>
Now that it's put this way, it seems glaringly obvious to me that this<br>
is the correct thing to do.<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Eh... I would really prefer something that's (a) more explicit about what specifically went wrong, and (b) harder to return by accident. It's not at all obvious that if the list of requirements is 'None' that means 'this build supports making sdists in general but cannot make them from this source tree but might still be able to make a wheel'. And if you forget to put in a return statement, then python returns None for you, which seems like it could lead to some super confusing error modes.</div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto"><span style="font-family:sans-serif">Why does the frontend need to know why an sdist was not created?</span><div dir="auto" style="font-family:sans-serif"><br></div><div dir="auto" style="font-family:sans-serif">Frontend is asking the backend, given the current state of the world, to either produce an sdist, or not. Sans ahead-of-time knowledge (see below), I would expect build_sdist to make some sanity checks about the world, then make a binary choice about whether sdist creation is a valid goal. If not possible, return None or NotImplemented or False or dict-of-reasons or whatever. Only if creation was *attempted*, and in the exceptional event it then failed, would I expect an Exception. We don't have structured exceptions sadly so they can't really carry much useful information from a protocol perspective above and beyond a simple None or the like anyway.</div><div dir="auto" style="font-family:sans-serif"><br></div><div dir="auto" style="font-family:sans-serif">I'd personally like to see some parity between build_sdist and build_wheel in this regard. Maybe the disconnect here is we have a way to specify hard reqs for building a wheel, statically or dynamically, and build_wheel is expected to never fail, but no way to specify hard reqs needed for build_sdist, necessitating this optional signaling path?</div><div dir="auto" style="font-family:sans-serif"><br></div><div dir="auto" style="font-family:sans-serif">If we had some definitive way for the frontend to know ahead of time if build_sdist is even expected to work, it could be called with more confidence.</div><div dir="auto" style="font-family:sans-serif"><br></div><div dir="auto" style="font-family:sans-serif">This could be a new sdist-related key in [build-system], a new table like [sdist-system].requires, or making the get_requires_for_* less optional, and defaulting to None instead of [ ].</div><div dir="auto" style="font-family:sans-serif"><br></div><div dir="auto" style="font-family:sans-serif">Frontend is responsible for prepping the world, so if it can't get a list of reqs, somehow, for build_sdist, it knows it can't work. Same for build_wheel, because you have to specify the backend itself, so there is at least one requirement!</div><div dir="auto" style="font-family:sans-serif"><br></div><div dir="auto" style="font-family:sans-serif">Thus if you are a backend that can produce an sdist without additional requirements beyond build reqs, you should explicitly return empty list from get_requires_for_build_sdist.</div><div dir="auto" style="font-family:sans-serif"><br></div><div dir="auto" style="font-family:sans-serif">-- <br><br><div data-smartmail="gmail_signature" dir="auto">C Anthony</div></div></div></div>