From e58b0fdaeaedd73a0ca19ad23a63874708d86b91 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sun, 15 Nov 2020 21:54:42 +0100 Subject: Remove Travis and Cirrus, use GH also for FreeBSD (#1880) --- scripts/internal/download_wheels_github.py | 10 ++-- scripts/internal/generate_manifest.py | 4 +- scripts/internal/print_wheels.py | 80 ++++++++++++++++++++---------- scripts/internal/winmake.py | 21 -------- 4 files changed, 61 insertions(+), 54 deletions(-) (limited to 'scripts') diff --git a/scripts/internal/download_wheels_github.py b/scripts/internal/download_wheels_github.py index 5623bb59..9de66fc2 100755 --- a/scripts/internal/download_wheels_github.py +++ b/scripts/internal/download_wheels_github.py @@ -57,12 +57,14 @@ 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) + if os.path.exists(src): + 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) + if os.path.exists(src): + print("rename: %s\n %s" % (src, dst)) + os.rename(src, dst) def run(): diff --git a/scripts/internal/generate_manifest.py b/scripts/internal/generate_manifest.py index f760dd65..384fb329 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 = ('.cirrus.yml', '.travis.yml', 'appveyor.yml') -SKIP_PREFIXES = ('.ci/', '.github/', 'scripts/internal/') +SKIP_FILES = ('appveyor.yml') +SKIP_PREFIXES = ('.ci/', '.github/') def sh(cmd): diff --git a/scripts/internal/print_wheels.py b/scripts/internal/print_wheels.py index 3c966173..c2b8d36b 100755 --- a/scripts/internal/print_wheels.py +++ b/scripts/internal/print_wheels.py @@ -14,57 +14,83 @@ from psutil._common import print_color from psutil._common import bytes2human -def main(): - def is64bit(name): - return name.endswith(('x86_64.whl', 'amd64.whl')) +class Wheel: - groups = collections.defaultdict(list) - for path in glob.glob('dist/*.whl'): - name = os.path.basename(path) - plat = name.split('-')[-1] - pyimpl = name.split('-')[3] + def __init__(self, path): + self._path = path + self._name = os.path.basename(path) + + def __repr__(self): + return "" % ( + self.name, self.platform(), self.arch(), self.pyver()) + + __str__ = __repr__ + + @property + def name(self): + return self._name + + def platform(self): + plat = self.name.split('-')[-1] + pyimpl = self.name.split('-')[3] ispypy = 'pypy' in pyimpl if 'linux' in plat: if ispypy: - groups['pypy_on_linux'].append(name) + return 'pypy_on_linux' else: - groups['linux'].append(name) + return 'linux' elif 'win' in plat: if ispypy: - groups['pypy_on_windows'].append(name) + return 'pypy_on_windows' else: - groups['windows'].append(name) + return 'windows' elif 'macosx' in plat: if ispypy: - groups['pypy_on_macos'].append(name) + return 'pypy_on_macos' else: - groups['macos'].append(name) + return 'macos' else: - assert 0, name + raise ValueError("unknown platform %r" % self.name) + + def arch(self): + if self.name.endswith(('x86_64.whl', 'amd64.whl')): + return '64' + return '32' + + def pyver(self): + pyver = 'pypy' if self.name.split('-')[3].startswith('pypy') else 'py' + pyver += self.name.split('-')[2][2:] + return pyver + + def size(self): + return os.path.getsize(self._path) + + +def main(): + groups = collections.defaultdict(list) + for path in glob.glob('dist/*.whl'): + wheel = Wheel(path) + groups[wheel.platform()].append(wheel) 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)) + for platf, wheels in groups.items(): + ppn = "%s (total = %s)" % (platf, len(wheels)) s = templ % (ppn, "size", "arch", "pyver") print_color('\n' + s, color=None, bold=True) - for name in sorted(names): + for wheel in sorted(wheels, key=lambda x: x.name): tot_files += 1 - path = os.path.join('dist', name) - size = os.path.getsize(path) - 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:] - s = templ % (name, bytes2human(size), arch, pyver) - if 'pypy' in pyver: + tot_size += wheel.size() + s = templ % (wheel.name, bytes2human(wheel.size()), wheel.arch(), + wheel.pyver()) + if 'pypy' in wheel.pyver(): print_color(s, color='violet') else: print_color(s, color='brown') print_color("\ntotals: files=%s, size=%s" % ( - tot_files, bytes2human(tot_size)), bold=1) + tot_files, bytes2human(tot_size)), bold=True) if __name__ == '__main__': diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index faa2aea8..933951a2 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -208,12 +208,6 @@ def recursive_rm(*patterns): safe_rmtree(os.path.join(root, dir)) -def test_setup(): - os.environ['PYTHONWARNINGS'] = 'all' - os.environ['PSUTIL_TESTING'] = '1' - os.environ['PSUTIL_DEBUG'] = '1' - - # =================================================================== # commands # =================================================================== @@ -368,7 +362,6 @@ def clean(): "*__pycache__", ".coverage", ".failed-tests.txt", - ".tox", ) safe_rmtree("build") safe_rmtree(".coverage") @@ -398,7 +391,6 @@ def lint(): def test(name=RUNNER_PY): """Run tests""" build() - test_setup() sh("%s %s" % (PYTHON, name)) @@ -406,7 +398,6 @@ def coverage(): """Run coverage tests.""" # Note: coverage options are controlled by .coveragerc file build() - test_setup() sh("%s -m coverage run %s" % (PYTHON, RUNNER_PY)) sh("%s -m coverage report" % PYTHON) sh("%s -m coverage html" % PYTHON) @@ -416,70 +407,60 @@ def coverage(): def test_process(): """Run process tests""" build() - test_setup() sh("%s psutil\\tests\\test_process.py" % PYTHON) def test_system(): """Run system tests""" build() - test_setup() sh("%s psutil\\tests\\test_system.py" % PYTHON) def test_platform(): """Run windows only tests""" build() - test_setup() sh("%s psutil\\tests\\test_windows.py" % PYTHON) def test_misc(): """Run misc tests""" build() - test_setup() sh("%s psutil\\tests\\test_misc.py" % PYTHON) def test_unicode(): """Run unicode tests""" build() - test_setup() sh("%s psutil\\tests\\test_unicode.py" % PYTHON) def test_connections(): """Run connections tests""" build() - test_setup() sh("%s psutil\\tests\\test_connections.py" % PYTHON) def test_contracts(): """Run contracts tests""" build() - test_setup() sh("%s psutil\\tests\\test_contracts.py" % PYTHON) def test_testutils(): """Run test utilities tests""" build() - test_setup() sh("%s psutil\\tests\\test_testutils.py" % PYTHON) def test_by_name(name): """Run test by name""" build() - test_setup() sh("%s -m unittest -v %s" % (PYTHON, name)) def test_failed(): """Re-run tests which failed on last run.""" build() - test_setup() sh("%s %s --last-failed" % (PYTHON, RUNNER_PY)) @@ -514,14 +495,12 @@ def bench_oneshot_2(): def print_access_denied(): """Print AD exceptions raised by all Process methods.""" build() - test_setup() sh("%s -Wa scripts\\internal\\print_access_denied.py" % PYTHON) def print_api_speed(): """Benchmark all API calls.""" build() - test_setup() sh("%s -Wa scripts\\internal\\print_api_speed.py" % PYTHON) -- cgit v1.2.1