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 | |
parent | e133fa15403a2996b01d25517db693d416175824 (diff) | |
download | psutil-wheels6.tar.gz |
add print_wheels.py script + refactor Makefilewheels6
-rw-r--r-- | MANIFEST.in | 1 | ||||
-rw-r--r-- | Makefile | 36 | ||||
-rw-r--r-- | scripts/internal/download_wheels_github.py | 64 | ||||
-rw-r--r-- | scripts/internal/print_wheels.py | 66 |
4 files changed, 90 insertions, 77 deletions
diff --git a/MANIFEST.in b/MANIFEST.in index 6f22b320..d52a691d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -126,6 +126,7 @@ include scripts/internal/print_access_denied.py include scripts/internal/print_announce.py include scripts/internal/print_api_speed.py include scripts/internal/print_timeline.py +include scripts/internal/print_wheels.py include scripts/internal/purge_installation.py include scripts/internal/tidelift.py include scripts/internal/winmake.py @@ -208,20 +208,9 @@ install-git-hooks: ## Install GIT pre-commit hook. chmod +x .git/hooks/pre-commit # =================================================================== -# Distribution +# Wheels # =================================================================== -git-tag-release: ## Git-tag a new release. - git tag -a release-`python -c "import setup; print(setup.get_version())"` -m `git rev-list HEAD --count`:`git rev-parse --short HEAD` - git push --follow-tags - -sdist: ## Create tar.gz source distribution. - ${MAKE} generate-manifest - $(PYTHON) setup.py sdist - -wheel: ## Generate wheel. - $(PYTHON) setup.py bdist_wheel - download-wheels-appveyor: ## Download latest wheels hosted on appveyor. $(PYTHON) scripts/internal/download_wheels_appveyor.py --user giampaolo --project psutil @@ -229,14 +218,31 @@ download-wheels-github: ## Download latest wheels hosted on github. $(PYTHON) scripts/internal/download_wheels_github.py --user=giampaolo --project=psutil --tokenfile=~/.github.token download-wheels: ## Download wheels from github and appveyor + rm -rf dist ${MAKE} download-wheels-appveyor ${MAKE} download-wheels-github + ${MAKE} print-wheels + +print-wheels: ## Print downloaded wheels + $(PYTHON) scripts/internal/print_wheels.py + +# =================================================================== +# Distribution +# =================================================================== + +git-tag-release: ## Git-tag a new release. + git tag -a release-`python -c "import setup; print(setup.get_version())"` -m `git rev-list HEAD --count`:`git rev-parse --short HEAD` + git push --follow-tags + +sdist: ## Create tar.gz source distribution. + ${MAKE} generate-manifest + $(PYTHON) setup.py sdist upload-src: ## Upload source tarball on https://pypi.org/project/psutil/ ${MAKE} sdist - $(PYTHON) setup.py sdist upload + $(PYTHON) -m twine upload dist/*.tar.gz -upload-win-wheels: ## Upload wheels in dist/* directory on PyPI. +upload-wheels: ## Upload wheels in dist/* directory on PyPI. $(PYTHON) -m twine upload dist/*.whl # --- others @@ -257,7 +263,7 @@ pre-release: ## Check if we're ready to produce a new release. ${MAKE} install ${MAKE} generate-manifest git diff MANIFEST.in > /dev/null # ...otherwise 'git diff-index HEAD' will complain - ${MAKE} win-download-wheels + ${MAKE} download-wheels ${MAKE} sdist $(PYTHON) -c \ "from psutil import __version__ as ver; \ 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(): diff --git a/scripts/internal/print_wheels.py b/scripts/internal/print_wheels.py new file mode 100644 index 00000000..be8290e0 --- /dev/null +++ b/scripts/internal/print_wheels.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Nicely print wheels print in dist/ directory.""" + +import collections +import glob +import os + +from psutil._common import print_color +from psutil._common import bytes2human + + +def main(): + def is64bit(name): + return name.endswith(('x86_64.whl', 'amd64.whl')) + + groups = collections.defaultdict(list) + for path in glob.glob('dist/*.whl'): + name = os.path.basename(path) + 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') + + +if __name__ == '__main__': + main() |