-
-
Notifications
You must be signed in to change notification settings - Fork 614
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
Show basename of hashing URL in debug logs #1113
Show basename of hashing URL in debug logs #1113
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1113 +/- ##
=======================================
Coverage 99.49% 99.49%
=======================================
Files 36 36
Lines 2752 2752
Branches 326 326
=======================================
Hits 2738 2738
Misses 8 8
Partials 6 6
Continue to review full report at Codecov.
|
Before: ``` Generating hashes: django Hashing https://files.pythonhosted.org/packages/a9/4f/8a247eee2958529a6a805d38fbacd9764fd566462fa0016aa2a2947ab2a6/Django-3.0.5-py3-none-any.whl Hashing https://files.pythonhosted.org/packages/ed/52/1f281f39fe38d10c6c73e1c1d26a0aad5406be1108bf5f50423751ea8aa3/Django-3.0.5.tar.gz ``` After: ``` Generating hashes: django Hashing Django-3.0.5-py3-none-any.whl Hashing Django-3.0.5.tar.gz ```
3ecb3b0
to
f41eee3
Compare
I'm missing something here trying to replicate either the Before or After samples above; how should I be getting that? $ rm -f requirements.txt
$ printf '%s\n' django plumbum | pip-compile -v --generate-hashes -o requirements.txt - 2>&1 | grep -A 5 'Generating'
Generating hashes:
plumbum
asgiref
django
sqlparse
pytz Same as on master. |
Ha-ha 😄 Now hashes generates in a second because of #1109! |
Could be tested with |
Steps to test the PR: $ docker run --rm -it python:3.8 /bin/bash
$ pip install git+https://github.com/atugushev/pip-tools@reduce-hashing-url-in-logs#egg=pip-tools
$ pip download future numpy
$ echo torch===1.5.0 | pip-compile - -v -o /tmp/requirements.txt \
--find-links=. \
-f https://download.pytorch.org/whl/torch_stable.html
--generate-hashes \
--pip-args='--no-index' |
Thanks very much! I don't know if this will be a problem in practice, but return posixpath.basename(self._url.split('#', 1)[0].split('?', 1)[0]) For (a pretty bad) example: In [1]: from pip._internal.models.link import Link
In [2]: l = Link('https://www.python.org/dev/peps/pep-0508/#environment-markers')
In [3]: l.url_without_fragment
Out[3]: 'https://www.python.org/dev/peps/pep-0508/'
In [4]: l.show_url
Out[4]: ''
In [5]: l = Link('https://www.python.org/dev/peps/pep-0508/')
In [6]: l.url_without_fragment
Out[6]: 'https://www.python.org/dev/peps/pep-0508/'
In [7]: l.show_url
Out[7]: '' So the question is: will we ever be generating hashes from links with Unrelated question: why does generating hashes (e.g. for EDIT: I guess I have my answer to that unrelated question here. |
That shouldn't be possible. But we could be more accurate with: if link.netloc == PyPI.file_storage_domain:
url = link.show_url
else:
url = link.url_without_fragment
logged_url = redact_auth_from_url(url) See related pip code.
Yeah, to be able to install |
Alright, I tried to break it and couldn't, so LGTM 👍 . I tried making an evil folder with an evil build tag: $ mkdir 'right#here?'
$ cd 'right#here?'
$ pip download plumbum
$ mv plumbum-1.6.9-py2.py3-none-any.whl 'plumbum-1.6.9-1#?-py2.py3-none-any.whl'
$ echo plumbum | pip-compile - -o /dev/null --generate-hashes -v --find-links=. --pip-args --no-index
<snip>
Hashing plumbum-1.6.9-1%23%3F-py2.py3-none-any.whl
<snip> Then I tried making an evil import hug
@hug.get('/plumbum-1.6.9-1#?-py2.py3-none-any.whl', output=hug.output_format.file)
def wheel(nonsense: hug.types.text):
return '/home/andy/Code/right#here?/plumbum-1.6.9-1#?-py2.py3-none-any.whl' $ pip install hug
$ hug -f serve.py $ echo 'plumbum @ http://localhost:8000/plumbum-1.6.9-1%23%3F-py2.py3-none-any.whl?nonsense=bad' | pip-compile - -o /dev/null --generate-hashes -v
<snip>
Hashing plumbum-1.6.9-1%23%3F-py2.py3-none-any.whl
<snip> |
Before:
After:
Steps to test the PR:
Changelog-friendly one-liner: Show basename of a hashing URL in
pip-compile
's debug logs.Contributor checklist