-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Temporary build and src directories no longer created in cwd/pwd (bugs #339, #381) #516
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
Conversation
…mes so pip can create them properly later
I'd rather separate the moving of the config dir as we probably need to ensure a migration path for users and that is documented. |
Yes, compliance with the XDG Base Directory specification is its own issue. |
…erent branch later
I've pulled that change from this pull request and will get working on it in a different branch (and pull request). Aside from that, what about the rest of this change? |
The current status says it can't be merged - can you pull develop and fix any conflicts then repush. Thinking out loud - we currently don't have tests on that codepath, which does concern me. At the very least you probably want to add error handling for the rmdir's. The comment on it being a hack does concern me that we could take another approach - looking where we are using build_prefix and src_prefix and handling that more correctly. Certainly in some cases req.py uses mkdtemp. |
Pulled develop and repushed it- it should be able to merge now (I hope). And I added a try/except around the rmdirs. I did some research into this and I think the problem is that, because you can override the location of build_prefix on the command line, pip needs to be able to distinguish between temporary directories it has created and directories that were already present on the system. This is currently done by creating build_prefix (and src_prefix) in req.py (I believe), rather than in locations.py. If the directories are created in locations.py (or already existed before pip started running), they will not be flagged for deletion. Ideally, I suppose, directories should be flagged for deletion if their name matches build_prefix instead? Then they could be created in locations.py but still deleted when pip finishes running. |
Uh, so, looking at the build logs, this seems to fail only in Python 3.2, and I'm not sure exactly what the test is that's causing it to fail, or why.. any thoughts? Here's the failure: FAIL: Test installing an editable git package from a repository, upgrading the repository, Traceback (most recent call last): |
This looks like it's a known flaky test I'm investigating in Issue #530 |
I've managed to get pip to cleanup the build and source dirs if they are the same directories that get created in locations.py, so the "hack" I added to locations.py can be removed. However- this only works for the install command, as install is the only command that calls cleanup_files. So we'd need to have all the commands run that cleanup_files command. I'm also not sure how this would affect bundles- it seems like src_dir used to only be created there is a bundle involved, but now it's always being created all the time. I feel like it might be simpler to keep removing the temporary directories when they're created and re-add them later. Should I keep working on everything I mentioned above? Or should I keep this pull request updated with upstream and wait if someone wants to merge? |
It may make sense to merge this in the short term and do the bigger change in a seperate pull request. |
Unless you're already pretty much there and have a pull request ready - in which case feel free to close this one out. |
No, I'm nowhere near having finished all of that other stuff- so I'll leave this open and keep it updated, awaiting a merge. |
OK I'll merge and close this, and please follow up with a further pull request when you are ready. Thanks for your contribution. |
Does this break the workflow of doing a Personally I'd be happy to lose this "feature", but I'm a bit shy of removing features after the complaints I got around the removal of |
Well- the build directory is no longer always the same, so technically yes. However, if you wanted the workflow to be like that (and I'm not sure why you would), you could run --no-install --build /some/folder and then --no-install --build /some/folder. This could possibly be fixed if the name of the folder generated by tempfile was cached somewhere (so rather than generating a new one every time locations.py gets imported, it would be generated once and written to a config file somewhere). |
Yes, one could still use There's another issue, which is that with this change editables will be checked out to a temp directory. This is wrong, since stuff left hanging around in At this point I think the best option available is to make this change opt-in-only via an env var / config file entry, so as to avoid breaking existing workflows. And if this change is switched on, fail with a clear and explicit error message if I think until there's a pull request ready that fixes this with more care for backwards-compatibility, this change should be reverted. Not actually doing that until I can discuss with @pnasrat. (Also, one other note for @pnasrat - if merging a change with any user-facing implications at all, please be sure to record it in |
It sounds like then that there are two different issues: where src is created and where build is created. As I understand it.. build should be a temporary directory, but always the same temporary directory so existing workflow will still work. But src needs to be a permanent directory because if it's being used at all, it's being used to install editable packages? The first is pretty simple to fix. The second is also simple to fix if we just move src back to cwd, but... isn't there somewhere else we could put it? |
That's right, except I'm not sure that trying to cache the build location between runs is going to work well. For one thing, there isn't really a good place to cache that information. Also, in the long run I wouldn't mind deprecating For |
Okay.. how about I'd be okay with the opt-in thing for now as well, but I think this might be a better solution. |
Actually, yeah, that's a pretty good solution. |
Alright- I'll just open another pull request with that, then, and with src still in CWD. |
This has been an issue with pip for a while (the latest bugs about this appear to be #339 and #381, but glancing through I found a couple of other reports), where the temporary build dir (and the temporary src dir) is created in a user's pwd/cwd.
This fix (unlike the proposed fix linked in #381) will always use tempfile to create the build and src directories, using a format similar to other temporary pip directories (/tmp/pip-[foo]-build, /tmp/pip-[bar]-src).
I also moved the configuration directory from ~/.pip to ~/.config/pip on Unix systems- ~/.config being a place where more and more programs are storing their configuration files, as a way to avoid clutter in a user's home folder.