From 8fc5ed1b20c9c9fab75164aae1984698a46974dc Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sun, 15 Nov 2020 00:27:05 +0100 Subject: Rewrite Linux prlimit() with ctypes (Linux wheels) (#1879) --- scripts/internal/download_wheels_appveyor.py | 4 ++-- scripts/internal/download_wheels_github.py | 14 +++++++++++ scripts/internal/generate_manifest.py | 4 ++-- scripts/internal/print_announce.py | 16 ++++++++++++- scripts/internal/print_hashes.py | 35 ++++++++++++++++++++++++++++ scripts/internal/print_wheels.py | 9 +++++-- scripts/procinfo.py | 1 - 7 files changed, 75 insertions(+), 8 deletions(-) mode change 100644 => 100755 scripts/internal/download_wheels_github.py create mode 100755 scripts/internal/print_hashes.py mode change 100644 => 100755 scripts/internal/print_wheels.py (limited to 'scripts') diff --git a/scripts/internal/download_wheels_appveyor.py b/scripts/internal/download_wheels_appveyor.py index a6773f34..83ea55a1 100755 --- a/scripts/internal/download_wheels_appveyor.py +++ b/scripts/internal/download_wheels_appveyor.py @@ -66,7 +66,7 @@ def get_file_urls(options): yield url -def rename_27_wheels(): +def rename_win27_wheels(): # See: https://github.com/giampaolo/psutil/issues/810 src = 'dist/psutil-%s-cp27-cp27m-win32.whl' % PSUTIL_VERSION dst = 'dist/psutil-%s-cp27-none-win32.whl' % PSUTIL_VERSION @@ -101,7 +101,7 @@ def run(options): return exit("expected %s files, got %s" % (expected, completed)) if exc: return exit() - rename_27_wheels() + rename_win27_wheels() def main(): diff --git a/scripts/internal/download_wheels_github.py b/scripts/internal/download_wheels_github.py old mode 100644 new mode 100755 index 4aa50d5d..5623bb59 --- a/scripts/internal/download_wheels_github.py +++ b/scripts/internal/download_wheels_github.py @@ -21,6 +21,7 @@ import os import requests import zipfile +from psutil import __version__ as PSUTIL_VERSION from psutil._common import bytes2human from psutil.tests import safe_rmpath @@ -52,12 +53,25 @@ def download_zip(url): print("got %s, size %s)" % (OUTFILE, bytes2human(totbytes))) +def rename_win27_wheels(): + # See: https://github.com/giampaolo/psutil/issues/810 + src = 'dist/psutil-%s-cp27-cp27m-win32.whl' % PSUTIL_VERSION + dst = 'dist/psutil-%s-cp27-none-win32.whl' % PSUTIL_VERSION + print("rename: %s\n %s" % (src, dst)) + os.rename(src, dst) + src = 'dist/psutil-%s-cp27-cp27m-win_amd64.whl' % PSUTIL_VERSION + dst = 'dist/psutil-%s-cp27-none-win_amd64.whl' % PSUTIL_VERSION + print("rename: %s\n %s" % (src, dst)) + os.rename(src, dst) + + def run(): data = get_artifacts() download_zip(data['artifacts'][0]['archive_download_url']) os.makedirs('dist', exist_ok=True) with zipfile.ZipFile(OUTFILE, 'r') as zf: zf.extractall('dist') + rename_win27_wheels() def main(): diff --git a/scripts/internal/generate_manifest.py b/scripts/internal/generate_manifest.py index c0be6d99..f760dd65 100755 --- a/scripts/internal/generate_manifest.py +++ b/scripts/internal/generate_manifest.py @@ -13,8 +13,8 @@ import subprocess SKIP_EXTS = ('.png', '.jpg', '.jpeg') -SKIP_FILES = ('.travis.yml', 'appveyor.yml') -SKIP_PREFIXES = ('.ci/', '.github/') +SKIP_FILES = ('.cirrus.yml', '.travis.yml', 'appveyor.yml') +SKIP_PREFIXES = ('.ci/', '.github/', 'scripts/internal/') def sh(cmd): diff --git a/scripts/internal/print_announce.py b/scripts/internal/print_announce.py index 180bf377..c9948c1d 100755 --- a/scripts/internal/print_announce.py +++ b/scripts/internal/print_announce.py @@ -6,16 +6,22 @@ """ Prints release announce based on HISTORY.rst file content. +See: https://pip.pypa.io/en/stable/reference/pip_install/#hash-checking-mode """ import os import re +import subprocess +import sys from psutil import __version__ as PRJ_VERSION HERE = os.path.abspath(os.path.dirname(__file__)) -HISTORY = os.path.abspath(os.path.join(HERE, '../../HISTORY.rst')) +ROOT = os.path.realpath(os.path.join(HERE, '..', '..')) +HISTORY = os.path.join(ROOT, 'HISTORY.rst') +PRINT_HASHES_SCRIPT = os.path.join( + ROOT, 'scripts', 'internal', 'print_hashes.py') PRJ_NAME = 'psutil' PRJ_URL_HOME = 'https://github.com/giampaolo/psutil' @@ -56,6 +62,11 @@ Links - Documentation: {prj_urldoc} - What's new: {prj_urlwhatsnew} +Hashes +====== + +{hashes} + -- Giampaolo - https://gmpy.dev/about @@ -100,6 +111,8 @@ def get_changes(): def main(): changes = get_changes() + hashes = subprocess.check_output( + [sys.executable, PRINT_HASHES_SCRIPT, 'dist/']).strip().decode() print(template.format( prj_name=PRJ_NAME, prj_version=PRJ_VERSION, @@ -108,6 +121,7 @@ def main(): prj_urldoc=PRJ_URL_DOC, prj_urlwhatsnew=PRJ_URL_WHATSNEW, changes=changes, + hashes=hashes, )) diff --git a/scripts/internal/print_hashes.py b/scripts/internal/print_hashes.py new file mode 100755 index 00000000..434c43d5 --- /dev/null +++ b/scripts/internal/print_hashes.py @@ -0,0 +1,35 @@ +#!/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. + +""" +Prints files hashes. +See: https://pip.pypa.io/en/stable/reference/pip_install/#hash-checking-mode +""" + +import hashlib +import os +import sys + + +def csum(file, kind): + h = hashlib.new(kind) + with open(file, "rb") as f: + h.update(f.read()) + return h.hexdigest() + + +def main(): + dir = sys.argv[1] + for name in sorted(os.listdir(dir)): + file = os.path.join(dir, name) + md5 = csum(file, "md5") + sha256 = csum(file, "sha256") + print("%s\nmd5: %s\nsha256: %s\n" % ( + os.path.basename(file), md5, sha256)) + + +if __name__ == "__main__": + main() diff --git a/scripts/internal/print_wheels.py b/scripts/internal/print_wheels.py old mode 100644 new mode 100755 index be8290e0..3c966173 --- a/scripts/internal/print_wheels.py +++ b/scripts/internal/print_wheels.py @@ -42,16 +42,18 @@ def main(): else: assert 0, name - totsize = 0 + tot_files = 0 + tot_size = 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): + tot_files += 1 path = os.path.join('dist', name) size = os.path.getsize(path) - totsize += size + tot_size += size arch = '64' if is64bit(name) else '32' pyver = 'pypy' if name.split('-')[3].startswith('pypy') else 'py' pyver += name.split('-')[2][2:] @@ -61,6 +63,9 @@ def main(): else: print_color(s, color='brown') + print_color("\ntotals: files=%s, size=%s" % ( + tot_files, bytes2human(tot_size)), bold=1) + if __name__ == '__main__': main() diff --git a/scripts/procinfo.py b/scripts/procinfo.py index 8eea3377..743a1777 100755 --- a/scripts/procinfo.py +++ b/scripts/procinfo.py @@ -102,7 +102,6 @@ RLIMITS_MAP = { "RLIMIT_CPU": "cputime", "RLIMIT_DATA": "datasize", "RLIMIT_FSIZE": "filesize", - "RLIMIT_LOCKS": "locks", "RLIMIT_MEMLOCK": "memlock", "RLIMIT_MSGQUEUE": "msgqueue", "RLIMIT_NICE": "nice", -- cgit v1.2.1