-
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
pip unexpectedly not installing latest version of git package with branch/commit pinning #2837
Comments
I think this is a duplicate of #2835. |
Yes, it looks like so. Then I would advocate for documenting this behaviour in https://pip.pypa.io/en/latest/reference/pip_install.html#vcs-support, since it's an easy pitfall. |
+1 |
@dukebody, what do you think of my proposed text? |
Hmmm it is not entirely clear IMO. What about the following? ** |
I think docs ought to explain in terms of behavior rather than implementation. My biased opinion is that my version is more clear. |
The sentence I think is not clear (at least to me) is "VCS requirements pin the version of the target commit, not necessarily the commit itself". What does "the version of the target commit" mean? Perhaps we should invite someone else to this conversation to give some more input about how to explain this in clear language. |
BTW, if the latest code in the checked out source has a greater version number, will the new code be installed even if no |
Agreed. How about "the version (specified in the setup.py) of the target commit"?
Yes, that is correct. |
Better. Can we settle this with the following? ** |
@dukebody beautiful! |
In my opinion, this is not a good resolution of this ticket. This behaviour breaks the rule of least astonishment, because it goes against specificity. If this were CSS, the version number in setup.py would be a Can you give me an example scenario where a user might target a specific commit and actually want to just keep the package they already have? I think the software should respect the specificity in the requirements.txt file. If that's not feasible, it should at least not fail silently and should alert the user that their requested branch/tag/commit was not respected. FWIW, I struggled for 4 hours yesterday with a package and neither bumping the version number in my targetted branch, nor passing the -U flag worked. I still haven't got my preferred version installed even now. Here is my fab script that sets up the environment:
and here is the requirement I can't seem to install properly:
I seem to end up with just the master branch every time. (In case you check the repo, I already tried bumping the version to 999, and rolled back that commit when it didn't work) |
@skolsuper I'm not sure why it wouldn't have worked when you bumped the version, but as a workaround I'd try making the requirement editable:
As for resolving this ticket, how would you suggest pip keep track of what commit is currently installed in a noneditable package? Pip currently doesn't persist any state. Is this a good enough reason to start? Take a look at #453 and #507 in which the maintainer essentially closes his own PR to add state for this purpose. My conclusion to this issue is to only use editable requirements. Editable requirements have the expected behavior (as you described it) and the additional advantage of |
Thanks @ryneeverett, I will give that a try. Is there a downside to using editable requirements, or is it a complete no-brainer? I've always avoided it on the basis that I won't be editing them so I don't need/want them editable. |
@skolsuper The only downside I'm aware of is that you have the entire git repository still on your system whereas with noneditable installs you just end up with the source. So it's not maximally lean but I'd say that cost is generally negligible. Hopefully we'll cut it down even further eventually with shallow clones. |
Clarify VCS installation behavior. Resolve #2837.
So far I've always been using editable requirements to solve that issue but I just run into the downside of it: If you set it as non editable, it only exports subpackages and everything is fine but then, changing the commit is not necessarily reflected. |
@dstufft I am raising this issue to your attention since you seem involved in the #2432 conversation regarding shallow Git clones as well as P/Rs (now closed) #453/#507 that are possibly relevant for a solution to this issue. Today I was burned by updating a Git checkout in
As discussed here, this will not re-fetch the new Git source code. The work-around stated above to pass the editable flag does work:
Of course... now I have a 54MB tree ( |
Today I encountered another condition where an editable install is inadequate - when environment markers are present. Consider this requirement:
This requirement will not update if some version of ldap3 is already in the environment. Prepending |
Ok, I (more or less) understand why pip works that way, but I have to say it really breaks expectations in a major way and that the proposed solution (using editable installs) is a workaround at best, with obviously quite a few downsides, cf the previous comments. Not such a problem in my case ATM (the few packages I use with commits as version are small) but if someone can think of possible solution to really fix this issue I'll be happy to give a hand. |
This makes packages that have a git URL in the `requirements.lock` file to be updated, even if the version number does not change. See pypa/pip#2837 for details
Fixes issues with requirements not being upgraded when already installed (for CircleCI) pypa/pip#2837
Even if the checked out source has a greater version number, the code will not be installed unless there is the |
I can confirm that package does not really upgrade even if version in |
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. |
(I'm posting this as a bug since nobody answered to http://stackoverflow.com/questions/30104748/pip-unexpectedly-not-installing-latest-version-of-git-package-with-branch-commit, so I think it is a bug, sorry if it isn't.)
I have a requirements.txt file with the following line (among others):
When I do
I see
And the package is not updated to the master version. Actually, it keeps some former version from PyPI I had listed in
requirements.txt
before.It doesn't work either if I specify a commit in the pinning or use the
--no-cache-dir
flag. I'm using pip 6.1.1.If I use the
--upgrade
flag then it works. But then what is the point of the pinning? Why does it say "Requirement already satisfied" if it really isn't? I'd expect pip to always install the version specified in the pinning.The text was updated successfully, but these errors were encountered: