diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-05-25 03:01:58 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-05-25 03:01:58 +0200 |
commit | bcf1ec14b32cf6379634c47ff192f37d5365c839 (patch) | |
tree | 0c3e0f9922a646548df2d5fc79f684a0fe16f7b3 /scripts/internal/download_wheels_github.py | |
parent | e133fa15403a2996b01d25517db693d416175824 (diff) | |
download | psutil-wheels6.tar.gz |
add print_wheels.py script + refactor Makefilewheels6
Diffstat (limited to 'scripts/internal/download_wheels_github.py')
-rw-r--r-- | scripts/internal/download_wheels_github.py | 64 |
1 files changed, 2 insertions, 62 deletions
diff --git a/scripts/internal/download_wheels_github.py b/scripts/internal/download_wheels_github.py index 8a16d337..4aa50d5d 100644 --- a/scripts/internal/download_wheels_github.py +++ b/scripts/internal/download_wheels_github.py @@ -16,14 +16,12 @@ https://developer.github.com/v3/actions/artifacts/ """ import argparse -import collections import json import os import requests import zipfile from psutil._common import bytes2human -from psutil._common import print_color from psutil.tests import safe_rmpath @@ -33,9 +31,6 @@ TOKEN = "" OUTFILE = "wheels-github.zip" -# --- GitHub API - - def get_artifacts(): base_url = "https://api.github.com/repos/%s/%s" % (USER, PROJECT) url = base_url + "/actions/artifacts" @@ -57,67 +52,12 @@ def download_zip(url): print("got %s, size %s)" % (OUTFILE, bytes2human(totbytes))) -# --- extract - - -def extract(): - with zipfile.ZipFile(OUTFILE, 'r') as zf: - zf.extractall('dist') - - -def print_wheels(): - def is64bit(name): - return name.endswith(('x86_64.whl', 'amd64.whl')) - - groups = collections.defaultdict(list) - for name in os.listdir('dist'): - plat = name.split('-')[-1] - pyimpl = name.split('-')[3] - ispypy = 'pypy' in pyimpl - if 'linux' in plat: - if ispypy: - groups['pypy_on_linux'].append(name) - else: - groups['linux'].append(name) - elif 'win' in plat: - if ispypy: - groups['pypy_on_windows'].append(name) - else: - groups['windows'].append(name) - elif 'macosx' in plat: - if ispypy: - groups['pypy_on_macos'].append(name) - else: - groups['macos'].append(name) - else: - assert 0, name - - totsize = 0 - templ = "%-54s %7s %7s %7s" - for platf, names in groups.items(): - ppn = "%s (total = %s)" % (platf.replace('_', ' '), len(names)) - s = templ % (ppn, "size", "arch", "pyver") - print_color('\n' + s, color=None, bold=True) - for name in sorted(names): - path = os.path.join('dist', name) - size = os.path.getsize(path) - totsize += size - arch = '64' if is64bit(name) else '32' - pyver = 'pypy' if name.split('-')[3].startswith('pypy') else 'py' - pyver += name.split('-')[2][2:] - s = templ % (name, bytes2human(size), arch, pyver) - if 'pypy' in pyver: - print_color(s, color='violet') - else: - print_color(s, color='brown') - - def run(): data = get_artifacts() download_zip(data['artifacts'][0]['archive_download_url']) os.makedirs('dist', exist_ok=True) - extract() - print_wheels() + with zipfile.ZipFile(OUTFILE, 'r') as zf: + zf.extractall('dist') def main(): |