-
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
Fix uninstall of editable on py27 in debian virtualenv #6918
Conversation
What's the exact issue here and why is this PR the appropriate fix? Wouldn't fixing the bug in debian be a better approach here? I'm super skeptical of fixing/working around bugs introduced downstream, since that means pip maintainers would have to do a lot more work than they already do. :) Anyway, assuming we go this route, I'd suggest creating a variable # This is needed as Debian-patched virtualenv and PyPy
# have a bug in sysconfig module.
# https://github.com/pypa/pip/issues/5193
# https://bitbucket.org/pypy/pypy/issues/2506/sysconfig-returns-incorrect-paths
can_not_depend_on_purelib = (
...
)
if can_not_depend_on_purelib:
site_packages = distutils_sysconfig.get_python_lib() # type: Optional[str]
else:
site_packages = sysconfig.get_path("purelib") # type: Optional[str] Further, if there's a way to detect being run on Debian, we should only use the workaround in that case. Lastly, this should probably have tests? |
+1 on getting Debian to fix their problem. We do enough already to deal with issues caused by Debian patching Python and pip, I don't think we should spend limited pip developer resource on supporting/maintaining workarounds like this. If people don't start pushing this sort of problem back on Debian, what's the incentive for Debian to get things right? Edit: Particularly as it's 2.7-only I'm against including this workaround. |
57f2605
to
c3674f7
Compare
@pradyunsg thanks for reviewing this.
I think it is described extensively in #5193.
Probably, but I think noone could pinpoint the root cause of the issue yet. In that spirit your suggestion of having Regarding tests, I'm temporarily pushing a version with only the second commit (without the python 2.7 workaround) to see if that is sufficient to reveal the problem. |
Naively, isn't the issue that Moving away from using an undocumented |
It is, on python 2.7, in some virtualenvs (I confirmed the problem is present on ubuntu 19, but not on centos 7, for instance).
I agree. Yet the issue is a regression in pip >= 10. I personally have little hope that an upstream fix, if possible at all, would percolate to all places where it is needed. In truth, the original issue is not a very big one. The reason I made this PR is that it can have nastier consequences. For instance if you apply the simplification in 9980841 without the sysconfig workaround, it breaks pip freeze of editable installs in the same py27 debian virtualenvs. Unfortunately it does not appear in CI. On my Ubuntu 19 machine I can see it though, by doing $ tox -e py27 -- -k freeze_editable
FAIL
$ tox -e py37 -- -k freeze_editable
OK So, while I totally understand why you want to keep exotic workarounds out of the pip codebase, IMHO, if you decide to close this PR and related issue as won't fix, there is a big risk it will manifest itself again in a worse way later. I reworked the workaround as per @pradyunsg suggestion. Edit: and the fix is not that exotic, since it's there for pypy too |
90ff623
to
740398a
Compare
link about expectations in OSS I empathize that this is an issue for end-users. However, the fact that this only occurs on Debian systems likely points to some downstream packager introduced quirk, which should be fixed on their end. In essence, upstream shouldn't do bug-fixes for when downstream introduces bugs. Yes, it sucks that we have to let users have broken systems. We already have a lot of users face issues because downstream packagers introduces/patches functionality in the Python/pip/virtualenv that they distribute. If we start papering over these issues, then we'll only set the expectation that pip maintainers would fix issues caused by downstream's patches, causing more work for us. It's the responsibility of downstream packagers to fix those issues. While this fix is not exotic, PyPy was updated to remove the need for this workaround. I'd prefer that Debian does the same. On a related note, now that it's been brought to my attention, I'm actually inclined to actually remove (or at least constraint when we use) that workaround on PyPy, based on usage numbers of them on PyPI. All that said, thanks for filing this PR, and getting things moving on this issue @sbidoul! Even though we may not accept this PR, your contribution is much appreciated. :) |
Thank you! ^>^ |
No worries, I know how OSS works. If I sounded like I did not, sincere apologies and please don't hesitate to point out where I miscommunicated. I merely wanted to point out why I think the issue might be considered important and risked to become more significant in the future.
It looks like it's the case indeed. Or perhaps the quirk is, or the fix should go, in virtualenv, I don't know. I would not even have thought about proposing the fix to pip if it was another package that suddenly broke pip. In this case the quirk was present before and it's a pip change that revealed it. So some users may complain that a pip upgrade broke something, even if it's not pip's "fault". Anyway feel free to close this and the related issue, you are the maintainer, no worries from my side. Please, pretty please, then don't apply anything like 9980841 until the root cause has been fixed and it's deployment sufficiently widespread. |
I'm gonna go ahead and close this, and instead push downstream to fix this on their side (if they haven't already). |
I can fix this in Debian, but it does occur to me that this won't help on Debian stable because the version of virtualenv we have there automatically installs the latest pip from pypi, so a Debian patch would never get used inside a virtualenv. On unstable, at least the local pip gets used be default, but once a user upgrades pip inside the virtualenv this problem will recur. Since it's python2.7 only and pip versions later than the one we have in our next release won't support python2.7 anymore, it's probably a don't care. |
For the Debian fix, I feel it’d be easier to patch |
"Easier" is the patch in hand. I've staged that for the next Debian pip upload. I see your point about that being a more general fix. No promises on if I will have time to investigate that too, but I think it makes sense. |
@kitterma @uranusjr is correct to say that the root cause is in debian's python patches and cannot be fixed? In which case can we reconsider merging this in pip? It won't cost us much in terms of maintenance and we can remove it in 6 months with the rest of python2-specific stuff, and at least we'll leave a python2 pip in a slightly better state. |
Since this is Debian only, I think for pip's purposes it's fine to leave it to us to patch (and I already have the patch staged in our git for the next upload, so it would actually be more work for me now not to apply it). We need to look into the virtualenv part of the equation and see what we can do there. If we come up with a virtualenv based solution to the problem, then we might be able to support a fix in the current Debian stable release too (no promises). |
One of the other Debian developers pointed out to me that if this change is pulled into pip then our stable users will get it right away since the stable virtualenv always upgrades to the most recent pip. Maybe that is a better idea. |
I think it depends on how you define fixability. It is true the root problem is in the Python patch made by Debian. But as I said in the linked issue, personally I think it is a good idea to change pip’s uninstallation logic to be a bit more permissibe (not necessarily with this patch since it effects more than uninstallation). It’s great the change would also make this Debian issue go away. |
Fixes #5193