-
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
Should a local file always be re-installed on 'pip install' (with or without '--upgrade')? #8711
Comments
This relates to #5780 and the upgrade strategies for direct URLs. |
Agreed. More specifically, the old resolver uses different logic for PEP 508 and legacy requirements on whether it should re-install a URL requirement. The new one tries to be consistent, but that consistent logic needs refining. I think the conclusion in #5780 is to
I’m not sure what parts of the URL PEP 610 records; if it contains the query string part, tools like tox should be able to force package re-installation with general cache-busting techniques. |
And let's not forget editables, which are always re-installed :) |
Can you detail how this would look?
Note this use falls under this section which is not a solution for this issue and users will be surprised by this change in behaviour. |
The most widely-used generic cache busting approach simply appends a hash to the query string, so you’d do something like
where the |
That sounds something a tool could do (though all tooling would need to change how to install packages), but not that useful for humans 🤔 |
My understanding is that pip doesn’t (never did?) position itself as a development tool, and is expected to be used in conjuction of other tooling to work well in such settings. pip’s current behaviour (always re-installs bare URLs, but never re-installs PEP 508 URL specs) is entirely arbitrary without justification. My understanding is that the situation is caused by historic oversight, and should be classified as a bug. But it is also not obvious which behaviour is “corerct”, and there are two camps of people wanting the opposite approach. The resolution in #5780 is most reasonable middle ground (which actually makes sense!) that I know. I am fully aware that it would break someone’s workflow no matter what we do, but I still believe it’s something that should be done. |
How would maintaining status quo break peoples workflow? 😊 |
This a big change for local development. During local development, we build the wheel, then pip install --upgrade it. The version number does not change during the local development cycle. Adding --use-feature=2020-resolver prevents the "upgrade" from happening. --force-reinstall is overkill because it reinstalls all of the dependencies (and actually doesn't work when some of the dependencies are not (yet) on pypi). --no-deps only works if all of the dependencies have already been installed, ie., don't change during development. If --force-reinstall could be limited to the packages on the command line, which is what I would expect, then that would be a reasonable solution. |
This is currently possible with |
I think local directories/files passed directly via the CLI (like I do agree that all other |
I thought about this a bit more; maybe we should just always reinstall a URL, no matter if it’s PEP 508, no matter whether it’s editable, and no matter whether it points to a directory, sdist, wheel, or VCS. The not-reinstall-URL thing is an optimisation anyway, and by always reinstalling a URL-specified requirements, we also give the user looking for optimisations use indexes instead, with which pip can offer even more optimisations than reinstallation. |
That can't work, it will raise a load of (performance) issues for people who actually need them. Asking people to use to indexes won't make it either. One reason is that using indexes requires generating unique version numbers which is a burden when, e.g. you want to install an unmerged upstream PR for some dependency. Always reinstalling local directories sounds better to me. Perhaps always reinstalling local files too, or not. A more targeted What is actually the use case for installing from a wheel or sdist in a development workflow? |
An issue with "pip install localdir" is how to pass arguments to setup.py (e.g., --no-user-cfg, --debug). It is much simpler to keep the building and the installing of the wheels separate. |
@uranusjr said:
But while speaking with @pradyunsg yesterday I learned that, according to Pradyun, this issue is resolved. Pradyun, could you clarify? |
Oops, I messed up the issue number, sorry. The complicated issue that may delay the rollout I had in mind is #8785, not this one. |
I'm getting confused over the different suggestions, so apologies, but are you saying that we shouldn't reinstall on any sort of archive file, and only reinstall unpacked source trees (local directories)? That's not going to address the tox case that was the original subject of this issue, but I'm not against it... |
@pfmoore ...or reinstall all sorts, I honestly don't know. All I'm saying so far is that I think the behavior should be same for file:// and https://, probably. To say anything more conclusive I'm afraid I'd need to do the full research on the table I posted... and just like you I don't have the bandwidth to do it correctly these days. Maybe someone has a clearer picture of the whole situation than me, I don't know. In an ideal world we'd need to do that research first, to know the as-is and wanted to-be situation and discuss a proper transition. But I guess there is the pressure to release the new resolver so 🤷 ... Now, if anyone wants more of my instinct, I'd say @uranusjr's proposal at #5780 (comment) looks promising (basically reinstall only if url changed compared to direct_url.json), but may require a new |
My group needs the reinstall behavior for wheels.
…On Thu, Nov 19, 2020, 08:35 Paul Moore ***@***.***> wrote:
Yeah, I get what you're saying, I just (still) disagree. I think that the
special case should be local *source code*, and we shouldn't be
special-casing wheels.
I've seen no-one claim that they need reinstall behaviour for wheels.
Longer-term, I think we should have a proper look at what constitutes
pip's idea of the "same thing" when it comes to name/version etc. At the
moment, we're making somewhat adhoc decisions based on individual use
cases. Doing what people want is good! But at the same time, we need a
proper model of the objects pip is working with, otherwise we'll end up
with inconsistencies, and things get messy.
(As an example, pip freeze can't see the distinction between installing
foo-1.0 from an index, and forcing an explicit install from a local wheel.
So by making pip install ./foo-1.0-xxx.whl do something different, we may
be breaking pip freeze. I don't think this is a significant problem, nor
do I think it's something we should be worrying about, but it *is* an
example of how not having a consistent model affects unrelated parts of the
code).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#8711 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABVICTP4ZJMM45P2STFWYOLSQVCL3ANCNFSM4PVH2TUQ>
.
|
Thanks for the data point @gregcouch - why is |
A few notes, after good night's sleep and re-reading this issue:
That matches my instinct as well. :) The distinction to me is that #5780 is asking for a behavior change in how we handle URLs in general, toward making it more consistent. This issue is about making the new resolver behave like the old resolver w.r.t. local directories and files.
YES! Exactly. We could've used this resolver change to also make progress on #5780, but we just don't have the time/dev resource available right now to properly consider all-the-things and make those changes as we probably want to. I think #9147 gets us mostly where we might want to be, in terms of this issue. The behaviors for local files and directories would be unchanged between the old vs new resolver (as far as I can tell), including the behaviors for wheels, albeit with more informative messages.
I don't either! That's the whole reason behind me falling back to "let's just do what the old resolver does and revisit this when we have more time to think through this, instead of unintentionally breaking certain workflows". The only thing different is that there's a new deprecation, toward changing the sdist reinstall behavior. :)
There is, definitely. I start a non-pip full-time role on Monday, which will affect my availability. Plus, we've already had fairly substantial delays for various other reasons, so I'm not too keen on waiting until after we have an extended discussion on this to move forward with the release. :)
And, I agree with this. I tried implementing this, but it quickly got a little more messy and I realized it was easier to replicate the old resolver's behavior than to deviate from it.
Could you elaborate a little further on this? Based on my testing here, even the old resolver did not reinstall wheels if the versions match. Either you are asking for behavior that wasn't in the old resolver or I am missing something. :)
vs ❯ pip install --no-deps ../furo/dist/furo-2020.11.19b18-py3-none-any.whl
Processing /Users/pradyunsg/Projects/furo/dist/furo-2020.11.19b18-py3-none-any.whl
furo is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel. |
I just did a quick test with 20.2.4:
#9147 does this:
So that does not quite reproduce what the old resolver did. It looks like the behaviour of 20.2.4 is kind of a side effect of pip needing to build to find the package name. |
We don't need bug for bug compatibility IMO - just something that's not obviously borked. 😅 I'm inclined to say that the behaviour of PEP 508 vs non-PEP 508 situations to be a bit of a bug-that-is-difficult-to-recreate, and making it consistent on that front right now is A-OK. |
Sure, but what is the bug in the first place ? That's not obvious to me. Perhaps the bug is that it did reinstall at all. |
As you know the problem with --force-install is that it reinstalls all of
the dependencies. --no-deps is usually okay, but fails when the
dependencies are changed. I want to be able to write the build script and
forget the details. And --force-reinstall --no-deps doesn't do that.
…On Sat, Nov 21, 2020, 01:31 Paul Moore ***@***.***> wrote:
Thanks for the data point @gregcouch <https://github.com/gregcouch> - why
is --force-reinstall (possibly with --no-deps) not sufficient for you?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8711 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABVICTKANZACJY6IFADFWHTSQ6CIZANCNFSM4PVH2TUQ>
.
|
Same in my team, and why I have raised #9116.
For our developers the workflow is to re-run
Think of it: The only reason to re-run EDIT: According to @pfmoore's comment I may have misunderstood the issue description. |
I was pointed here by the deprication warning: Currently on How might I achieve the same behavior once on I tried reading through the comments but it is not very clear. The deprecation warning however seems very clear, what I need will stop working with |
You asked for feedback, so I'll tell you what I think... I normally expect Having the behavior change depending on whether a file is a wheel or an sdist is surprising --- to me, file name vs package name is a way more salient distinction. But I've never encountered that quirk before, so maybe it doesn't matter. I guess it's fine if my mental model was wrong... but if the |
My company relies on things NOT reinstalling as an optimization in our production build pipeline and it seems that this behavior is different now, I assume because of this issue.
Now, pip seems to want to install the library again in step 2. Is there anyway to avoid this behavior now? |
Merging this into #5780 (comment) |
Without the resolver pip always reinstalled source distributions that it got as a direct command-line argument. Such is the case of tox, that builds the sdist, and then invokes pip to install it. In a pip with resolver world now, pip seems to no longer do this but rather first check the version number to see if it's not already installed:
For local development projects, the version number though is highly untrustworthy, and the records/their contents are different even if the version number is the same. You generally only change versions at releases. We should either always re-install sdists/wheels passed in as paths or ensure that the content of the installed and passed are byte identical...
PS. tox/users could pass
--force-reinstall
to force the operation I guess, but this would be a breaking feature from POV of pip users.The text was updated successfully, but these errors were encountered: