| 528 | return filename, headers |
| 529 | |
| 530 | def compute_checksum(target, algorithm='sha256', blocksize=2**13): |
| 531 | hashtype = getattr(hashlib, algorithm) |
| 532 | hash_ = hashtype() |
| 533 | logger.debug('computing checksum', target=target, algorithm=algorithm) |
| 534 | with open(target, 'rb') as f: |
| 535 | for chunk in iter(lambda: f.read(blocksize), b''): |
| 536 | hash_.update(chunk) |
| 537 | result = hash_.hexdigest() |
| 538 | logger.debug('computed checksum', result=result) |
| 539 | return result |
| 540 | |
| 541 | def _get_pip_version(): |
| 542 | # try to get pip version without actually importing pip |