-
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
AdjacentTempDirectory should fail on unwritable directory #6215
Conversation
Ping @cjerdonek - are you able to suggest how best to make the temp directory unwritable? Or another way to test that scenario? I'm stuck (more precisely, all my ideas would be Windows specific ;) ) |
Can you monkeypatch |
Directly linking to #6169 for a better cross-reference. |
Minor remark/question; sorry if this is not relevant: isn't it weird that |
@YannickJadoul It shouldn't be trying to create it there - what scenario is causing this? |
Ah, found it (uninstalling scripts). The fallback needs to be better when this approach fails, but the infrastructure is there - more work incoming! |
My fallback should also handle the previous problem of hitting the maximum path length limit, though it may create more temporary folders (in most cases I assume two: |
@zooba I don't think it's just the scripts. Those result in maybe an even bigger problem (since a new folder in the parent folder of Example (using the ancient version of yannick@Athenai:~$ source TEMPENV/bin/activate
(TEMPENV) yannick@Athenai:~$ ls TEMPENV/
bin include lib pip-selfcheck.json
(TEMPENV) yannick@Athenai:~$ pip install setuptools==18.2
Collecting setuptools==18.2
Using cached https://files.pythonhosted.org/packages/c3/f6/b3224fb53fd3ddebdcc2aafb8f2d3a044a66446c9f17f4e5a24ca03b781b/setuptools-18.2-py2.py3-none-any.whl
Installing collected packages: setuptools
Found existing installation: setuptools 40.7.0
Uninstalling setuptools-40.7.0:
Successfully uninstalled setuptools-40.7.0
Successfully installed setuptools-18.2
(TEMPENV) yannick@Athenai:~$ chmod -w TEMPENV/lib/python3.6/
(TEMPENV) yannick@Athenai:~$ pip install --upgrade setuptools
Collecting setuptools
Using cached https://files.pythonhosted.org/packages/5b/ac/90c7617bfc48ae1265d2c0cc46aeb0a0d482e00577008d21b64efe9a2006/setuptools-40.7.0-py2.py3-none-any.whl
Installing collected packages: setuptools
Found existing installation: setuptools 18.2
Uninstalling setuptools-18.2:
^COperation cancelled by user
(TEMPENV) yannick@Athenai:~$ ls TEMPENV/
bin -in include lib pip-selfcheck.json
(TEMPENV) yannick@Athenai:~$ ls TEMPENV/-in/
easy_install easy_install-3.6
(TEMPENV) yannick@Athenai:~$ chmod +w TEMPENV/lib/python3.6/
(TEMPENV) yannick@Athenai:~$ pip install --upgrade -vvv setuptools
[... lots and lots of PyPI links ...]
Installing collected packages: setuptools
Found existing installation: setuptools 18.2
Uninstalling setuptools-18.2:
Created temporary directory: /home/yannick/TEMPENV/~in
Removing file or directory /home/yannick/TEMPENV/bin/easy_install
Removing file or directory /home/yannick/TEMPENV/bin/easy_install-3.6
Created temporary directory: /home/yannick/TEMPENV/lib/python3.6/site-packages/~_pycache__
Removing file or directory /home/yannick/TEMPENV/lib/python3.6/site-packages/__pycache__/
Created temporary directory: /home/yannick/TEMPENV/lib/python3.6/site-packages/~markerlib
Removing file or directory /home/yannick/TEMPENV/lib/python3.6/site-packages/_markerlib/
Created temporary directory: /home/yannick/TEMPENV/lib/python3.6/-ite-packages
Removing file or directory /home/yannick/TEMPENV/lib/python3.6/site-packages/easy_install.py
Removing file or directory /home/yannick/TEMPENV/lib/python3.6/site-packages/pkg_resources/
Removing file or directory /home/yannick/TEMPENV/lib/python3.6/site-packages/setuptools-18.2.dist-info/
Removing file or directory /home/yannick/TEMPENV/lib/python3.6/site-packages/setuptools/
Successfully uninstalled setuptools-18.2
changing mode of /home/yannick/TEMPENV/bin/easy_install to 755
changing mode of /home/yannick/TEMPENV/bin/easy_install-3.6 to 755
Successfully installed setuptools-40.7.0
Cleaning up...
Removed build tracker '/tmp/pip-req-tracker-e2lpcqcx' EDIT: That's a lot of output, but notice the line saying |
@YannickJadoul Yep, that's the one that I fixed - it's doing that file because of the |
Okay, my fix doesn't account for ordering of the paths, so it's nearly back to where it was before :( Trying again |
@zooba Are you sure? I'm pretty sure this package does not contain scripts, and I still get this
|
The The If there's another directory where files may be installed but the directory is not wholly owned by the package, that could also trigger the same thing. I have a bit more of a fix coming to remove the ordering issues from stash directory creation, but it certainly resolves this issue. |
@zooba OK, yes, fair enough; my bad. Thanks! |
@zooba Are you fixing two issues now? |
@cjerdonek The second one was introduced by the fix for the first. Shuffling directories around is considerably more complex once the fallback mechanism is introduced. |
The CI failures are (going to be) due to some tests failing and timing out, but the logging isn't showing me anything useful. I'm trying to reproduce locally. |
It's also holding up the queue on AppVeyor... I'll go ahead and cancel the build. |
The current problem is during one of the rollback tests - it's creating an extra subdirectory for the .dist-info and moving the original .dist-info into it. Normally this means that the "move" call is recognizing that the source is a file and the destination is a directory and creating the directory, but that isn't the case here (they're both directories). I'll keep looking tomorrow. |
Is there any way to separate the trickier stashing logic from the larger |
@cjerdonek I hope I can make it easier to follow, but ultimately, isn't it the whole point of the UninstallPathSet? The functionality won't be used elsewhere, and it requires creating real directories or else it won't fail to create them (without some serious monkeypatching…). But I'll try factoring it into its own class and then see whether it's worth it. |
It was just a thought. I was mainly just thinking of the |
@cjerdonek I like the idea, so I started it (posted my WIP, which probably won't pass, but will let you see where I'm heading). But now I'm going down a venv rabbithole instead 😖 So I'll get back to this as soon as I fix up the stuff I broke in CPython... |
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 added a couple minor comments.
Also, re: splitting out, I was only thinking _stash()
and _save_dirs
, but this looks good, too!
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.
Seems OK to me but I'm not sure I'm familiar enough with this to "approve".
@zooba Could you please update this PR? |
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
This was just the rebase - I'll get back to finishing the actual PR as soon as I can. |
Thanks @zooba! :) I'm hoping to get this in for 19.0.2 -- which I plan to release in this week. It'd be ideal if we can get this done ~8th or 9th. :) |
I don't think I have anything left to do here. Any suggestions? |
@cjerdonek Could you review this? |
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.
LGTM
If no one voices any concerns in the next few hours, I'll go ahead and merge this.
@pradyunsg Generally my preference is for a clean commit history (as opposed to fixing mistakes, etc), so I would prefer this to be squashed unless the commits were designed to have a coherent sequence. |
Will do. :) |
Uh. And here I am, genuinely sure that I'd clicked Squash and Merge. |
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 #6169
Based on #6225