-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Show a nice error if editable mode is attempted with a pyproject.toml source tree #6331
Show a nice error if editable mode is attempted with a pyproject.toml source tree #6331
Conversation
e3b7ef8
to
cbe23a9
Compare
One minor nit (I don't have time to do a full review right now). I'd prefer it if the message referred to "PEP 517 based" rather than "pyproject.toml-based". After all, it's PEP 517 that doesn't have a hook for doing editable installs. But it is only a minor point. |
Okay, thanks. Let me explain my thinking and how I arrived at that, and you can let me know what you think. That word choice came about after reading and reflecting on issue #6256 ("pip's error message for wheel-build failure on PEP517 packages isn't very friendly"), and after reading the PEP more carefully. Basically, I do really want pip to be more user-friendly, and my thinking was that it would be more user-friendly for us (and without sacrificing accuracy) to lead with the thing that more people will be familiar with (the
And further on:
(After reading this again here, I see now it might be more faithful to the PEP for us to say " To your point re: PEP 517, I was careful to include a reference to PEP 517 for people already familiar with it, and for those that want to learn more. The error message also says why the source tree is being considered Lastly, another point is that it won't always be the case that |
Thanks. I take your point and agree with you (I'd forgotten that PEP 517 had given a name to this type of source tree). |
a52aea2
to
f34d5bb
Compare
Okay, thanks a lot, @pfmoore. I just updated the PR in a couple ways. First, I had to scale the PR back slightly to get the tests passing. I noticed something that I'd like your thoughts on, @pfmoore, which I'll spell out for you at the end of this comment. The second thing I changed was tweaking the error text to use the word "style" rather than "based" (in line with my comments above) to match PEP 517's language more closely. The three possible messages are now:
Okay, here is the thing I'd like your thoughts on. There is a part of pip's pip/src/pip/_internal/pyproject.py Lines 95 to 99 in 5f3c56e
The possible problem I see is that it does this even if the user is doing an editable install. It's a problem IMO because PEP 517 doesn't support editable installs. When I tried disabling that opt-in logic when editable mode is being used, the following test failed: pip/tests/functional/test_install_reqs.py Lines 300 to 306 in 5f3c56e
The "pep518-3.0" project in that test has a "build-system" "requires" section: pip/tests/data/src/pep518-3.0/pyproject.toml Lines 1 to 2 in 5f3c56e
and when the project isn't handled as a PEP 517 project, the code doesn't look at the contents of the So I left that opt-in logic alone for now and only addressed the cases where the PEP 517 processing is required by the PEP. My question for you is -- if PEP 517 processing isn't required but the project has a |
f34d5bb
to
cc2d299
Compare
This was a matter of debate at the start of the implementation. I don't currently have time to hunt out the references, but there were two key places where discussion happened - the issue for implementing PEP 517 and the PR itself. Basically the question was, which of the new (PEP 517) and old (legacy) code paths should we use in cases of doubt. The consensus was that we should use PEP 517 wherever possible, pushing as many projects onto the new code path as we could. The discussion about this was around #5407 (comment). I have a feeling that originally, the code that now says Nevertheless, I'm still strongly of the opinion that we should use PEP 517 wherever we can reasonably do so. Ultimately, we want to remove the legacy code path altogether. To do that, we need to use the PEP 517 code path even for projects that haven't opted into it, or we'll be unable to support the long tail of projects that won't ever add a I'm OK with opting out of PEP 517 if Thinking about this, I've raised #6334 as a placeholder registering the intention to ultimately remove the legacy codepath. So, to summarise, my answer to your question "should pip be opting the project in to PEP 517 processing?" is yes, we should - and that was always the intended behaviour. (Of course, there's always the option to change our minds if the evidence says we need to - but I don't believe that's the case right now). |
@pfmoore Oops, sorry. I accidentally left out a phrase when I restated my question and meant for my question to focus only on editable mode, so I'll restate:
It seems to me like we don't want to opt in to PEP 517 in this case for a couple reasons. First, we haven't thought through what it means to use PEP 517 in conjunction with editable mode (and the PEP expressly doesn't support it). And second, if we do add support for it later, I wouldn't want to risk prematurely adding in a new behavior that we need to preserve backwards compatibility with later on. (Basically, even though you've already said you're okay with not opting in in this case, I'm making a case for you to remove the reservations you might have with this option.) |
@cjerdonek Ah, that makes more sense. I won't directly answer your question (as I'm getting lost in double negatives, and I don't want to add to the confusion). I'll just say what I think should happen (as I think that will be clearer): I think that if the standard logic has resulted in pip deciding to process a project using PEP 517, and the user has specified There is a strong argument that this is not a particularly user-friendly approach, and I agree that it isn't. However, I am more concerned that if we do silently switch to the legacy code path for Note - this is just my opinion, and I've been clear that I'm keen on forcing the pace on switching to PEP 517. Also, I'm also not a heavy user of editable installs myself. So I won't be surprised if the consensus is against me on this. And I'm not going to fight in that case. But I wanted to get my reasoning on record.
I 100% agree with this - but my response is to implement no behaviour (i.e., fail). I think you're arguing that "use the legacy codepath" doesn't add new behaviour, but I'd view "use the legacy behaviour" as choosing a behaviour (for PEP 517 projects) that we'd have to change later. |
I was actually going to suggest this (failing outright) as another option for the same reasons you mentioned, but I hesitated because I thought it might be too late given that 19.0 was already released. I do very much agree with you that what you're suggesting is the right approach for a properly forward-compatible approach. I'm totally okay with this approach if you're okay with it (and actually prefer it), provided that we're willing to accept any pushback after 19.1 is released. (It seems likely that some users will start to experience errors in 19.1 in some situations that they weren't experiencing before.)
One clarification here. There are actually two cases I think we should consider separately:
For (2), I agree with you that we should let the user override an editable failure with |
If the PEP mandates PEP 517 behaviour, then I think |
Great! I think we're in agreement, too. I'll try doing the second half of what we discussed (the so-called optional case) in a separate PR after this one is done. |
@pfmoore Would you be able to review this PR at some point? I'd like to be able to start working on "part 2" of this (well enough in advance of the next release, etc), but I was hoping this could be merged before then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have time to do more than desk-check the PR via the github UI, I'm afraid, but it looks generally OK. One concern I have is that when we add the new PEP 517 backend-path
support (see pypa/pyproject-hooks#46) it's going to be harder to thread the new backend-path
key through the sequence of calls you've introduced here (resolve_pyproject_toml
needs to take an extra parameter, which it does nothing with except pass it on, which is a code smell to me). And if we ever add further keys needed for creating the hook caller, this could get worse.
I'm OK with the comment "let's leave that for whoever deals with integrating that PR" (except for the fact that the obvious candidate may well be me, and I really don't want to have to deal with it ;-)) but I think it's worth being explicit that this change, as it stands, makes it harder to pass data from pyproject.toml
to the backend. See https://github.com/pypa/pip/blob/master/src/pip/_internal/req/req_install.py#L488-L592 for how it's done now.
Thanks, @pfmoore. To provide some background on the rationale, the reason I broke out The advantage of breaking out this particular function is that it makes it a lot easier to test the various code paths. We can test the logic independent of the file system; testing new combinations is just a matter of adding new tuples to the parametrized list of test cases. (In particular, we don't need to fiddle with writing a Regarding |
Also, something I want to emphasize is that breaking out |
As I said, I mostly wanted to be sure that the point had been considered. Based on your comments, I'm happy to approve. |
Okay, thanks a lot, @pfmoore. I'll merge and work on "part 2" shortly. |
FYI, I finished working on the follow-on "part 2" of this PR. It's posted here: #6370 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Fixes #6314.
This PR adds an informative error message if an editable install is attempted with a
pyproject.toml
-style (PEP 517) source tree.It also adjusts the logic so that, if PEP 517 is optional and editable mode is being used, then it prevents opting in to PEP 517 processing.This PR has two commits:
To make reviewing easier, here are the three possible error messages that this PR can result in: