-
-
Notifications
You must be signed in to change notification settings - Fork 615
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
Avoid URL requirement name collisions #1149
Avoid URL requirement name collisions #1149
Conversation
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.
Hello @geokala,
Thanks for the PR! I've skimmed the patch and noticed that it could break the cache when hashing files. Could you check this out?
https://github.com/jazzband/pip-tools/blob/65f2ebea007ade0dd723cec6f417df1131164eb1/piptools/repositories/pypi.py#L318
Codecov Report
@@ Coverage Diff @@
## master #1149 +/- ##
=======================================
Coverage 99.49% 99.49%
=======================================
Files 36 36
Lines 2752 2773 +21
Branches 326 328 +2
=======================================
+ Hits 2738 2759 +21
Misses 8 8
Partials 6 6
Continue to review full report at Codecov.
|
65f2ebe
to
ecdf92e
Compare
Re: Cache directory, good point. I've factored out the logic to a _get_download_path function and used it in both places it appears to be needed. |
piptools/repositories/pypi.py
Outdated
collisions. | ||
""" | ||
if ireq.link: | ||
salt = hashlib.sha256(ireq.link.url_without_fragment.encode()).hexdigest() |
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've researched pip codebase and have found this function. It probably makes sense to do the same for caching files. What do you think?
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.
Sure, that looks like it'd work nicely. Only issue would be that it's depending on another pip internal function, so increases the risk of breakage every time they update.
If you're comfortable with that then I can switch it to use that this evening.
Otherwise, I can grab the nesting part of it to give the same behaviour and avoid that dependency.
What's your preference?
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 would grab the nesting part.
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.
OK, that'll be in the next push. Just looking at the test now.
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.
Could you update _get_download_path
in accordance with this function?
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.
Can do- but what's the objective?
I can do a straight copy of that function, which will not break on changes to that function's name, but will break if there are changes to the vendored packages that pip uses. Otherwise, what's currently in this PR is a partial copy which should address the concerns but may cause slight cache bloat.
Is the preference here to reduce cache bloat but at the possible expense of stability? If so, I could change it to call that function directly?
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.
The intention is to kill two birds with one stone. But, I don't want to block this improvement due to mysterious bugs and rather approve this as is. Thanks for your contribution!
dfea595
to
07fdf9a
Compare
Can we get a nice explanation of the problem being solved, as the docstring for the test? |
07fdf9a
to
9790601
Compare
@AndydeCleyre Sure, I've just added that- hopefully it's not too verbose? |
Not sure why CI is failing at the moment, will take a look when it deigns to give me logs. |
FYI, also fixed test |
@atugushev Awesome, thanks for that- makes sense, so I've merged it into my PR. |
Looks like CI is failing on 2.7 pip latest (I think?): =================================== log end ==================================== Has pip already stopped supporting 2.7 for make_sdist or something? |
A local run of |
So yeah, looks like more-itertools is being used by easy_install but doesn't support python2.7 any more- I'm guessing I already had an older version of easy_install installed so didn't run into this problem. |
Unfortunately, recent |
Please rebase onto |
Without changing the dir, manual runs of pytest in the pip-tools repo will result in sdists with unexpected content Co-Authored-By: geokala <[email protected]>
e546c9f
to
7bb1002
Compare
Rebased. Fingers crossed. |
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 👍
Great first-time contribution 🚀 Thanks! |
No worries, and thanks for your help! |
Fixes #1145.
This avoids cache collisions when using URLs which both end with the same filename where a later dependency depends on an earlier one, e.g.
file:///tmp/mydep1/master.zip
file:///tmp/mydep2/master.zip
(where mydep2 depends on mydep1)
Changelog-friendly one-liner: Avoid name collisions with URL based requirements.
Contributor checklist