diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2022-11-11 18:13:58 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2022-11-11 18:13:58 +0100 |
commit | 3290ead1b20633b5f77f114bd9b33ad85e28f7fc (patch) | |
tree | 42770d65e707695288694ecc372755ecf6df5798 | |
parent | f65346fd57df6a23b5ab3ed661d425efe37cbd2a (diff) | |
download | psutil-3290ead1b20633b5f77f114bd9b33ad85e28f7fc.tar.gz |
improve and rename print_wheels.py script
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
-rw-r--r-- | MANIFEST.in | 2 | ||||
-rw-r--r-- | Makefile | 10 | ||||
-rwxr-xr-x | scripts/internal/print_dist.py (renamed from scripts/internal/print_wheels.py) | 57 |
3 files changed, 47 insertions, 22 deletions
diff --git a/MANIFEST.in b/MANIFEST.in index e19c7e2d..13ed1c17 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -141,10 +141,10 @@ include scripts/internal/git_pre_commit.py include scripts/internal/print_access_denied.py include scripts/internal/print_announce.py include scripts/internal/print_api_speed.py +include scripts/internal/print_dist.py include scripts/internal/print_downloads.py include scripts/internal/print_hashes.py include scripts/internal/print_timeline.py -include scripts/internal/print_wheels.py include scripts/internal/purge_installation.py include scripts/internal/winmake.py include scripts/iotop.py @@ -234,14 +234,14 @@ install-git-hooks: ## Install GIT pre-commit hook. download-wheels-github: ## Download latest wheels hosted on github. $(PYTHON) scripts/internal/download_wheels_github.py --tokenfile=~/.github.token - ${MAKE} print-wheels + ${MAKE} print-dist download-wheels-appveyor: ## Download latest wheels hosted on appveyor. $(PYTHON) scripts/internal/download_wheels_appveyor.py - ${MAKE} print-wheels + ${MAKE} print-dist -print-wheels: ## Print downloaded wheels - $(PYTHON) scripts/internal/print_wheels.py +print-dist: ## Print downloaded wheels / tar.gs + $(PYTHON) scripts/internal/print_dist.py # =================================================================== # Distribution @@ -275,7 +275,7 @@ pre-release: ## Check if we're ready to produce a new release. ${MAKE} download-wheels-github ${MAKE} download-wheels-appveyor ${MAKE} print-hashes - ${MAKE} print-wheels + ${MAKE} print-dist $(PYTHON) -m twine check --strict dist/* $(PYTHON) -c \ "from psutil import __version__ as ver; \ diff --git a/scripts/internal/print_wheels.py b/scripts/internal/print_dist.py index 6b19909b..1e8e5562 100755 --- a/scripts/internal/print_wheels.py +++ b/scripts/internal/print_dist.py @@ -4,11 +4,10 @@ # 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.""" +"""List and pretty print tarball & wheel files in the dist/ directory.""" import argparse import collections -import glob import os from psutil._common import bytes2human @@ -22,8 +21,9 @@ class Wheel: self._name = os.path.basename(path) def __repr__(self): - return "<Wheel(name=%s, plat=%s, arch=%s, pyver=%s)>" % ( - self.name, self.platform(), self.arch(), self.pyver()) + return "<%s(name=%s, plat=%s, arch=%s, pyver=%s)>" % ( + self.__class__.__name__, self.name, self.platform(), self.arch(), + self.pyver()) __str__ = __repr__ @@ -56,7 +56,11 @@ class Wheel: def arch(self): if self.name.endswith(('x86_64.whl', 'amd64.whl')): return '64' - return '32' + if self.name.endswith(("i686.whl", "win32.whl")): + return '32' + if self.name.endswith("arm64.whl"): + return 'arm64' + return '?' def pyver(self): pyver = 'pypy' if self.name.split('-')[3].startswith('pypy') else 'py' @@ -67,6 +71,18 @@ class Wheel: return os.path.getsize(self._path) +class Tarball(Wheel): + + def platform(self): + return "source" + + def arch(self): + return "-" + + def pyver(self): + return "-" + + def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('dir', nargs="?", default="dist", @@ -76,28 +92,37 @@ def main(): if not os.path.isdir(args.dir): raise NotADirectoryError(args.dir) groups = collections.defaultdict(list) - for path in glob.glob('%s/*.whl' % args.dir): - wheel = Wheel(path) - groups[wheel.platform()].append(wheel) + + ls = sorted(os.listdir(args.dir), + key=lambda x: x.endswith("tar.gz")) + for name in ls: + path = os.path.join(args.dir, name) + if path.endswith(".whl"): + pkg = Wheel(path) + elif path.endswith(".tar.gz"): + pkg = Tarball(path) + else: + raise ValueError("invalid package %r", path) + groups[pkg.platform()].append(pkg) tot_files = 0 tot_size = 0 templ = "%-100s %7s %7s %7s" - for platf, wheels in groups.items(): - ppn = "%s (total = %s)" % (platf, len(wheels)) + for platf, pkgs in groups.items(): + ppn = "%s (%s)" % (platf, len(pkgs)) s = templ % (ppn, "size", "arch", "pyver") print_color('\n' + s, color=None, bold=True) - for wheel in sorted(wheels, key=lambda x: x.name): + for pkg in sorted(pkgs, key=lambda x: x.name): tot_files += 1 - tot_size += wheel.size() - s = templ % (wheel.name, bytes2human(wheel.size()), wheel.arch(), - wheel.pyver()) - if 'pypy' in wheel.pyver(): + tot_size += pkg.size() + s = templ % (" " + pkg.name, bytes2human(pkg.size()), pkg.arch(), + pkg.pyver()) + if 'pypy' in pkg.pyver(): print_color(s, color='violet') else: print_color(s, color='brown') - print_color("\ntotals: files=%s, size=%s" % ( + print_color("\n\ntotals: files=%s, size=%s" % ( tot_files, bytes2human(tot_size)), bold=True) |