From: yegorslists at googlemail.com <yegorslists@googlemail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] scanpypi: add support for the new PyPI infrastructure
Date: Wed, 18 Apr 2018 11:55:42 +0200 [thread overview]
Message-ID: <20180418095542.22608-1-yegorslists@googlemail.com> (raw)
From: Yegor Yefremov <yegorslists@googlemail.com>
https://pypi.python.org URL has been changed to https://pypi.org.
Package's JSON object now contains sha256 checksum, so use it
instead of locally computed one. Change comments in the hash
file accordingly.
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
utils/scanpypi | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/utils/scanpypi b/utils/scanpypi
index f03ad0bb64..8a2ae00434 100755
--- a/utils/scanpypi
+++ b/utils/scanpypi
@@ -153,7 +153,7 @@ class BuildrootPackage():
"""
Fetch a package's metadata from the python package index
"""
- self.metadata_url = 'https://pypi.python.org/pypi/{pkg}/json'.format(
+ self.metadata_url = 'https://pypi.org/pypi/{pkg}/json'.format(
pkg=self.real_name)
try:
pkg_json = six.moves.urllib.request.urlopen(self.metadata_url).read().decode()
@@ -187,7 +187,7 @@ class BuildrootPackage():
self.metadata['urls'] = [{
'packagetype': 'sdist',
'url': self.metadata['info']['download_url'],
- 'md5_digest': None}]
+ 'digests': None}]
# In this case, we can't get the name of the downloaded file
# from the pypi api, so we need to find it, this should work
urlpath = six.moves.urllib.parse.urlparse(
@@ -208,10 +208,10 @@ class BuildrootPackage():
else:
self.used_url = download_url
self.as_string = download.read()
- if not download_url['md5_digest']:
+ if not download_url['digests']['md5']:
break
self.md5_sum = hashlib.md5(self.as_string).hexdigest()
- if self.md5_sum == download_url['md5_digest']:
+ if self.md5_sum == download_url['digests']['md5']:
break
else:
if download.__class__ == six.moves.urllib.error.HTTPError:
@@ -529,22 +529,23 @@ class BuildrootPackage():
path_to_hash = os.path.join(self.pkg_dir, pkg_hash)
print('Creating {filename}...'.format(filename=path_to_hash))
lines = []
- if self.used_url['md5_digest']:
- md5_comment = '# md5 from {url}, sha256 locally computed\n'.format(
+ if self.used_url['digests']['md5'] and self.used_url['digests']['sha256']:
+ hash_header = '# md5, sha256 from {url}\n'.format(
url=self.metadata_url)
- lines.append(md5_comment)
+ lines.append(hash_header)
hash_line = '{method}\t{digest} {filename}\n'.format(
method='md5',
- digest=self.used_url['md5_digest'],
+ digest=self.used_url['digests']['md5'],
+ filename=self.filename)
+ lines.append(hash_line)
+ hash_line = '{method}\t{digest} {filename}\n'.format(
+ method='sha256',
+ digest=self.used_url['digests']['sha256'],
filename=self.filename)
lines.append(hash_line)
- digest = hashlib.sha256(self.as_string).hexdigest()
- hash_line = '{method}\t{digest} {filename}\n'.format(
- method='sha256',
- digest=digest,
- filename=self.filename)
- lines.append(hash_line)
+ if self.license_files:
+ lines.append('# Locally computed sha256 checksums\n')
for license_file in self.license_files:
sha256 = hashlib.sha256()
with open(license_file, 'rb') as lic_f:
--
2.17.0
next reply other threads:[~2018-04-18 9:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-18 9:55 yegorslists at googlemail.com [this message]
2018-04-18 15:14 ` [Buildroot] [PATCH] scanpypi: add support for the new PyPI infrastructure Thomas Petazzoni
2018-04-18 21:22 ` Arnout Vandecappelle
2018-04-19 6:57 ` Yegor Yefremov
2018-04-23 7:45 ` Arnout Vandecappelle
2018-05-01 6:53 ` Peter Korsgaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180418095542.22608-1-yegorslists@googlemail.com \
--to=yegorslists@googlemail.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.