Skip to content
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-compile must not archive the entire directory of a locally available editable requirement #583

Merged
merged 2 commits into from
Nov 23, 2017

Conversation

costypetrisor
Copy link
Contributor

@costypetrisor costypetrisor commented Oct 22, 2017

I'm using pip-compile for a project whose working dir is really large, and that project is passed as an editable requirement to pip-compile.
Unfortunately the code behind pip-compile which is imported from pip will make an archive of this entire large working dir even if this editable requirement is available locally.
The archive will be done in %USERPROFILE%\AppData\Local\pip-tools\Cache\pkgs or ~/.cache/pip-tools/Cache/pkgs. I found out about this when this folder bloated to almost 10 gigs.
And another ugly side effect is that I'm experiencing really slow pip-compile times (that large project's dir contains many files, so it's about 5 minutes for me).

I've fixed this by copying some code from pip's RequirementSet._prepare_file inside Resolver._iter_dependencies to avoid this call from pip just for local editable reqs.

I know this fix's approach is not that easily maintainable in the future, and because of that I'm not expecting to have this merged in pip-tools, but I just wanted to share this PR anyway, just in case other people wish to use the fix just for them, like I do.

Contributor checklist
  • Provided the tests for the changes
  • Added the changes to CHANGELOG.md
  • Requested (or received) a review from another contributor

CHANGELOG entry: Fixed long compile durations with an locally available editable requirement

@vphilippon
Copy link
Member

Hey @costypetrisor, thanks for putting your time into this.

I've looked at the pip call your trying to avoid, and I think that if you could simply have download_dir=None in those case, it would fix it.
So, the condition you've put to detect that we have an "editable requirement locally available" could be put in pypi.py, with the condition for VSC sources.

If you can give it a try, we could get this to be a maintainable patch, and merged.

@costypetrisor
Copy link
Contributor Author

Hi @vphilippon

Thanks for looking at this :)
I've been blindsided when I first looked at pip's code and didn't notice that the call I was trying to avoid was under a nice if controllable from the outside.

I've updated the PR.

Thanks :)

@vphilippon
Copy link
Member

@costypetrisor Could you rebase this on master? _compat/contextlib2 was removed.

@costypetrisor
Copy link
Contributor Author

@vphilippon rebase done :)

@costypetrisor
Copy link
Contributor Author

hold on a second, I think I pushed the wrong thing

@costypetrisor
Copy link
Contributor Author

@vphilippon the correct PR branch has been pushed now :)
Thanks! :)

…ent, no archive is being created in pip-tools cache dir
…ditable requirement and this can take a really long time
Copy link
Member

@vphilippon vphilippon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Also, I did a test with a larger-than-usual project myself (the tar.gz is ~180KB), and I'm seeing a 1 minute timesave on the first pip-compile with cleared cache, and no performance loss on the next pip-compile. And that's on a SSD.
Good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants