Skip to content

Commit

Permalink
Future proof a little bit
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmavirus24 committed Sep 13, 2015
1 parent 47fcbdc commit d6dfdd4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions twine/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ def __init__(self, filename, comment, metadata, python_version, filetype):
self.gpg_signature = None

md5_hash = hashlib.md5()
sha2_hash = hashlib.sha256()
with open(filename, "rb") as fp:
content = fp.read(4096)
while content:
md5_hash.update(content)
sha2_hash.update(content)
content = fp.read(4096)

self.md5_digest = md5_hash.hexdigest()
self.sha2_digest = sha2_hash.hexdigest()

@classmethod
def from_filename(cls, filename, comment):
Expand Down Expand Up @@ -114,6 +117,11 @@ def metadata_dictionary(self):
"comment": self.comment,
"md5_digest": self.md5_digest,

# When https://github.com/pypa/warehouse/issues/681 is closed and
# warehouse is deployed, uncomment the line below to start sending
# a more up-to-date digest.
# "sha256_digest": self.sha256_digest,

# PEP 314
"provides": meta.provides,
"requires": meta.requires,
Expand Down

0 comments on commit d6dfdd4

Please sign in to comment.