-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Speed up unpack_file_url #2196
Speed up unpack_file_url #2196
Conversation
I wonder if it would be even better to ignore everything that is not in the manifest...? Though we could certainly start with this and add that later... |
It would perhaps be better to make an sdist, instead of duplicating that logic in pip. |
My inclination is to maybe add the sdist thing in another PR and lobby to have this PR merged as-is, as I'm not clear yet on how making the sdist would work and this speeds up things considerably as-is. |
Seems reasonable, although tbh it makes me slightly nervous for some reason (specifically including "build"). What happens if a project has the structure
Would foo/build be skipped? (I'm not 100% sure how shutil.ignore_patterns works). OTOH, I like the idea of building via a sdist. That would be a nice change (but it's more disruptive, so I agree it should be a separate PR). |
Honestly the thing that worries me the most about this change is that I don't like the fact that it just hard-codes a bunch of common directories. I mean, probably it'll be ok, especially the |
@dstufft Yeah, that's basically my problem with it (assuming it doesn't have a bug with lower-level directories called build like I said above). But improving the slow copy step is a definite plus... |
Yeah, it's definitely a bit gross (though waiting 17 seconds to install something local is gross too 😄). I wonder if there's some middle ground, like what if I read the list of paths out of |
71175b2
to
25af50a
Compare
shutil.copytree(
link_path, location, symlinks=True,
- ignore=shutil.ignore_patterns('.tox', '.git', 'build'))
+ ignore=shutil.ignore_patterns('.*')) Less gross? |
I wonder if it's best to leave it for now (it's been around forever, so there's not that much urgency) and focus more on the idea of building a sdist and installing that. That should be a lot faster, I'd have thought... Actually, I just did a quick test on a random pip checkout - So going via sdist is a major win. The heuristics are not as good, but still significant, but they are ugly and there's a small chance of breakage. |
@pfmoore: Thanks for doing that quick little benchmark. Building an I'd be up for taking a stab at the sdist -- how are folks envisioning building it? Shelling out to You don't want to merge this PR in the meantime? Now it just filters out |
@msabramo I'd assume we would simply shell out to I'm not against merging this, just a bit nervous it could cause breakages. I'd like some of the other devs to confirm they are OK with it before doing so. @dstufft @jezdez @qwcode ? I just have this nervous concern that with the current heuristic of |
Ah, |
I don't think it's a sane idea (it's hidden on Unix, after all!) hence why I don't mind breaking it... |
I think a |
by ignoring .tox, .git, .hg, .bzr, and .svn when doing `shutil.copytree` in unpack_file_url in pip/download.py. Fixes: pypaGH-2195
25af50a
to
aeb43ce
Compare
diff --git a/pip/download.py b/pip/download.py
index 2f4a349..50b81b3 100644
--- a/pip/download.py
+++ b/pip/download.py
@@ -634,7 +634,8 @@ def unpack_file_url(link, location, download_dir=None):
rmtree(location)
shutil.copytree(
link_path, location, symlinks=True,
- ignore=shutil.ignore_patterns('.*'))
+ ignore=shutil.ignore_patterns(
+ '.tox', '.git', '.hg', '.bzr', '.svn'))
if download_dir:
logger.info('Link is a directory, ignoring download_dir')
return |
I guess the best would be to follow the MANIFEST.in by using https://github.com/pypa/pip/blob/develop/pip/_vendor/distlib/manifest.py |
@msabramo Yep, I'd go with that. @xavfernandez If we're going to respect |
I agree with @pfmoore. |
OK, that's what I have now (https://github.com/pypa/pip/pull/2196/files) so I guess that this is ready to be merged. |
PBR actually makes use of .git in the build dir, so as to be able to determine versions from Git tags present, generate AUTHORS files from the revision history, et cetera. It will at least need some option to be able to override this behavior. |
Seconding that, please make it opt-in (or better yet, just build an sdist in-place, which will dtrt with pbr afaict). |
I'm going to revert this and drop the speed up until it can be done by building a sdist.
|
@dstufft: It sounds like there should be an open issue to speed up pip install via an sdist intermediate step. Am I reading correctly? |
Yea, sorry I forgot to open an issue about it. |
I couldn't find an issue; I probably missed it, but in any case, I reopened #2195 |
sdist way is not very ideal, especially when users want to use |
I don't think we use |
I'm not sure what the cause is, but |
I've had that issue a couple times when the cause was a circular symlink.
…On Wed, May 31, 2017 at 10:43 AM Vlad Firoiu ***@***.***> wrote:
I'm not sure what the cause is, but pip install -e is super slow for me.
It spends minutes waiting on Obtaining file://... even on relatively
small directories.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2196 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAnFSCO9U0QRZ3dXy0YsxS3Zx5QYgkOyks5r_aapgaJpZM4DIue_>
.
|
by ignoring ('.tox', '.git', 'build') when doing
shutil.copytree
.Fixes: GH-2195
Before
After
From 17 seconds to less than 3 seconds; not bad! 😄