From 56efb1db0a5235e9a5a3a876657185e51860ced2 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 22 Jun 2024 01:23:01 +0200 Subject: [PATCH 01/77] get rid of TSCRIPT --- .github/workflows/build.yml | 2 +- Makefile | 29 ++++++++++++++--------------- docs/DEVGUIDE.rst | 2 +- make.bat | 7 ------- 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d23bd179c..00eecb141 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -119,7 +119,7 @@ jobs: python-version: 3.x - name: 'Run linters' run: | - python3 -m pip install ruff==0.4.4 black rstcheck toml-sort sphinx + python3 -m pip install ruff black rstcheck toml-sort sphinx make lint-all # upload weels as a single artefact diff --git a/Makefile b/Makefile index 259ad4389..eeee9fde7 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,6 @@ PYTHON = python3 PYTHON_ENV_VARS = PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 ARGS = -TSCRIPT = psutil/tests/runner.py # Internal. PY3_DEPS = \ @@ -132,59 +131,59 @@ setup-dev-env: ## Install GIT hooks, pip, test deps (also upgrades them). test: ## Run all tests. To run a specific test do "make test ARGS=psutil.tests.test_system.TestDiskAPIs" ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) test-parallel: ## Run all tests in parallel. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) --parallel + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) --parallel test-process: ## Run process-related API tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_process.py + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_process.py test-process-all: ## Run tests which iterate over all process PIDs. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_process_all.py + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_process_all.py test-system: ## Run system-related API tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_system.py + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_system.py test-misc: ## Run miscellaneous tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_misc.py + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_misc.py test-testutils: ## Run test utils tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_testutils.py + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_testutils.py test-unicode: ## Test APIs dealing with strings. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_unicode.py + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_unicode.py test-contracts: ## APIs sanity tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_contracts.py + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_contracts.py test-connections: ## Test psutil.net_connections() and Process.net_connections(). ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_connections.py + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_connections.py test-posix: ## POSIX specific tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_posix.py + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_posix.py test-platform: ## Run specific platform tests only. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "OSX", "SUNOS", "WINDOWS", "AIX") if getattr(psutil, x)][0])'`.py + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "OSX", "SUNOS", "WINDOWS", "AIX") if getattr(psutil, x)][0])'`.py test-memleaks: ## Memory leak tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_memleaks.py + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_memleaks.py test-last-failed: ## Re-run tests which failed on last run ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) --last-failed + $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) --last-failed test-coverage: ## Run test coverage. ${MAKE} build diff --git a/docs/DEVGUIDE.rst b/docs/DEVGUIDE.rst index 744ddadf4..6f552081c 100644 --- a/docs/DEVGUIDE.rst +++ b/docs/DEVGUIDE.rst @@ -44,7 +44,7 @@ Once you have a compiler installed run: .. code-block:: bash - make test TSCRIPT=test_script.py # on UNIX + make test ARGS=test_script.py # on UNIX make test test_script.py # on Windows - Do not use ``sudo``. ``make install`` installs psutil as a limited user in diff --git a/make.bat b/make.bat index 2ac53d9ec..ec4fc591e 100644 --- a/make.bat +++ b/make.bat @@ -16,19 +16,12 @@ rem ...therefore it might not work on your Windows installation. rem rem To compile for a specific Python version run: rem set PYTHON=C:\Python34\python.exe & make.bat build -rem -rem To use a different test script: -rem set TSCRIPT=foo.py & make.bat test rem ========================================================================== if "%PYTHON%" == "" ( set PYTHON=python ) -if "%TSCRIPT%" == "" ( - set TSCRIPT=psutil\tests\runner.py -) - rem Needed to locate the .pypirc file and upload exes on PyPI. set HOME=%USERPROFILE% set PSUTIL_DEBUG=1 From d92b4ebfa158b525a7d5ed87fb1d87b8c0297fd8 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 22 Jun 2024 01:28:14 +0200 Subject: [PATCH 02/77] remove runner.py --- .github/workflows/build.yml | 3 +- MANIFEST.in | 1 - Makefile | 1 - psutil/tests/runner.py | 385 ------------------------------------ pyproject.toml | 5 +- scripts/internal/winmake.py | 15 +- 6 files changed, 12 insertions(+), 398 deletions(-) delete mode 100755 psutil/tests/runner.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00eecb141..2c52680f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,8 +82,7 @@ jobs: os: [ubuntu-latest, macos-12] env: CIBW_TEST_COMMAND: - PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python {project}/psutil/tests/runner.py && - PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python {project}/psutil/tests/test_memleaks.py + make test && make test-memleaks CIBW_TEST_EXTRAS: test CIBW_BUILD: 'cp27-*' diff --git a/MANIFEST.in b/MANIFEST.in index bb60aa849..43ee1cda0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -153,7 +153,6 @@ include psutil/arch/windows/wmi.h include psutil/tests/README.rst include psutil/tests/__init__.py include psutil/tests/__main__.py -include psutil/tests/runner.py include psutil/tests/test_aix.py include psutil/tests/test_bsd.py include psutil/tests/test_connections.py diff --git a/Makefile b/Makefile index eeee9fde7..f64ce06fe 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,6 @@ ARGS = PY3_DEPS = \ black \ check-manifest \ - concurrencytest \ coverage \ packaging \ pylint \ diff --git a/psutil/tests/runner.py b/psutil/tests/runner.py deleted file mode 100755 index 3b28b64f1..000000000 --- a/psutil/tests/runner.py +++ /dev/null @@ -1,385 +0,0 @@ -#!/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. - -"""Unit test runner, providing new features on top of unittest module: -- colourized output -- parallel run (UNIX only) -- print failures/tracebacks on CTRL+C -- re-run failed tests only (make test-failed). - -Invocation examples: -- make test -- make test-failed - -Parallel: -- make test-parallel -- make test-process ARGS=--parallel -""" - -from __future__ import print_function - -import atexit -import optparse -import os -import sys -import textwrap -import time -import unittest - - -try: - import ctypes -except ImportError: - ctypes = None - -try: - import concurrencytest # pip install concurrencytest -except ImportError: - concurrencytest = None - -import psutil -from psutil._common import hilite -from psutil._common import print_color -from psutil._common import term_supports_colors -from psutil._compat import super -from psutil.tests import CI_TESTING -from psutil.tests import import_module_by_path -from psutil.tests import print_sysinfo -from psutil.tests import reap_children -from psutil.tests import safe_rmpath - - -VERBOSITY = 2 -FAILED_TESTS_FNAME = '.failed-tests.txt' -NWORKERS = psutil.cpu_count() or 1 -USE_COLORS = not CI_TESTING and term_supports_colors() - -HERE = os.path.abspath(os.path.dirname(__file__)) -loadTestsFromTestCase = ( # noqa: N816 - unittest.defaultTestLoader.loadTestsFromTestCase -) - - -def cprint(msg, color, bold=False, file=None): - if file is None: - file = sys.stderr if color == 'red' else sys.stdout - if USE_COLORS: - print_color(msg, color, bold=bold, file=file) - else: - print(msg, file=file) - - -class TestLoader: - - testdir = HERE - skip_files = ['test_memleaks.py'] - if "WHEELHOUSE_UPLOADER_USERNAME" in os.environ: - skip_files.extend(['test_osx.py', 'test_linux.py', 'test_posix.py']) - - def _get_testmods(self): - return [ - os.path.join(self.testdir, x) - for x in os.listdir(self.testdir) - if x.startswith('test_') - and x.endswith('.py') - and x not in self.skip_files - ] - - def _iter_testmod_classes(self): - """Iterate over all test files in this directory and return - all TestCase classes in them. - """ - for path in self._get_testmods(): - mod = import_module_by_path(path) - for name in dir(mod): - obj = getattr(mod, name) - if isinstance(obj, type) and issubclass( - obj, unittest.TestCase - ): - yield obj - - def all(self): - suite = unittest.TestSuite() - for obj in self._iter_testmod_classes(): - test = loadTestsFromTestCase(obj) - suite.addTest(test) - return suite - - def last_failed(self): - # ...from previously failed test run - suite = unittest.TestSuite() - if not os.path.isfile(FAILED_TESTS_FNAME): - return suite - with open(FAILED_TESTS_FNAME) as f: - names = f.read().split() - for n in names: - test = unittest.defaultTestLoader.loadTestsFromName(n) - suite.addTest(test) - return suite - - def from_name(self, name): - if name.endswith('.py'): - name = os.path.splitext(os.path.basename(name))[0] - return unittest.defaultTestLoader.loadTestsFromName(name) - - -class ColouredResult(unittest.TextTestResult): - def addSuccess(self, test): - unittest.TestResult.addSuccess(self, test) - cprint("OK", "green") - - def addError(self, test, err): - unittest.TestResult.addError(self, test, err) - cprint("ERROR", "red", bold=True) - - def addFailure(self, test, err): - unittest.TestResult.addFailure(self, test, err) - cprint("FAIL", "red") - - def addSkip(self, test, reason): - unittest.TestResult.addSkip(self, test, reason) - cprint("skipped: %s" % reason.strip(), "brown") - - def printErrorList(self, flavour, errors): - flavour = hilite(flavour, "red", bold=flavour == 'ERROR') - super().printErrorList(flavour, errors) - - -class ColouredTextRunner(unittest.TextTestRunner): - """A coloured text runner which also prints failed tests on - KeyboardInterrupt and save failed tests in a file so that they can - be re-run. - """ - - resultclass = ColouredResult if USE_COLORS else unittest.TextTestResult - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.failed_tnames = set() - - def _makeResult(self): - # Store result instance so that it can be accessed on - # KeyboardInterrupt. - self.result = super()._makeResult() - return self.result - - def _write_last_failed(self): - if self.failed_tnames: - with open(FAILED_TESTS_FNAME, "w") as f: - for tname in self.failed_tnames: - f.write(tname + '\n') - - def _save_result(self, result): - if not result.wasSuccessful(): - for t in result.errors + result.failures: - tname = t[0].id() - self.failed_tnames.add(tname) - - def _run(self, suite): - try: - result = super().run(suite) - except (KeyboardInterrupt, SystemExit): - result = self.runner.result - result.printErrors() - raise sys.exit(1) - else: - self._save_result(result) - return result - - def _exit(self, success): - if success: - cprint("SUCCESS", "green", bold=True) - safe_rmpath(FAILED_TESTS_FNAME) - sys.exit(0) - else: - cprint("FAILED", "red", bold=True) - self._write_last_failed() - sys.exit(1) - - def run(self, suite): - result = self._run(suite) - self._exit(result.wasSuccessful()) - - -class ParallelRunner(ColouredTextRunner): - @staticmethod - def _parallelize(suite): - def fdopen(fd, mode, *kwds): - stream = orig_fdopen(fd, mode) - atexit.register(stream.close) - return stream - - # Monkey patch concurrencytest lib bug (fdopen() stream not closed). - # https://github.com/cgoldberg/concurrencytest/issues/11 - orig_fdopen = os.fdopen - concurrencytest.os.fdopen = fdopen - forker = concurrencytest.fork_for_tests(NWORKERS) - return concurrencytest.ConcurrentTestSuite(suite, forker) - - @staticmethod - def _split_suite(suite): - serial = unittest.TestSuite() - parallel = unittest.TestSuite() - for test in suite: - if test.countTestCases() == 0: - continue - if isinstance(test, unittest.TestSuite): - test_class = test._tests[0].__class__ - elif isinstance(test, unittest.TestCase): - test_class = test - else: - raise TypeError("can't recognize type %r" % test) - - if getattr(test_class, '_serialrun', False): - serial.addTest(test) - else: - parallel.addTest(test) - return (serial, parallel) - - def run(self, suite): - ser_suite, par_suite = self._split_suite(suite) - par_suite = self._parallelize(par_suite) - - # run parallel - cprint( - "starting parallel tests using %s workers" % NWORKERS, - "green", - bold=True, - ) - t = time.time() - par = self._run(par_suite) - par_elapsed = time.time() - t - - # At this point we should have N zombies (the workers), which - # will disappear with wait(). - orphans = psutil.Process().children() - _gone, alive = psutil.wait_procs(orphans, timeout=1) - if alive: - cprint("alive processes %s" % alive, "red") - reap_children() - - # run serial - t = time.time() - ser = self._run(ser_suite) - ser_elapsed = time.time() - t - - # print - if not par.wasSuccessful() and ser_suite.countTestCases() > 0: - par.printErrors() # print them again at the bottom - par_fails, par_errs, par_skips = map( - len, (par.failures, par.errors, par.skipped) - ) - ser_fails, ser_errs, ser_skips = map( - len, (ser.failures, ser.errors, ser.skipped) - ) - print( - textwrap.dedent( - """ - +----------+----------+----------+----------+----------+----------+ - | | total | failures | errors | skipped | time | - +----------+----------+----------+----------+----------+----------+ - | parallel | %3s | %3s | %3s | %3s | %.2fs | - +----------+----------+----------+----------+----------+----------+ - | serial | %3s | %3s | %3s | %3s | %.2fs | - +----------+----------+----------+----------+----------+----------+ - """ - % ( - par.testsRun, - par_fails, - par_errs, - par_skips, - par_elapsed, - ser.testsRun, - ser_fails, - ser_errs, - ser_skips, - ser_elapsed, - ) - ) - ) - print( - "Ran %s tests in %.3fs using %s workers" - % ( - par.testsRun + ser.testsRun, - par_elapsed + ser_elapsed, - NWORKERS, - ) - ) - ok = par.wasSuccessful() and ser.wasSuccessful() - self._exit(ok) - - -def get_runner(parallel=False): - def warn(msg): - cprint(msg + " Running serial tests instead.", "red") - - if parallel: - if psutil.WINDOWS: - warn("Can't run parallel tests on Windows.") - elif concurrencytest is None: - warn("concurrencytest module is not installed.") - elif NWORKERS == 1: - warn("Only 1 CPU available.") - else: - return ParallelRunner(verbosity=VERBOSITY) - return ColouredTextRunner(verbosity=VERBOSITY) - - -# Used by test_*,py modules. -def run_from_name(name): - if CI_TESTING: - print_sysinfo() - suite = TestLoader().from_name(name) - runner = get_runner() - runner.run(suite) - - -def setup(): - psutil._set_debug(True) - - -def main(): - setup() - usage = "python3 -m psutil.tests [opts] [test-name]" - parser = optparse.OptionParser(usage=usage, description="run unit tests") - parser.add_option( - "--last-failed", - action="store_true", - default=False, - help="only run last failed tests", - ) - parser.add_option( - "--parallel", - action="store_true", - default=False, - help="run tests in parallel", - ) - opts, args = parser.parse_args() - - if not opts.last_failed: - safe_rmpath(FAILED_TESTS_FNAME) - - # loader - loader = TestLoader() - if args: - if len(args) > 1: - parser.print_usage() - return sys.exit(1) - else: - suite = loader.from_name(args[0]) - elif opts.last_failed: - suite = loader.last_failed() - else: - suite = loader.all() - - if CI_TESTING: - print_sysinfo() - runner = get_runner(opts.parallel) - runner.run(suite) - - -if __name__ == '__main__': - main() diff --git a/pyproject.toml b/pyproject.toml index ba13f2829..77bbc6ed3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,7 +108,6 @@ ignore = [ ".github/workflows/*" = ["T201", "T203"] "psutil/_compat.py" = ["PLW0127"] # self-assigning-variable "psutil/tests/*" = ["EM101", "TRY003"] -"psutil/tests/runner.py" = ["T201", "T203"] "scripts/*" = ["T201", "T203"] "scripts/internal/*" = ["EM101", "T201", "T203", "TRY003"] "setup.py" = ["T201", "T203"] @@ -211,8 +210,8 @@ skip = [ "pp*", ] test-command = [ - "env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python {project}/psutil/tests/runner.py", - "env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python {project}/psutil/tests/test_memleaks.py", + "make test", + "make test-memleaks", ] test-extras = "test" diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index b789aa80d..73e9e6bf3 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -29,9 +29,11 @@ APPVEYOR = bool(os.environ.get('APPVEYOR')) PYTHON = sys.executable if APPVEYOR else os.getenv('PYTHON', sys.executable) -RUNNER_PY = 'psutil\\tests\\runner.py' GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py" PY3 = sys.version_info[0] >= 3 +PYTEST_ARGS = "-v --tb=native " +if PY3: + PYTEST_ARGS += "-o " HERE = os.path.abspath(os.path.dirname(__file__)) ROOT_DIR = os.path.realpath(os.path.join(HERE, "..", "..")) PYPY = '__pypy__' in sys.builtin_module_names @@ -41,6 +43,7 @@ "pip", "pyperf", "pyreadline", + "pytest", "requests", "setuptools", "wheel", @@ -375,17 +378,17 @@ def setup_dev_env(): sh("%s -m pip install -U %s" % (PYTHON, " ".join(DEPS))) -def test(name=RUNNER_PY): +def test(args=""): """Run tests.""" build() - sh("%s %s" % (PYTHON, name)) + sh("%s -m pytest %s %s" % (PYTHON, PYTEST_ARGS, args)) def coverage(): """Run coverage tests.""" # Note: coverage options are controlled by .coveragerc file build() - sh("%s -m coverage run %s" % (PYTHON, RUNNER_PY)) + sh("%s -m coverage run -m pytest %s" % (PYTHON, PYTEST_ARGS)) sh("%s -m coverage report" % PYTHON) sh("%s -m coverage html" % PYTHON) sh("%s -m webbrowser -t htmlcov/index.html" % PYTHON) @@ -448,13 +451,13 @@ def test_testutils(): def test_by_name(name): """Run test by name.""" build() - sh("%s -m unittest -v %s" % (PYTHON, name)) + test(name) def test_last_failed(): """Re-run tests which failed on last run.""" build() - sh("%s %s --last-failed" % (PYTHON, RUNNER_PY)) + test("--last-failed") def test_memleaks(): From c3c5b09259e3a91a34f9663ef9e7addb0b19bcfa Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 22 Jun 2024 01:29:40 +0200 Subject: [PATCH 03/77] get rid of runner invocation from individual test files --- psutil/tests/test_aix.py | 6 ------ psutil/tests/test_bsd.py | 6 ------ psutil/tests/test_connections.py | 6 ------ psutil/tests/test_contracts.py | 6 ------ psutil/tests/test_linux.py | 6 ------ psutil/tests/test_memleaks.py | 12 ------------ psutil/tests/test_misc.py | 6 ------ psutil/tests/test_osx.py | 6 ------ psutil/tests/test_posix.py | 6 ------ psutil/tests/test_process.py | 6 ------ psutil/tests/test_process_all.py | 6 ------ psutil/tests/test_sunos.py | 6 ------ psutil/tests/test_system.py | 6 ------ psutil/tests/test_testutils.py | 6 ------ psutil/tests/test_unicode.py | 6 ------ psutil/tests/test_windows.py | 6 ------ 16 files changed, 102 deletions(-) diff --git a/psutil/tests/test_aix.py b/psutil/tests/test_aix.py index e7e0c8aa5..8e6121570 100755 --- a/psutil/tests/test_aix.py +++ b/psutil/tests/test_aix.py @@ -129,9 +129,3 @@ def test_net_if_addrs_names(self): ifconfig_names = set(out.split()) psutil_names = set(psutil.net_if_addrs().keys()) self.assertSetEqual(ifconfig_names, psutil_names) - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_bsd.py b/psutil/tests/test_bsd.py index 8512b4f9e..6112c11e1 100755 --- a/psutil/tests/test_bsd.py +++ b/psutil/tests/test_bsd.py @@ -624,9 +624,3 @@ def test_cpu_stats_ctx_switches(self): self.assertAlmostEqual( psutil.cpu_stats().ctx_switches, ctx_switches, delta=1000 ) - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_connections.py b/psutil/tests/test_connections.py index 4a0674d62..ee0cf2a2c 100755 --- a/psutil/tests/test_connections.py +++ b/psutil/tests/test_connections.py @@ -568,9 +568,3 @@ def test_net_connection_constants(self): psutil.CONN_BOUND # noqa if WINDOWS: psutil.CONN_DELETE_TCB # noqa - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py index a5469ac8a..9154c5c70 100755 --- a/psutil/tests/test_contracts.py +++ b/psutil/tests/test_contracts.py @@ -341,9 +341,3 @@ def test_negative_signal(self): self.assertIsInstance(code, enum.IntEnum) else: self.assertIsInstance(code, int) - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index d8faac968..9b1a134ff 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -2353,9 +2353,3 @@ def test_readlink(self): with mock.patch("os.readlink", return_value="foo (deleted)") as m: self.assertEqual(psutil._psplatform.readlink("bar"), "foo") assert m.called - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_memleaks.py b/psutil/tests/test_memleaks.py index 6506497c9..8ef108e1a 100755 --- a/psutil/tests/test_memleaks.py +++ b/psutil/tests/test_memleaks.py @@ -19,7 +19,6 @@ import functools import os import platform -import sys import unittest import psutil @@ -492,14 +491,3 @@ def test_win_service_get_status(self): def test_win_service_get_description(self): name = next(psutil.win_service_iter()).name() self.execute(lambda: cext.winservice_query_descr(name)) - - -if __name__ == '__main__': - from psutil.tests.runner import cprint - from psutil.tests.runner import run_from_name - - if QEMU_USER: - cprint("skipping %s tests under QEMU_USER" % __file__, "brown") - sys.exit(0) - - run_from_name(__file__) diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py index 5c05d1764..66d28b220 100755 --- a/psutil/tests/test_misc.py +++ b/psutil/tests/test_misc.py @@ -1069,9 +1069,3 @@ def test_battery(self): @unittest.skipIf(not HAS_BATTERY, "no battery") def test_sensors(self): self.assert_stdout('sensors.py') - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_osx.py b/psutil/tests/test_osx.py index 1fe02d3e4..a45b3853d 100755 --- a/psutil/tests/test_osx.py +++ b/psutil/tests/test_osx.py @@ -204,9 +204,3 @@ def test_sensors_battery(self): psutil_result = psutil.sensors_battery() self.assertEqual(psutil_result.power_plugged, power_plugged) self.assertEqual(psutil_result.percent, int(percent)) - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_posix.py b/psutil/tests/test_posix.py index 941f0fac1..a19b09ac3 100755 --- a/psutil/tests/test_posix.py +++ b/psutil/tests/test_posix.py @@ -490,9 +490,3 @@ def test_getpagesize(self): self.assertGreater(pagesize, 0) self.assertEqual(pagesize, resource.getpagesize()) self.assertEqual(pagesize, mmap.PAGESIZE) - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index 363474c78..86d19176a 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -1706,9 +1706,3 @@ def test_kill_terminate(self): proc.send_signal, signal.CTRL_BREAK_EVENT, ) - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_process_all.py b/psutil/tests/test_process_all.py index 48833a105..e00f9aec7 100755 --- a/psutil/tests/test_process_all.py +++ b/psutil/tests/test_process_all.py @@ -541,9 +541,3 @@ def check(pid): continue with self.subTest(pid=pid): check(pid) - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_sunos.py b/psutil/tests/test_sunos.py index 548352281..d7505f808 100755 --- a/psutil/tests/test_sunos.py +++ b/psutil/tests/test_sunos.py @@ -37,9 +37,3 @@ def test_swap_memory(self): def test_cpu_count(self): out = sh("/usr/sbin/psrinfo") self.assertEqual(psutil.cpu_count(), len(out.split('\n'))) - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py index e228f6d32..c6854699a 100755 --- a/psutil/tests/test_system.py +++ b/psutil/tests/test_system.py @@ -980,9 +980,3 @@ def test_sensors_fans(self): self.assertIsInstance(entry.label, str) self.assertIsInstance(entry.current, (int, long)) self.assertGreaterEqual(entry.current, 0) - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_testutils.py b/psutil/tests/test_testutils.py index ef98a3abe..d29d6e66a 100755 --- a/psutil/tests/test_testutils.py +++ b/psutil/tests/test_testutils.py @@ -452,9 +452,3 @@ class TestOtherUtils(PsutilTestCase): def test_is_namedtuple(self): assert is_namedtuple(collections.namedtuple('foo', 'a b c')(1, 2, 3)) assert not is_namedtuple(tuple()) - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_unicode.py b/psutil/tests/test_unicode.py index 45aeb4e92..6f73af2c6 100755 --- a/psutil/tests/test_unicode.py +++ b/psutil/tests/test_unicode.py @@ -368,9 +368,3 @@ def test_proc_environ(self): self.assertIsInstance(k, str) self.assertIsInstance(v, str) self.assertEqual(env['FUNNY_ARG'], self.funky_suffix) - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) diff --git a/psutil/tests/test_windows.py b/psutil/tests/test_windows.py index 7778cf4a6..592705f95 100755 --- a/psutil/tests/test_windows.py +++ b/psutil/tests/test_windows.py @@ -959,9 +959,3 @@ def test_win_service_get(self): self.assertIn(service.display_name(), str(service)) self.assertIn(service.name(), repr(service)) self.assertIn(service.display_name(), repr(service)) - - -if __name__ == '__main__': - from psutil.tests.runner import run_from_name - - run_from_name(__file__) From 1ac4efa3ee3e221c2c9f7369f3c96d37596e421e Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 22 Jun 2024 01:36:18 +0200 Subject: [PATCH 04/77] use pytest in the Makefile --- Makefile | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index f64ce06fe..f41887f18 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,14 @@ # Configurable. PYTHON = python3 PYTHON_ENV_VARS = PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 +PYTEST_ARGS = -v --tb=native -o cache_dir=/tmp/psutil-pytest-cache ARGS = -# Internal. +# mandatory deps for running tests PY3_DEPS = \ + pytest +# dev deps. +PY3_DEPS += \ black \ check-manifest \ coverage \ @@ -16,6 +20,7 @@ PY3_DEPS = \ pylint \ pyperf \ pypinfo \ + pytest-cov \ requests \ rstcheck \ ruff \ @@ -29,7 +34,8 @@ PY3_DEPS = \ PY2_DEPS = \ futures \ ipaddress \ - mock + mock \ + pytest PY_DEPS = `$(PYTHON) -c \ "import sys; \ py3 = sys.version_info[0] == 3; \ @@ -130,65 +136,65 @@ setup-dev-env: ## Install GIT hooks, pip, test deps (also upgrades them). test: ## Run all tests. To run a specific test do "make test ARGS=psutil.tests.test_system.TestDiskAPIs" ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) test-parallel: ## Run all tests in parallel. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) --parallel + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) --parallel test-process: ## Run process-related API tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_process.py + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) psutil/tests/test_process.py test-process-all: ## Run tests which iterate over all process PIDs. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_process_all.py + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) psutil/tests/test_process_all.py test-system: ## Run system-related API tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_system.py + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) psutil/tests/test_system.py test-misc: ## Run miscellaneous tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_misc.py + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) psutil/tests/test_misc.py test-testutils: ## Run test utils tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_testutils.py + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) psutil/tests/test_testutils.py test-unicode: ## Test APIs dealing with strings. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_unicode.py + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) psutil/tests/test_unicode.py test-contracts: ## APIs sanity tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_contracts.py + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) psutil/tests/test_contracts.py test-connections: ## Test psutil.net_connections() and Process.net_connections(). ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_connections.py + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) psutil/tests/test_connections.py test-posix: ## POSIX specific tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_posix.py + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) psutil/tests/test_posix.py test-platform: ## Run specific platform tests only. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "OSX", "SUNOS", "WINDOWS", "AIX") if getattr(psutil, x)][0])'`.py + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) psutil/tests/test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "OSX", "SUNOS", "WINDOWS", "AIX") if getattr(psutil, x)][0])'`.py test-memleaks: ## Memory leak tests. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) psutil/tests/test_memleaks.py + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) psutil/tests/test_memleaks.py test-last-failed: ## Re-run tests which failed on last run ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) $(ARGS) --last-failed + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) --last-failed $(ARGS) test-coverage: ## Run test coverage. ${MAKE} build # Note: coverage options are controlled by .coveragerc file rm -rf .coverage htmlcov - $(PYTHON_ENV_VARS) $(PYTHON) -m coverage run -m unittest -v + $(PYTHON_ENV_VARS) $(PYTHON) -m coverage run -m pytest $(PYTEST_ARGS) $(ARGS) $(PYTHON) -m coverage report @echo "writing results to htmlcov/index.html" $(PYTHON) -m coverage html From 49cf6bdd15c44247027ae4aa6f491cc8fadc702b Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 22 Jun 2024 01:53:27 +0200 Subject: [PATCH 05/77] fix test --- Makefile | 2 +- psutil/tests/__init__.py | 2 +- psutil/tests/test_process.py | 1 + psutil/tests/test_testutils.py | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f41887f18..4d1a15323 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ # Configurable. PYTHON = python3 PYTHON_ENV_VARS = PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 -PYTEST_ARGS = -v --tb=native -o cache_dir=/tmp/psutil-pytest-cache +PYTEST_ARGS = -v --tb=native -s -o cache_dir=/tmp/psutil-pytest-cache ARGS = # mandatory deps for running tests diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index dccb9e4b2..6bcb8f092 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -521,7 +521,7 @@ def sh(cmd, **kwds): else: stdout, stderr = p.communicate() if p.returncode != 0: - raise RuntimeError(stderr) + raise RuntimeError(stdout + stderr) if stderr: warn(stderr) if stdout.endswith('\n'): diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index 86d19176a..db34b96bf 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -312,6 +312,7 @@ def test_create_time(self): def test_terminal(self): terminal = psutil.Process().terminal() if terminal is not None: + # Note: this will fail unless pytest is run with `-s` opt tty = os.path.realpath(sh('tty')) self.assertEqual(terminal, tty) diff --git a/psutil/tests/test_testutils.py b/psutil/tests/test_testutils.py index d29d6e66a..80ca405b9 100755 --- a/psutil/tests/test_testutils.py +++ b/psutil/tests/test_testutils.py @@ -389,9 +389,9 @@ def fun(ls=ls): ls.append("x" * 124 * 1024) try: - # will consume around 30M in total + # will consume around 60M in total self.assertRaisesRegex( - AssertionError, "extra-mem", self.execute, fun, times=50 + AssertionError, "extra-mem", self.execute, fun, times=100 ) finally: del ls From 20f587d00613f1b8a7d5e4a67a2b3e9dfb9bbe2c Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 22 Jun 2024 02:18:12 +0200 Subject: [PATCH 06/77] adjust test --- psutil/tests/test_process.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index db34b96bf..d396a7870 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -312,9 +312,13 @@ def test_create_time(self): def test_terminal(self): terminal = psutil.Process().terminal() if terminal is not None: - # Note: this will fail unless pytest is run with `-s` opt - tty = os.path.realpath(sh('tty')) - self.assertEqual(terminal, tty) + try: + tty = os.path.realpath(sh('tty')) + except RuntimeError: + # Note: happens if pytest is run without the `-s` opt. + raise unittest.SkipTest("can't rely on `tty` CLI") + else: + self.assertEqual(terminal, tty) @unittest.skipIf(not HAS_PROC_IO_COUNTERS, 'not supported') @skip_on_not_implemented(only_if=LINUX) From 8a3f12171f1c34e30f57ef6ececf0fe86965e735 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 22 Jun 2024 02:43:29 +0200 Subject: [PATCH 07/77] pytest parallel --- Makefile | 4 +++- psutil/tests/test_connections.py | 9 +++++---- psutil/tests/test_linux.py | 10 +++++++--- psutil/tests/test_process.py | 3 +++ psutil/tests/test_process_all.py | 2 -- psutil/tests/test_testutils.py | 5 +++-- psutil/tests/test_unicode.py | 5 +++-- 7 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 4d1a15323..491aae4a0 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ PY3_DEPS += \ pyperf \ pypinfo \ pytest-cov \ + pytest-xdist \ requests \ rstcheck \ ruff \ @@ -140,7 +141,8 @@ test: ## Run all tests. To run a specific test do "make test ARGS=psutil.tests. test-parallel: ## Run all tests in parallel. ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) --parallel + # note: -s and -v opts are ignored + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) -n auto --dist loadgroup $(ARGS) test-process: ## Run process-related API tests. ${MAKE} build diff --git a/psutil/tests/test_connections.py b/psutil/tests/test_connections.py index ee0cf2a2c..1aa970e57 100755 --- a/psutil/tests/test_connections.py +++ b/psutil/tests/test_connections.py @@ -16,6 +16,8 @@ from socket import SOCK_DGRAM from socket import SOCK_STREAM +import pytest + import psutil from psutil import FREEBSD from psutil import LINUX @@ -38,7 +40,6 @@ from psutil.tests import filter_proc_net_connections from psutil.tests import reap_children from psutil.tests import retry_on_failure -from psutil.tests import serialrun from psutil.tests import skip_on_access_denied from psutil.tests import tcp_socketpair from psutil.tests import unix_socketpair @@ -55,7 +56,7 @@ def this_proc_net_connections(kind): return cons -@serialrun +@pytest.mark.xdist_group(name="group_serial") class ConnectionTestCase(PsutilTestCase): def setUp(self): self.assertEqual(this_proc_net_connections(kind='all'), []) @@ -102,7 +103,7 @@ def test_invalid_kind(self): self.assertRaises(ValueError, psutil.net_connections, kind='???') -@serialrun +@pytest.mark.xdist_group(name="group_serial") class TestUnconnectedSockets(ConnectionTestCase): """Tests sockets which are open but not connected to anything.""" @@ -198,7 +199,7 @@ def test_unix_udp(self): self.assertEqual(conn.status, psutil.CONN_NONE) -@serialrun +@pytest.mark.xdist_group(name="group_serial") class TestConnectedSocket(ConnectionTestCase): """Test socket pairs which are actually connected to each other. diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index 9b1a134ff..c26ad279d 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -2126,9 +2126,13 @@ def test_exe_mocked(self): with mock.patch( 'psutil._pslinux.readlink', side_effect=OSError(errno.ENOENT, "") ) as m: - ret = psutil.Process().exe() - assert m.called - self.assertEqual(ret, "") + # de-activate guessing from cmdline() + with mock.patch( + 'psutil._pslinux.Process.cmdline', return_value=[] + ): + ret = psutil.Process().exe() + assert m.called + self.assertEqual(ret, "") def test_issue_1014(self): # Emulates a case where smaps file does not exist. In this case diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index d396a7870..1009e7bea 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -21,6 +21,8 @@ import types import unittest +import pytest + import psutil from psutil import AIX from psutil import BSD @@ -309,6 +311,7 @@ def test_create_time(self): time.strftime("%Y %m %d %H:%M:%S", time.localtime(p.create_time())) @unittest.skipIf(not POSIX, 'POSIX only') + @pytest.mark.xdist_group(name="group_serial") def test_terminal(self): terminal = psutil.Process().terminal() if terminal is not None: diff --git a/psutil/tests/test_process_all.py b/psutil/tests/test_process_all.py index e00f9aec7..7c0c771d0 100755 --- a/psutil/tests/test_process_all.py +++ b/psutil/tests/test_process_all.py @@ -40,7 +40,6 @@ from psutil.tests import is_namedtuple from psutil.tests import is_win_secure_system_proc from psutil.tests import process_namespace -from psutil.tests import serialrun # Cuts the time in half, but (e.g.) on macOS the process pool stays @@ -97,7 +96,6 @@ def do_wait(): return info -@serialrun class TestFetchAllProcesses(PsutilTestCase): """Test which iterates over all running processes and performs some sanity checks against Process API's returned values. diff --git a/psutil/tests/test_testutils.py b/psutil/tests/test_testutils.py index 80ca405b9..5f7e5c97d 100755 --- a/psutil/tests/test_testutils.py +++ b/psutil/tests/test_testutils.py @@ -16,6 +16,8 @@ import subprocess import unittest +import pytest + import psutil import psutil.tests from psutil import FREEBSD @@ -46,7 +48,6 @@ from psutil.tests import retry_on_failure from psutil.tests import safe_mkdir from psutil.tests import safe_rmpath -from psutil.tests import serialrun from psutil.tests import system_namespace from psutil.tests import tcp_socketpair from psutil.tests import terminate @@ -361,7 +362,7 @@ def test_create_sockets(self): self.assertGreaterEqual(types[socket.SOCK_DGRAM], 2) -@serialrun +@pytest.mark.xdist_group(name="group_serial") class TestMemLeakClass(TestMemoryLeak): @retry_on_failure() def test_times(self): diff --git a/psutil/tests/test_unicode.py b/psutil/tests/test_unicode.py index 6f73af2c6..4fb62dcbd 100755 --- a/psutil/tests/test_unicode.py +++ b/psutil/tests/test_unicode.py @@ -79,6 +79,8 @@ import warnings from contextlib import closing +import pytest + import psutil from psutil import BSD from psutil import POSIX @@ -103,7 +105,6 @@ from psutil.tests import get_testfn from psutil.tests import safe_mkdir from psutil.tests import safe_rmpath -from psutil.tests import serialrun from psutil.tests import skip_on_access_denied from psutil.tests import spawn_testproc from psutil.tests import terminate @@ -178,7 +179,7 @@ def setUp(self): raise unittest.SkipTest("can't handle unicode str") -@serialrun +@pytest.mark.xdist_group(name="group_serial") @unittest.skipIf(ASCII_FS, "ASCII fs") @unittest.skipIf(PYPY and not PY3, "too much trouble on PYPY2") class TestFSAPIs(BaseUnicodeTest): From 704922718c0dc727b61c86d7239f15514ba0fc62 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 22 Jun 2024 02:47:10 +0200 Subject: [PATCH 08/77] expose PYTEST_PARALLEL test constant --- psutil/tests/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 6bcb8f092..97e7a215b 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -87,7 +87,7 @@ "HAS_IONICE", "HAS_MEMORY_MAPS", "HAS_PROC_CPU_NUM", "HAS_RLIMIT", "HAS_SENSORS_BATTERY", "HAS_BATTERY", "HAS_SENSORS_FANS", "HAS_SENSORS_TEMPERATURES", "HAS_NET_CONNECTIONS_UNIX", "MACOS_11PLUS", - "MACOS_12PLUS", "COVERAGE", 'AARCH64', "QEMU_USER", + "MACOS_12PLUS", "COVERAGE", 'AARCH64', "QEMU_USER", "PYTEST_PARALLEL", # subprocesses 'pyrun', 'terminate', 'reap_children', 'spawn_testproc', 'spawn_zombie', 'spawn_children_pair', @@ -128,6 +128,7 @@ GITHUB_ACTIONS = 'GITHUB_ACTIONS' in os.environ or 'CIBUILDWHEEL' in os.environ CI_TESTING = APPVEYOR or GITHUB_ACTIONS COVERAGE = 'COVERAGE_RUN' in os.environ +PYTEST_PARALLEL = "PYTEST_XDIST_WORKER" in os.environ # `make test-parallel` if LINUX and GITHUB_ACTIONS: with open('/proc/1/cmdline') as f: QEMU_USER = "/bin/qemu-" in f.read() From 66de9199eefa51a055bddd5eb6b76aa5f2ebe664 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 22 Jun 2024 02:51:47 +0200 Subject: [PATCH 09/77] skip test in parallel mode --- psutil/tests/test_linux.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index c26ad279d..ef27d4f51 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -36,6 +36,7 @@ from psutil.tests import HAS_GETLOADAVG from psutil.tests import HAS_RLIMIT from psutil.tests import PYPY +from psutil.tests import PYTEST_PARALLEL from psutil.tests import QEMU_USER from psutil.tests import TOLERANCE_DISK_USAGE from psutil.tests import TOLERANCE_SYS_MEM @@ -1603,6 +1604,7 @@ def test_procfs_path(self): psutil.PROCFS_PATH = "/proc" @retry_on_failure() + @unittest.skipIf(PYTEST_PARALLEL, "skip if pytest-parallel") def test_issue_687(self): # In case of thread ID: # - pid_exists() is supposed to return False From 58d42438ad97550d22af56f430f2553b47d4cd32 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 22 Jun 2024 03:01:17 +0200 Subject: [PATCH 10/77] rm @serialrun deco --- psutil/tests/__init__.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 97e7a215b..83d00f708 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -14,7 +14,6 @@ import errno import functools import gc -import inspect import os import platform import random @@ -1599,16 +1598,6 @@ def iter(ls): test_class_coverage = process_namespace.test_class_coverage -def serialrun(klass): - """A decorator to mark a TestCase class. When running parallel tests, - class' unit tests will be run serially (1 process). - """ - # assert issubclass(klass, unittest.TestCase), klass - assert inspect.isclass(klass), klass - klass._serialrun = True - return klass - - def retry_on_failure(retries=NO_RETRIES): """Decorator which runs a test function and retries N times before actually failing. From 9a2754293fb1500ae4369f494ec1823d3d6b297a Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 22 Jun 2024 03:09:56 +0200 Subject: [PATCH 11/77] small var rename --- Makefile | 2 +- psutil/tests/test_connections.py | 6 +++--- psutil/tests/test_process.py | 3 --- psutil/tests/test_testutils.py | 2 +- psutil/tests/test_unicode.py | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 491aae4a0..29a210b04 100644 --- a/Makefile +++ b/Makefile @@ -141,7 +141,7 @@ test: ## Run all tests. To run a specific test do "make test ARGS=psutil.tests. test-parallel: ## Run all tests in parallel. ${MAKE} build - # note: -s and -v opts are ignored + # Note: when running in parallel pytest's `-s` and `-v` opts are ignored $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) -n auto --dist loadgroup $(ARGS) test-process: ## Run process-related API tests. diff --git a/psutil/tests/test_connections.py b/psutil/tests/test_connections.py index 1aa970e57..e1a24563d 100755 --- a/psutil/tests/test_connections.py +++ b/psutil/tests/test_connections.py @@ -56,7 +56,7 @@ def this_proc_net_connections(kind): return cons -@pytest.mark.xdist_group(name="group_serial") +@pytest.mark.xdist_group(name="serial") class ConnectionTestCase(PsutilTestCase): def setUp(self): self.assertEqual(this_proc_net_connections(kind='all'), []) @@ -103,7 +103,7 @@ def test_invalid_kind(self): self.assertRaises(ValueError, psutil.net_connections, kind='???') -@pytest.mark.xdist_group(name="group_serial") +@pytest.mark.xdist_group(name="serial") class TestUnconnectedSockets(ConnectionTestCase): """Tests sockets which are open but not connected to anything.""" @@ -199,7 +199,7 @@ def test_unix_udp(self): self.assertEqual(conn.status, psutil.CONN_NONE) -@pytest.mark.xdist_group(name="group_serial") +@pytest.mark.xdist_group(name="serial") class TestConnectedSocket(ConnectionTestCase): """Test socket pairs which are actually connected to each other. diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index 1009e7bea..d396a7870 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -21,8 +21,6 @@ import types import unittest -import pytest - import psutil from psutil import AIX from psutil import BSD @@ -311,7 +309,6 @@ def test_create_time(self): time.strftime("%Y %m %d %H:%M:%S", time.localtime(p.create_time())) @unittest.skipIf(not POSIX, 'POSIX only') - @pytest.mark.xdist_group(name="group_serial") def test_terminal(self): terminal = psutil.Process().terminal() if terminal is not None: diff --git a/psutil/tests/test_testutils.py b/psutil/tests/test_testutils.py index 5f7e5c97d..f7ce52dd6 100755 --- a/psutil/tests/test_testutils.py +++ b/psutil/tests/test_testutils.py @@ -362,7 +362,7 @@ def test_create_sockets(self): self.assertGreaterEqual(types[socket.SOCK_DGRAM], 2) -@pytest.mark.xdist_group(name="group_serial") +@pytest.mark.xdist_group(name="serial") class TestMemLeakClass(TestMemoryLeak): @retry_on_failure() def test_times(self): diff --git a/psutil/tests/test_unicode.py b/psutil/tests/test_unicode.py index 4fb62dcbd..af32b56d1 100755 --- a/psutil/tests/test_unicode.py +++ b/psutil/tests/test_unicode.py @@ -179,7 +179,7 @@ def setUp(self): raise unittest.SkipTest("can't handle unicode str") -@pytest.mark.xdist_group(name="group_serial") +@pytest.mark.xdist_group(name="serial") @unittest.skipIf(ASCII_FS, "ASCII fs") @unittest.skipIf(PYPY and not PY3, "too much trouble on PYPY2") class TestFSAPIs(BaseUnicodeTest): From c1d0ea49a191d5d67f0d65aaf61f2a6c929973ca Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 22 Jun 2024 11:46:08 +0200 Subject: [PATCH 12/77] avoid installing unneded deps on GHA Signed-off-by: Giampaolo Rodola --- Makefile | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 29a210b04..62d029c7a 100644 --- a/Makefile +++ b/Makefile @@ -12,26 +12,29 @@ ARGS = PY3_DEPS = \ pytest # dev deps. -PY3_DEPS += \ - black \ - check-manifest \ - coverage \ - packaging \ - pylint \ - pyperf \ - pypinfo \ - pytest-cov \ - pytest-xdist \ - requests \ - rstcheck \ - ruff \ - setuptools \ - sphinx_rtd_theme \ - teyit \ - toml-sort \ - twine \ - virtualenv \ - wheel +ifndef GITHUB_ACTIONS + PY3_DEPS += \ + black \ + check-manifest \ + coverage \ + packaging \ + pylint \ + pyperf \ + pypinfo \ + pytest-cov \ + pytest-xdist \ + requests \ + rstcheck \ + ruff \ + setuptools \ + sphinx_rtd_theme \ + teyit \ + toml-sort \ + twine \ + virtualenv \ + wheel +endif +# python 2 deps PY2_DEPS = \ futures \ ipaddress \ @@ -43,6 +46,7 @@ PY_DEPS = `$(PYTHON) -c \ py38 = sys.version_info[:2] >= (3, 8); \ py3_extra = ' abi3audit' if py38 else ''; \ print('$(PY3_DEPS)' + py3_extra if py3 else '$(PY2_DEPS)')"` + NUM_WORKERS = `$(PYTHON) -c "import os; print(os.cpu_count() or 1)"` # "python3 setup.py build" can be parallelized on Python >= 3.6. BUILD_OPTS = `$(PYTHON) -c \ From 13be4f35e00780f1f9f37f63e2e913da078cb821 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sun, 23 Jun 2024 12:09:58 +0200 Subject: [PATCH 13/77] attempt 3 --- .github/workflows/build.yml | 3 ++- Makefile | 9 ++++----- pyproject.toml | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c52680f1..2c2eef867 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,7 +82,8 @@ jobs: os: [ubuntu-latest, macos-12] env: CIBW_TEST_COMMAND: - make test && make test-memleaks + PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=native -v -s {project}/psutil/tests/runner.py && + PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=native -v -s {project}/psutil/tests/test_memleaks.py CIBW_TEST_EXTRAS: test CIBW_BUILD: 'cp27-*' diff --git a/Makefile b/Makefile index 62d029c7a..2354a3a53 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ # Configurable. PYTHON = python3 PYTHON_ENV_VARS = PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 -PYTEST_ARGS = -v --tb=native -s -o cache_dir=/tmp/psutil-pytest-cache +PYTEST_ARGS = --tb=native -v -s ARGS = # mandatory deps for running tests @@ -141,12 +141,11 @@ setup-dev-env: ## Install GIT hooks, pip, test deps (also upgrades them). test: ## Run all tests. To run a specific test do "make test ARGS=psutil.tests.test_system.TestDiskAPIs" ${MAKE} build - $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) $(ARGS) + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) --ignore=psutil/tests/test_memleaks.py $(ARGS) test-parallel: ## Run all tests in parallel. ${MAKE} build - # Note: when running in parallel pytest's `-s` and `-v` opts are ignored - $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) -n auto --dist loadgroup $(ARGS) + $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(PYTEST_ARGS) --ignore=psutil/tests/test_memleaks.py -n auto --dist loadgroup $(ARGS) test-process: ## Run process-related API tests. ${MAKE} build @@ -200,7 +199,7 @@ test-coverage: ## Run test coverage. ${MAKE} build # Note: coverage options are controlled by .coveragerc file rm -rf .coverage htmlcov - $(PYTHON_ENV_VARS) $(PYTHON) -m coverage run -m pytest $(PYTEST_ARGS) $(ARGS) + $(PYTHON_ENV_VARS) $(PYTHON) -m coverage run -m pytest $(PYTEST_ARGS) --ignore=psutil/tests/test_memleaks.py $(ARGS) $(PYTHON) -m coverage report @echo "writing results to htmlcov/index.html" $(PYTHON) -m coverage html diff --git a/pyproject.toml b/pyproject.toml index 77bbc6ed3..084366a11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -210,8 +210,8 @@ skip = [ "pp*", ] test-command = [ - "make test", - "make test-memleaks", + "env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=native -v -s --ignore=psutil/tests/test_memleaks.py {project}/psutil/tests", + "env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python {project}/psutil/tests/test_memleaks.py", ] test-extras = "test" From 045463a763b33b95a333c6458784e80069c3090e Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sun, 23 Jun 2024 12:16:00 +0200 Subject: [PATCH 14/77] attempt 4 --- .github/workflows/build.yml | 160 ++++++++++++++++++------------------ pyproject.toml | 3 +- 2 files changed, 81 insertions(+), 82 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c2eef867..9222c0162 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ concurrency: jobs: # Linux + macOS + Windows Python 3 py3: - name: "py3-${{ matrix.os }}-${{ matrix.arch }}" + name: "py3, ${{ matrix.os }}, ${{ matrix.arch }}" runs-on: ${{ matrix.os }} timeout-minutes: 30 strategy: @@ -26,12 +26,12 @@ jobs: matrix: include: - {os: ubuntu-latest, arch: x86_64} - - {os: ubuntu-latest, arch: i686} - - {os: ubuntu-latest, arch: aarch64} - - {os: macos-12, arch: x86_64} - - {os: macos-14, arch: arm64} - - {os: windows-2019, arch: AMD64} - - {os: windows-2019, arch: x86} + # - {os: ubuntu-latest, arch: i686} + # - {os: ubuntu-latest, arch: aarch64} + # - {os: macos-12, arch: x86_64} + # - {os: macos-14, arch: arm64} + # - {os: windows-2019, arch: AMD64} + # - {os: windows-2019, arch: x86} steps: - uses: actions/checkout@v4 @@ -71,83 +71,83 @@ jobs: python setup.py sdist mv dist/psutil*.tar.gz wheelhouse/ - # Linux + macOS + Python 2 - py2: - name: py2-${{ matrix.os }} - runs-on: ${{ matrix.os }} - timeout-minutes: 20 - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-12] - env: - CIBW_TEST_COMMAND: - PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=native -v -s {project}/psutil/tests/runner.py && - PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=native -v -s {project}/psutil/tests/test_memleaks.py - CIBW_TEST_EXTRAS: test - CIBW_BUILD: 'cp27-*' + # # Linux + macOS + Python 2 + # py2: + # name: py2, ${{ matrix.os }} + # runs-on: ${{ matrix.os }} + # timeout-minutes: 20 + # strategy: + # fail-fast: false + # matrix: + # os: [ubuntu-latest, macos-12] + # env: + # CIBW_TEST_COMMAND: + # PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=native -v -s {project}/psutil/tests/runner.py && + # PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=native -v -s {project}/psutil/tests/test_memleaks.py + # CIBW_TEST_EXTRAS: test + # CIBW_BUILD: 'cp27-*' - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.9 + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-python@v5 + # with: + # python-version: 3.9 - - name: Create wheels + run tests - uses: pypa/cibuildwheel@v1.12.0 + # - name: Create wheels + run tests + # uses: pypa/cibuildwheel@v1.12.0 - - name: Upload wheels - uses: actions/upload-artifact@v4 - with: - name: wheels-py2-${{ matrix.os }} - path: wheelhouse + # - name: Upload wheels + # uses: actions/upload-artifact@v4 + # with: + # name: wheels-py2-${{ matrix.os }} + # path: wheelhouse - - name: Generate .tar.gz - if: matrix.os == 'ubuntu-latest' - run: | - make generate-manifest - python setup.py sdist - mv dist/psutil*.tar.gz wheelhouse/ + # - name: Generate .tar.gz + # if: matrix.os == 'ubuntu-latest' + # run: | + # make generate-manifest + # python setup.py sdist + # mv dist/psutil*.tar.gz wheelhouse/ - # Run linters - linters: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - name: 'Run linters' - run: | - python3 -m pip install ruff black rstcheck toml-sort sphinx - make lint-all + # # Run linters + # linters: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-python@v5 + # with: + # python-version: 3.x + # - name: 'Run linters' + # run: | + # python3 -m pip install ruff black rstcheck toml-sort sphinx + # make lint-all - # upload weels as a single artefact - upload-wheels: - needs: [py2, py3] - runs-on: ubuntu-latest - steps: - - uses: actions/upload-artifact/merge@v4 - with: - name: wheels - pattern: wheels-* - separate-directories: false - delete-merged: true + # # upload weels as a single artefact + # upload-wheels: + # needs: [py2, py3] + # runs-on: ubuntu-latest + # steps: + # - uses: actions/upload-artifact/merge@v4 + # with: + # name: wheels + # pattern: wheels-* + # separate-directories: false + # delete-merged: true - # Check sanity of .tar.gz + wheel files - check-dist: - needs: [upload-wheels] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - uses: actions/download-artifact@v4 - with: - name: wheels - path: wheelhouse - - run: | - python scripts/internal/print_hashes.py wheelhouse/ - pipx run twine check --strict wheelhouse/* - pipx run abi3audit --verbose --strict wheelhouse/*-abi3-*.whl + # # Check sanity of .tar.gz + wheel files + # check-dist: + # needs: [upload-wheels] + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-python@v5 + # with: + # python-version: 3.x + # - uses: actions/download-artifact@v4 + # with: + # name: wheels + # path: wheelhouse + # - run: | + # python scripts/internal/print_hashes.py wheelhouse/ + # pipx run twine check --strict wheelhouse/* + # pipx run abi3audit --verbose --strict wheelhouse/*-abi3-*.whl diff --git a/pyproject.toml b/pyproject.toml index 084366a11..e72941cbd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -210,8 +210,7 @@ skip = [ "pp*", ] test-command = [ - "env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=native -v -s --ignore=psutil/tests/test_memleaks.py {project}/psutil/tests", - "env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python {project}/psutil/tests/test_memleaks.py", + "env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=native -v -s {project}/psutil/tests", ] test-extras = "test" From c17152d6713fd0e58616e5af03b4aaa8480db0ec Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Wed, 3 Jul 2024 09:40:25 +0200 Subject: [PATCH 15/77] update ruff rules --- psutil/_psaix.py | 2 +- psutil/_psbsd.py | 2 +- psutil/_pslinux.py | 2 +- psutil/_psosx.py | 2 +- psutil/_pssunos.py | 2 +- psutil/_pswindows.py | 2 +- psutil/tests/test_posix.py | 2 +- psutil/tests/test_process.py | 2 +- psutil/tests/test_process_all.py | 2 +- pyproject.toml | 5 +++++ scripts/pidof.py | 6 ++---- 11 files changed, 16 insertions(+), 13 deletions(-) diff --git a/psutil/_psaix.py b/psutil/_psaix.py index f48425eb8..0904449b3 100644 --- a/psutil/_psaix.py +++ b/psutil/_psaix.py @@ -349,7 +349,7 @@ def wrapper(self, *args, **kwargs): class Process: """Wrapper class around underlying C implementation.""" - __slots__ = ["pid", "_name", "_ppid", "_procfs_path", "_cache"] + __slots__ = ["_cache", "_name", "_ppid", "_procfs_path", "pid"] def __init__(self, pid): self.pid = pid diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py index 4d49cf98b..2d5b42acf 100644 --- a/psutil/_psbsd.py +++ b/psutil/_psbsd.py @@ -640,7 +640,7 @@ def wrap_exceptions_procfs(inst): class Process: """Wrapper class around underlying C implementation.""" - __slots__ = ["pid", "_name", "_ppid", "_cache"] + __slots__ = ["_cache", "_name", "_ppid", "pid"] def __init__(self, pid): self.pid = pid diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 167183881..7dfa1430a 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -1732,7 +1732,7 @@ def wrapper(self, *args, **kwargs): class Process: """Linux process implementation.""" - __slots__ = ["pid", "_name", "_ppid", "_procfs_path", "_cache"] + __slots__ = ["_cache", "_name", "_ppid", "_procfs_path", "pid"] def __init__(self, pid): self.pid = pid diff --git a/psutil/_psosx.py b/psutil/_psosx.py index 41263fd73..ed9b319de 100644 --- a/psutil/_psosx.py +++ b/psutil/_psosx.py @@ -361,7 +361,7 @@ def wrapper(self, *args, **kwargs): class Process: """Wrapper class around underlying C implementation.""" - __slots__ = ["pid", "_name", "_ppid", "_cache"] + __slots__ = ["_cache", "_name", "_ppid", "pid"] def __init__(self, pid): self.pid = pid diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py index 1c0b96e9e..5536d3507 100644 --- a/psutil/_pssunos.py +++ b/psutil/_pssunos.py @@ -387,7 +387,7 @@ def wrapper(self, *args, **kwargs): class Process: """Wrapper class around underlying C implementation.""" - __slots__ = ["pid", "_name", "_ppid", "_procfs_path", "_cache"] + __slots__ = ["_cache", "_name", "_ppid", "_procfs_path", "pid"] def __init__(self, pid): self.pid = pid diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py index 0ba511b90..7eb01b7e2 100644 --- a/psutil/_pswindows.py +++ b/psutil/_pswindows.py @@ -762,7 +762,7 @@ def wrapper(self, *args, **kwargs): class Process: """Wrapper class around underlying C implementation.""" - __slots__ = ["pid", "_name", "_ppid", "_cache"] + __slots__ = ["_cache", "_name", "_ppid", "pid"] def __init__(self, pid): self.pid = pid diff --git a/psutil/tests/test_posix.py b/psutil/tests/test_posix.py index 941f0fac1..90fd4eb3c 100755 --- a/psutil/tests/test_posix.py +++ b/psutil/tests/test_posix.py @@ -315,7 +315,7 @@ def test_pids(self): pids_psutil = psutil.pids() # on MACOS and OPENBSD ps doesn't show pid 0 - if MACOS or OPENBSD and 0 not in pids_ps: + if MACOS or (OPENBSD and 0 not in pids_ps): pids_ps.insert(0, 0) # There will often be one more process in pids_ps for ps itself diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index 363474c78..d46e9fbd7 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -618,7 +618,7 @@ def test_memory_full_info(self): for name in mem._fields: value = getattr(mem, name) self.assertGreaterEqual(value, 0, msg=(name, value)) - if name == 'vms' and OSX or LINUX: + if (name == 'vms' and OSX) or LINUX: continue self.assertLessEqual(value, total, msg=(name, value, total)) if LINUX or WINDOWS or MACOS: diff --git a/psutil/tests/test_process_all.py b/psutil/tests/test_process_all.py index 48833a105..7e6369399 100755 --- a/psutil/tests/test_process_all.py +++ b/psutil/tests/test_process_all.py @@ -321,7 +321,7 @@ def memory_full_info(self, ret, info): value = getattr(ret, name) self.assertIsInstance(value, (int, long)) self.assertGreaterEqual(value, 0, msg=(name, value)) - if LINUX or OSX and name in ('vms', 'data'): + if LINUX or (OSX and name in ('vms', 'data')): # On Linux there are processes (e.g. 'goa-daemon') whose # VMS is incredibly high for some reason. continue diff --git a/pyproject.toml b/pyproject.toml index ba13f2829..f1da78a43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,12 @@ select = [ "D301", # Use `r"""` if any backslashes in a docstring "D403", # [*] First word of the first line should be capitalized "PERF102", # [*] When using only the keys of a dict use the `keys()` method + "PLR5501", # [*] Use `elif` instead of `else` then `if`, to reduce indentation + "PLR6104", # Use `+=` to perform an augmented assignment directly + "PLW0602", # Using global for `x` but no assignment is done "RET507", # Unnecessary `elif` after `continue` statement + "RUF021", # [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear + "RUF023", # [*] `Class.__slots__` is not sorted "S113", # Probable use of requests call without timeout "S602", # `subprocess` call with `shell=True` identified, security issue ] diff --git a/scripts/pidof.py b/scripts/pidof.py index 662d5d657..71314963f 100755 --- a/scripts/pidof.py +++ b/scripts/pidof.py @@ -22,10 +22,8 @@ def pidof(pgname): pids = [] for proc in psutil.process_iter(['name', 'cmdline']): # search for matches in the process name and cmdline - if ( - proc.info['name'] == pgname - or proc.info['cmdline'] - and proc.info['cmdline'][0] == pgname + if proc.info['name'] == pgname or ( + proc.info['cmdline'] and proc.info['cmdline'][0] == pgname ): pids.append(str(proc.pid)) return pids From e9a2a11c96a29bd4e36473840c8d2719361fd9dc Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Mon, 8 Jul 2024 00:34:57 +0200 Subject: [PATCH 16/77] use short traceback --- .github/workflows/build.yml | 4 ++-- Makefile | 2 +- pyproject.toml | 2 +- scripts/internal/winmake.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9222c0162..400f3532b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,8 +82,8 @@ jobs: # os: [ubuntu-latest, macos-12] # env: # CIBW_TEST_COMMAND: - # PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=native -v -s {project}/psutil/tests/runner.py && - # PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=native -v -s {project}/psutil/tests/test_memleaks.py + # PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=short -v -s {project}/psutil/tests/runner.py && + # PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=short -v -s {project}/psutil/tests/test_memleaks.py # CIBW_TEST_EXTRAS: test # CIBW_BUILD: 'cp27-*' diff --git a/Makefile b/Makefile index 2354a3a53..5aacd01cc 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ # Configurable. PYTHON = python3 PYTHON_ENV_VARS = PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 -PYTEST_ARGS = --tb=native -v -s +PYTEST_ARGS = -v -s --tb=short ARGS = # mandatory deps for running tests diff --git a/pyproject.toml b/pyproject.toml index c8863c649..8933cc285 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -215,7 +215,7 @@ skip = [ "pp*", ] test-command = [ - "env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=native -v -s {project}/psutil/tests", + "env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests", ] test-extras = "test" diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index 73e9e6bf3..7b6ae411c 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -31,7 +31,7 @@ PYTHON = sys.executable if APPVEYOR else os.getenv('PYTHON', sys.executable) GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py" PY3 = sys.version_info[0] >= 3 -PYTEST_ARGS = "-v --tb=native " +PYTEST_ARGS = "-v -s --tb=short" if PY3: PYTEST_ARGS += "-o " HERE = os.path.abspath(os.path.dirname(__file__)) From 562bc848a08ed0b6d519bfddf7a9d2f480ab3fd2 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Mon, 8 Jul 2024 00:35:54 +0200 Subject: [PATCH 17/77] rm teyit + make fix-unittests target --- Makefile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Makefile b/Makefile index 5aacd01cc..df11627db 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,6 @@ ifndef GITHUB_ACTIONS ruff \ setuptools \ sphinx_rtd_theme \ - teyit \ toml-sort \ twine \ virtualenv \ @@ -244,16 +243,12 @@ fix-black: fix-ruff: @git ls-files '*.py' | xargs $(PYTHON) -m ruff check --no-cache --fix $(ARGS) -fix-unittests: ## Fix unittest idioms. - @git ls-files '*test_*.py' | xargs $(PYTHON) -m teyit --show-stats - fix-toml: ## Fix pyproject.toml @git ls-files '*.toml' | xargs toml-sort fix-all: ## Run all code fixers. ${MAKE} fix-ruff ${MAKE} fix-black - ${MAKE} fix-unittests ${MAKE} fix-toml # =================================================================== From da580b4688842df39fdc0172e6660078ba779d92 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Mon, 8 Jul 2024 19:11:13 +0200 Subject: [PATCH 18/77] disable failing test --- psutil/tests/test_linux.py | 10 ++++++---- psutil/tests/test_process_all.py | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index ef27d4f51..e0c361a04 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -981,10 +981,12 @@ def open_mock(name, *args, **kwargs): @unittest.skipIf(not LINUX, "LINUX only") class TestSystemCPUStats(PsutilTestCase): - def test_ctx_switches(self): - vmstat_value = vmstat("context switches") - psutil_value = psutil.cpu_stats().ctx_switches - self.assertAlmostEqual(vmstat_value, psutil_value, delta=500) + + # XXX: fails too often. + # def test_ctx_switches(self): + # vmstat_value = vmstat("context switches") + # psutil_value = psutil.cpu_stats().ctx_switches + # self.assertAlmostEqual(vmstat_value, psutil_value, delta=500) def test_interrupts(self): vmstat_value = vmstat("interrupts") diff --git a/psutil/tests/test_process_all.py b/psutil/tests/test_process_all.py index c7c23c773..1a55b87ac 100755 --- a/psutil/tests/test_process_all.py +++ b/psutil/tests/test_process_all.py @@ -32,6 +32,7 @@ from psutil._compat import long from psutil._compat import unicode from psutil.tests import CI_TESTING +from psutil.tests import PYTEST_PARALLEL from psutil.tests import QEMU_USER from psutil.tests import VALID_PROC_STATUSES from psutil.tests import PsutilTestCase @@ -44,7 +45,7 @@ # Cuts the time in half, but (e.g.) on macOS the process pool stays # alive after join() (multiprocessing bug?), messing up other tests. -USE_PROC_POOL = LINUX and not CI_TESTING +USE_PROC_POOL = LINUX and not CI_TESTING and not PYTEST_PARALLEL def proc_info(pid): From 57c0ef0dcb6c0dcf859bb042737ad8e7baabf35e Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Fri, 12 Jul 2024 10:11:53 +0200 Subject: [PATCH 19/77] progress --- .github/workflows/build.yml | 146 ++++++++++++++++++------------------ 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 400f3532b..469204537 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,83 +71,83 @@ jobs: python setup.py sdist mv dist/psutil*.tar.gz wheelhouse/ - # # Linux + macOS + Python 2 - # py2: - # name: py2, ${{ matrix.os }} - # runs-on: ${{ matrix.os }} - # timeout-minutes: 20 - # strategy: - # fail-fast: false - # matrix: - # os: [ubuntu-latest, macos-12] - # env: - # CIBW_TEST_COMMAND: - # PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=short -v -s {project}/psutil/tests/runner.py && - # PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=short -v -s {project}/psutil/tests/test_memleaks.py - # CIBW_TEST_EXTRAS: test - # CIBW_BUILD: 'cp27-*' + # Linux + macOS + Python 2 + py2: + name: py2, ${{ matrix.os }} + runs-on: ${{ matrix.os }} + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-12] + env: + CIBW_TEST_COMMAND: + PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=short -v -s {project}/psutil/tests/runner.py && + PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=short -v -s {project}/psutil/tests/test_memleaks.py + CIBW_TEST_EXTRAS: test + CIBW_BUILD: 'cp27-*' - # steps: - # - uses: actions/checkout@v4 - # - uses: actions/setup-python@v5 - # with: - # python-version: 3.9 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.9 - # - name: Create wheels + run tests - # uses: pypa/cibuildwheel@v1.12.0 + - name: Create wheels + run tests + uses: pypa/cibuildwheel@v1.12.0 - # - name: Upload wheels - # uses: actions/upload-artifact@v4 - # with: - # name: wheels-py2-${{ matrix.os }} - # path: wheelhouse + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-py2-${{ matrix.os }} + path: wheelhouse - # - name: Generate .tar.gz - # if: matrix.os == 'ubuntu-latest' - # run: | - # make generate-manifest - # python setup.py sdist - # mv dist/psutil*.tar.gz wheelhouse/ + - name: Generate .tar.gz + if: matrix.os == 'ubuntu-latest' + run: | + make generate-manifest + python setup.py sdist + mv dist/psutil*.tar.gz wheelhouse/ - # # Run linters - # linters: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: actions/setup-python@v5 - # with: - # python-version: 3.x - # - name: 'Run linters' - # run: | - # python3 -m pip install ruff black rstcheck toml-sort sphinx - # make lint-all + # Run linters + linters: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: 'Run linters' + run: | + python3 -m pip install ruff black rstcheck toml-sort sphinx + make lint-all - # # upload weels as a single artefact - # upload-wheels: - # needs: [py2, py3] - # runs-on: ubuntu-latest - # steps: - # - uses: actions/upload-artifact/merge@v4 - # with: - # name: wheels - # pattern: wheels-* - # separate-directories: false - # delete-merged: true + # upload weels as a single artefact + upload-wheels: + needs: [py2, py3] + runs-on: ubuntu-latest + steps: + - uses: actions/upload-artifact/merge@v4 + with: + name: wheels + pattern: wheels-* + separate-directories: false + delete-merged: true - # # Check sanity of .tar.gz + wheel files - # check-dist: - # needs: [upload-wheels] - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: actions/setup-python@v5 - # with: - # python-version: 3.x - # - uses: actions/download-artifact@v4 - # with: - # name: wheels - # path: wheelhouse - # - run: | - # python scripts/internal/print_hashes.py wheelhouse/ - # pipx run twine check --strict wheelhouse/* - # pipx run abi3audit --verbose --strict wheelhouse/*-abi3-*.whl + # Check sanity of .tar.gz + wheel files + check-dist: + needs: [upload-wheels] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - uses: actions/download-artifact@v4 + with: + name: wheels + path: wheelhouse + - run: | + python scripts/internal/print_hashes.py wheelhouse/ + pipx run twine check --strict wheelhouse/* + pipx run abi3audit --verbose --strict wheelhouse/*-abi3-*.whl From 667f1e77cce13d99030695b04692efc66d80570b Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Fri, 12 Jul 2024 10:56:42 +0200 Subject: [PATCH 20/77] fix ruff --- scripts/internal/winmake.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index 7b6ae411c..5b888ae74 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -19,6 +19,7 @@ import errno import fnmatch import os +import shlex import shutil import site import ssl @@ -117,9 +118,9 @@ def win_colorprint(s, color=LIGHTBLUE): def sh(cmd, nolog=False): if not nolog: safe_print("cmd: " + cmd) - p = subprocess.Popen( - cmd, shell=True, env=os.environ, cwd=os.getcwd() # noqa - ) + if isinstance(cmd, str): + cmd = shlex.split(cmd) + p = subprocess.Popen(cmd, env=os.environ, cwd=os.getcwd()) p.communicate() if p.returncode != 0: sys.exit(p.returncode) From 87a599976aee80fdb2f0804b4e4067f431fb896c Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 27 Jul 2024 20:13:26 +0200 Subject: [PATCH 21/77] re-enable CI platforms --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 469204537..8efe85f18 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,12 +26,12 @@ jobs: matrix: include: - {os: ubuntu-latest, arch: x86_64} - # - {os: ubuntu-latest, arch: i686} - # - {os: ubuntu-latest, arch: aarch64} - # - {os: macos-12, arch: x86_64} - # - {os: macos-14, arch: arm64} - # - {os: windows-2019, arch: AMD64} - # - {os: windows-2019, arch: x86} + - {os: ubuntu-latest, arch: i686} + - {os: ubuntu-latest, arch: aarch64} + - {os: macos-12, arch: x86_64} + - {os: macos-14, arch: arm64} + - {os: windows-2019, arch: AMD64} + - {os: windows-2019, arch: x86} steps: - uses: actions/checkout@v4 From 0f450b8ac36d78e13157e04fd56d3ceb817d6187 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 27 Jul 2024 20:21:18 +0200 Subject: [PATCH 22/77] bump up cibuildwheel ver --- .github/workflows/build.yml | 2 +- pyproject.toml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8efe85f18..1e3a9dfd6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,7 +53,7 @@ jobs: if: matrix.arch == 'aarch64' - name: Create wheels + run tests - uses: pypa/cibuildwheel@v2.19.1 + uses: pypa/cibuildwheel@v2.19.2 env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True diff --git a/pyproject.toml b/pyproject.toml index 8933cc285..5f8486042 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,7 @@ ignore = [ "C90", # mccabe (function `X` is too complex) "COM812", # Trailing comma missing "D", # pydocstyle + "DOC501", # Raised exception `X` missing from docstring "DTZ", # flake8-datetimez "ERA001", # Found commented-out code "FBT", # flake8-boolean-trap (makes zero sense) From 07984c1588969143870c34739361b9877da28f1b Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 27 Jul 2024 20:37:39 +0200 Subject: [PATCH 23/77] attempt 1 --- .github/workflows/build.yml | 2 ++ pyproject.toml | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1e3a9dfd6..9d0a69c10 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,6 +57,8 @@ jobs: env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True + CIBW_TEST_COMMAND: + make test - name: Upload wheels uses: actions/upload-artifact@v4 diff --git a/pyproject.toml b/pyproject.toml index 5f8486042..f6923d1c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -215,9 +215,9 @@ skip = [ "cp3{7,8,9,10,11,12}-*linux_{aarch64,ppc64le,s390x}", # Only test cp36/cp313 on qemu tested architectures "pp*", ] -test-command = [ - "env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests", -] +# test-command = [ +# "env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests", +# ] test-extras = "test" [tool.cibuildwheel.macos] From 666cd81e014738f2a4c37a1c944540478ade9c65 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 27 Jul 2024 20:40:40 +0200 Subject: [PATCH 24/77] install pytest --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d0a69c10..d648a0526 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,6 +58,7 @@ jobs: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_COMMAND: + pip install pytest make test - name: Upload wheels From 22e7f88d8adcfe55179d7d74dc3f5deed839eff4 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 27 Jul 2024 20:45:01 +0200 Subject: [PATCH 25/77] adjust path --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d648a0526..925b76201 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,8 +58,8 @@ jobs: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_COMMAND: - pip install pytest - make test + python3 -m pip install pytest + PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python3 -m pytest -v -s --tb=short --ignore={project}/tests/test_memleaks.py {project}/psutil/tests - name: Upload wheels uses: actions/upload-artifact@v4 From 9deea3fd38e61a6e68c716117cc17a07e0d0972b Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 27 Jul 2024 20:48:49 +0200 Subject: [PATCH 26/77] adjust path 2 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 925b76201..31d3fb1a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,7 +58,7 @@ jobs: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_COMMAND: - python3 -m pip install pytest + pip install pytest PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python3 -m pytest -v -s --tb=short --ignore={project}/tests/test_memleaks.py {project}/psutil/tests - name: Upload wheels From 8871a089a2a0b7e56d1649b0cb3dd6235acde8cc Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 27 Jul 2024 20:49:19 +0200 Subject: [PATCH 27/77] progress --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 31d3fb1a7..aeab8a110 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,8 +58,8 @@ jobs: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_COMMAND: - pip install pytest - PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python3 -m pytest -v -s --tb=short --ignore={project}/tests/test_memleaks.py {project}/psutil/tests + python -m pip install pytest + PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest -v -s --tb=short --ignore={project}/tests/test_memleaks.py {project}/psutil/tests - name: Upload wheels uses: actions/upload-artifact@v4 From f04e92c326a81d0a79eb5fe89ddbcc446cd2adfb Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 27 Jul 2024 20:54:05 +0200 Subject: [PATCH 28/77] progress --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f6923d1c4..42c4128a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -215,9 +215,9 @@ skip = [ "cp3{7,8,9,10,11,12}-*linux_{aarch64,ppc64le,s390x}", # Only test cp36/cp313 on qemu tested architectures "pp*", ] -# test-command = [ -# "env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests", -# ] +test-command = [ + "python -m pip install pytest && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests", +] test-extras = "test" [tool.cibuildwheel.macos] From 516ed56f49c7e759e576d87fafe143ce62e36aba Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Mon, 30 Sep 2024 20:51:46 +0200 Subject: [PATCH 29/77] add pytest dep --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 4b642217e..d16828cb9 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ ifndef GITHUB_ACTIONS pylint \ pyperf \ pypinfo \ + pytest \ pytest-cov \ pytest-xdist \ requests \ From 65b7aabce9a6fcc79c7fe557768a9ca631a9678b Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Mon, 30 Sep 2024 20:57:40 +0200 Subject: [PATCH 30/77] attempt --- .github/workflows/build.yml | 16 ++++++++-------- Makefile | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aeab8a110..653280cd1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,12 +26,12 @@ jobs: matrix: include: - {os: ubuntu-latest, arch: x86_64} - - {os: ubuntu-latest, arch: i686} - - {os: ubuntu-latest, arch: aarch64} - - {os: macos-12, arch: x86_64} - - {os: macos-14, arch: arm64} - - {os: windows-2019, arch: AMD64} - - {os: windows-2019, arch: x86} + # - {os: ubuntu-latest, arch: i686} + # - {os: ubuntu-latest, arch: aarch64} + # - {os: macos-12, arch: x86_64} + # - {os: macos-14, arch: arm64} + # - {os: windows-2019, arch: AMD64} + # - {os: windows-2019, arch: x86} steps: - uses: actions/checkout@v4 @@ -57,9 +57,9 @@ jobs: env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True + CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: - python -m pip install pytest - PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest -v -s --tb=short --ignore={project}/tests/test_memleaks.py {project}/psutil/tests + PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest -v -s --tb=short --ignore={project}/tests/test_memleaks.py {project}/psutil/tests - name: Upload wheels uses: actions/upload-artifact@v4 diff --git a/Makefile b/Makefile index d16828cb9..4b642217e 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,6 @@ ifndef GITHUB_ACTIONS pylint \ pyperf \ pypinfo \ - pytest \ pytest-cov \ pytest-xdist \ requests \ From 38619145bf222bb7dd0d7f5ed17fd31e17de719e Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Mon, 30 Sep 2024 22:06:11 +0200 Subject: [PATCH 31/77] attempt 2 --- .github/workflows/build.yml | 4 ++-- pyproject.toml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 653280cd1..65e183156 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -84,9 +84,9 @@ jobs: matrix: os: [ubuntu-latest, macos-12] env: + CIBW_TEST_REQUIRES: 'pytest' CIBW_TEST_COMMAND: - PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=short -v -s {project}/psutil/tests/runner.py && - PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python -m pytest --tb=short -v -s {project}/psutil/tests/test_memleaks.py + PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test CIBW_BUILD: 'cp27-*' diff --git a/pyproject.toml b/pyproject.toml index 35749d33e..3d0f9e01b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -217,9 +217,9 @@ skip = [ "cp3{7,8,9,10,11,12}-*linux_{aarch64,ppc64le,s390x}", # Only test cp36/cp313 on qemu tested architectures "pp*", ] -test-command = [ - "python -m pip install pytest && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests", -] +# test-command = [ +# "python -m pip install pytest && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests", +# ] test-extras = "test" [tool.cibuildwheel.macos] From f9f374d3ed0c211fcc03e38e987890e5f7b64c18 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 09:54:03 +0200 Subject: [PATCH 32/77] attempt 3 --- .github/workflows/build.yml | 84 ++++++++++++++++++------------------- pyproject.toml | 6 +-- 2 files changed, 43 insertions(+), 47 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65e183156..98deba011 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,10 +57,6 @@ jobs: env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True - CIBW_TEST_REQUIRES: pytest - CIBW_TEST_COMMAND: - PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest -v -s --tb=short --ignore={project}/tests/test_memleaks.py {project}/psutil/tests - - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -112,45 +108,45 @@ jobs: python setup.py sdist mv dist/psutil*.tar.gz wheelhouse/ - # Run linters - linters: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - name: 'Run linters' - run: | - python3 -m pip install ruff black rstcheck toml-sort sphinx - make lint-all + # # Run linters + # linters: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-python@v5 + # with: + # python-version: 3.x + # - name: 'Run linters' + # run: | + # python3 -m pip install ruff black rstcheck toml-sort sphinx + # make lint-all - # upload weels as a single artefact - upload-wheels: - needs: [py2, py3] - runs-on: ubuntu-latest - steps: - - uses: actions/upload-artifact/merge@v4 - with: - name: wheels - pattern: wheels-* - separate-directories: false - delete-merged: true + # # upload weels as a single artefact + # upload-wheels: + # needs: [py2, py3] + # runs-on: ubuntu-latest + # steps: + # - uses: actions/upload-artifact/merge@v4 + # with: + # name: wheels + # pattern: wheels-* + # separate-directories: false + # delete-merged: true - # Check sanity of .tar.gz + wheel files - check-dist: - needs: [upload-wheels] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - uses: actions/download-artifact@v4 - with: - name: wheels - path: wheelhouse - - run: | - python scripts/internal/print_hashes.py wheelhouse/ - pipx run twine check --strict wheelhouse/* - pipx run abi3audit --verbose --strict wheelhouse/*-abi3-*.whl + # # Check sanity of .tar.gz + wheel files + # check-dist: + # needs: [upload-wheels] + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-python@v5 + # with: + # python-version: 3.x + # - uses: actions/download-artifact@v4 + # with: + # name: wheels + # path: wheelhouse + # - run: | + # python scripts/internal/print_hashes.py wheelhouse/ + # pipx run twine check --strict wheelhouse/* + # pipx run abi3audit --verbose --strict wheelhouse/*-abi3-*.whl diff --git a/pyproject.toml b/pyproject.toml index 3d0f9e01b..35749d33e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -217,9 +217,9 @@ skip = [ "cp3{7,8,9,10,11,12}-*linux_{aarch64,ppc64le,s390x}", # Only test cp36/cp313 on qemu tested architectures "pp*", ] -# test-command = [ -# "python -m pip install pytest && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests", -# ] +test-command = [ + "python -m pip install pytest && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests", +] test-extras = "test" [tool.cibuildwheel.macos] From 1a96b3e90e9bc6adf7e88adedd11d90bc2287a1d Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 09:57:23 +0200 Subject: [PATCH 33/77] progress --- .github/workflows/build.yml | 81 +++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 98deba011..30e573e99 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,6 +57,7 @@ jobs: env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True + - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -108,45 +109,45 @@ jobs: python setup.py sdist mv dist/psutil*.tar.gz wheelhouse/ - # # Run linters - # linters: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: actions/setup-python@v5 - # with: - # python-version: 3.x - # - name: 'Run linters' - # run: | - # python3 -m pip install ruff black rstcheck toml-sort sphinx - # make lint-all + # Run linters + linters: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: 'Run linters' + run: | + python3 -m pip install ruff black rstcheck toml-sort sphinx + make lint-all - # # upload weels as a single artefact - # upload-wheels: - # needs: [py2, py3] - # runs-on: ubuntu-latest - # steps: - # - uses: actions/upload-artifact/merge@v4 - # with: - # name: wheels - # pattern: wheels-* - # separate-directories: false - # delete-merged: true + # upload weels as a single artefact + upload-wheels: + needs: [py2, py3] + runs-on: ubuntu-latest + steps: + - uses: actions/upload-artifact/merge@v4 + with: + name: wheels + pattern: wheels-* + separate-directories: false + delete-merged: true - # # Check sanity of .tar.gz + wheel files - # check-dist: - # needs: [upload-wheels] - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: actions/setup-python@v5 - # with: - # python-version: 3.x - # - uses: actions/download-artifact@v4 - # with: - # name: wheels - # path: wheelhouse - # - run: | - # python scripts/internal/print_hashes.py wheelhouse/ - # pipx run twine check --strict wheelhouse/* - # pipx run abi3audit --verbose --strict wheelhouse/*-abi3-*.whl + # Check sanity of .tar.gz + wheel files + check-dist: + needs: [upload-wheels] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - uses: actions/download-artifact@v4 + with: + name: wheels + path: wheelhouse + - run: | + python scripts/internal/print_hashes.py wheelhouse/ + pipx run twine check --strict wheelhouse/* + pipx run abi3audit --verbose --strict wheelhouse/*-abi3-*.whl From 8f83395efc5c23da19a18d4e98cabd8fd99abc87 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 11:29:45 +0200 Subject: [PATCH 34/77] progress2 --- .github/workflows/build.yml | 149 ++++++++++++++++++------------------ pyproject.toml | 4 - 2 files changed, 76 insertions(+), 77 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 30e573e99..b6f79046a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,6 +57,10 @@ jobs: env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True + CIBW_TEST_REQUIRES: pytest + CIBW_TEST_COMMAND: + make install && PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + CIBW_TEST_EXTRAS: test - name: Upload wheels uses: actions/upload-artifact@v4 @@ -71,83 +75,82 @@ jobs: python setup.py sdist mv dist/psutil*.tar.gz wheelhouse/ - # Linux + macOS + Python 2 - py2: - name: py2, ${{ matrix.os }} - runs-on: ${{ matrix.os }} - timeout-minutes: 20 - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-12] - env: - CIBW_TEST_REQUIRES: 'pytest' - CIBW_TEST_COMMAND: - PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests - CIBW_TEST_EXTRAS: test - CIBW_BUILD: 'cp27-*' + # # Linux + macOS + Python 2 + # py2: + # name: py2, ${{ matrix.os }} + # runs-on: ${{ matrix.os }} + # timeout-minutes: 20 + # strategy: + # fail-fast: false + # matrix: + # os: [ubuntu-latest, macos-12] + # env: + # CIBW_TEST_COMMAND: + # PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + # CIBW_TEST_EXTRAS: test + # CIBW_BUILD: 'cp27-*' - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.9 + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-python@v5 + # with: + # python-version: 3.9 - - name: Create wheels + run tests - uses: pypa/cibuildwheel@v1.12.0 + # - name: Create wheels + run tests + # uses: pypa/cibuildwheel@v1.12.0 - - name: Upload wheels - uses: actions/upload-artifact@v4 - with: - name: wheels-py2-${{ matrix.os }} - path: wheelhouse + # - name: Upload wheels + # uses: actions/upload-artifact@v4 + # with: + # name: wheels-py2-${{ matrix.os }} + # path: wheelhouse - - name: Generate .tar.gz - if: matrix.os == 'ubuntu-latest' - run: | - make generate-manifest - python setup.py sdist - mv dist/psutil*.tar.gz wheelhouse/ + # - name: Generate .tar.gz + # if: matrix.os == 'ubuntu-latest' + # run: | + # make generate-manifest + # python setup.py sdist + # mv dist/psutil*.tar.gz wheelhouse/ - # Run linters - linters: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - name: 'Run linters' - run: | - python3 -m pip install ruff black rstcheck toml-sort sphinx - make lint-all + # # Run linters + # linters: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-python@v5 + # with: + # python-version: 3.x + # - name: 'Run linters' + # run: | + # python3 -m pip install ruff black rstcheck toml-sort sphinx + # make lint-all - # upload weels as a single artefact - upload-wheels: - needs: [py2, py3] - runs-on: ubuntu-latest - steps: - - uses: actions/upload-artifact/merge@v4 - with: - name: wheels - pattern: wheels-* - separate-directories: false - delete-merged: true + # # upload weels as a single artefact + # upload-wheels: + # needs: [py2, py3] + # runs-on: ubuntu-latest + # steps: + # - uses: actions/upload-artifact/merge@v4 + # with: + # name: wheels + # pattern: wheels-* + # separate-directories: false + # delete-merged: true - # Check sanity of .tar.gz + wheel files - check-dist: - needs: [upload-wheels] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - uses: actions/download-artifact@v4 - with: - name: wheels - path: wheelhouse - - run: | - python scripts/internal/print_hashes.py wheelhouse/ - pipx run twine check --strict wheelhouse/* - pipx run abi3audit --verbose --strict wheelhouse/*-abi3-*.whl + # # Check sanity of .tar.gz + wheel files + # check-dist: + # needs: [upload-wheels] + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-python@v5 + # with: + # python-version: 3.x + # - uses: actions/download-artifact@v4 + # with: + # name: wheels + # path: wheelhouse + # - run: | + # python scripts/internal/print_hashes.py wheelhouse/ + # pipx run twine check --strict wheelhouse/* + # pipx run abi3audit --verbose --strict wheelhouse/*-abi3-*.whl diff --git a/pyproject.toml b/pyproject.toml index 35749d33e..878f789f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -217,10 +217,6 @@ skip = [ "cp3{7,8,9,10,11,12}-*linux_{aarch64,ppc64le,s390x}", # Only test cp36/cp313 on qemu tested architectures "pp*", ] -test-command = [ - "python -m pip install pytest && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests", -] -test-extras = "test" [tool.cibuildwheel.macos] archs = ["arm64", "x86_64"] From 904b849a7022da74a6396b34d7ff314b495cc36a Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 11:32:09 +0200 Subject: [PATCH 35/77] progress 3 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b6f79046a..ec63e77d5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,7 +59,7 @@ jobs: CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: - make install && PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + make -C {project} install && PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test - name: Upload wheels From 6615db455f55e6b40263106c25d2eab85b6eb298 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 12:00:44 +0200 Subject: [PATCH 36/77] progress 4 --- .github/workflows/build.yml | 7 +++---- psutil/tests/test_process.py | 15 +++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec63e77d5..751b4d3e8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,9 +28,9 @@ jobs: - {os: ubuntu-latest, arch: x86_64} # - {os: ubuntu-latest, arch: i686} # - {os: ubuntu-latest, arch: aarch64} - # - {os: macos-12, arch: x86_64} + - {os: macos-12, arch: x86_64} # - {os: macos-14, arch: arm64} - # - {os: windows-2019, arch: AMD64} + - {os: windows-2019, arch: AMD64} # - {os: windows-2019, arch: x86} steps: - uses: actions/checkout@v4 @@ -57,9 +57,8 @@ jobs: env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True - CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: - make -C {project} install && PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + make -C {project} setup-dev-env install && PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test - name: Upload wheels diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index b2aeada07..ac7e69020 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -1503,13 +1503,16 @@ def test_pid_0(self): @unittest.skipIf(not HAS_ENVIRON, "not supported") def test_environ(self): def clean_dict(d): - # Most of these are problematic on Travis. - d.pop("PLAT", None) - d.pop("HOME", None) + exclude = ["PLAT", "HOME", "PYTEST_CURRENT_TEST"] if MACOS: - d.pop("__CF_USER_TEXT_ENCODING", None) - d.pop("VERSIONER_PYTHON_PREFER_32_BIT", None) - d.pop("VERSIONER_PYTHON_VERSION", None) + exclude.extend([ + "__CF_USER_TEXT_ENCODING", + "VERSIONER_PYTHON_PREFER_32_BIT", + "VERSIONER_PYTHON_VERSION", + "VERSIONER_PYTHON_VERSION", + ]) + for name in exclude: + d.pop(name, None) return dict([ ( k.replace("\r", "").replace("\n", ""), From 936e4ed5b14e3dd3ee273ee89e37b5dcd6c5eea1 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 14:18:33 +0200 Subject: [PATCH 37/77] progress 5 --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 751b4d3e8..810e0e740 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,8 +57,9 @@ jobs: env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True + CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: - make -C {project} setup-dev-env install && PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test - name: Upload wheels From 785f9b3c27de0f48edc97c40d618fae1fb617f2e Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 14:21:01 +0200 Subject: [PATCH 38/77] progress 6 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 810e0e740..340d75631 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,7 +59,7 @@ jobs: CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: - PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + make -C {project} install && PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test - name: Upload wheels From 82fdc6409423f8ac2b04df6183a4e1d971b5da07 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 14:25:52 +0200 Subject: [PATCH 39/77] progress 7 --- .github/workflows/build.yml | 2 +- psutil/tests/test_process.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 340d75631..3f2eae88b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,7 +57,7 @@ jobs: env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True - CIBW_TEST_REQUIRES: pytest + CIBW_TEST_REQUIRES: pytest bdist_wheel CIBW_TEST_COMMAND: make -C {project} install && PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index ac7e69020..6863108a3 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -1503,7 +1503,7 @@ def test_pid_0(self): @unittest.skipIf(not HAS_ENVIRON, "not supported") def test_environ(self): def clean_dict(d): - exclude = ["PLAT", "HOME", "PYTEST_CURRENT_TEST"] + exclude = ["PLAT", "HOME", "PYTEST_CURRENT_TEST", "PYTEST_VERSION"] if MACOS: exclude.extend([ "__CF_USER_TEXT_ENCODING", From a50aa7ae82b1d8d9787e6401ffb5932ceb45507f Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 14:33:18 +0200 Subject: [PATCH 40/77] progress 8 --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3f2eae88b..f5303803a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,9 +57,9 @@ jobs: env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True - CIBW_TEST_REQUIRES: pytest bdist_wheel + CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: - make -C {project} install && PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + make -C {project} install && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test - name: Upload wheels From 7933aa1953505020eff0facdbafa224958555f5a Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 14:50:26 +0200 Subject: [PATCH 41/77] progress 9 --- .github/workflows/build.yml | 2 +- Makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f5303803a..b873a87a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,7 +59,7 @@ jobs: CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: - make -C {project} install && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test - name: Upload wheels diff --git a/Makefile b/Makefile index 869056d27..14fbd98e8 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,8 @@ ARGS = # mandatory deps for running tests PY3_DEPS = \ - pytest + pytest \ + pytest-xdist # dev deps. ifndef GITHUB_ACTIONS PY3_DEPS += \ @@ -22,7 +23,6 @@ ifndef GITHUB_ACTIONS pyperf \ pypinfo \ pytest-cov \ - pytest-xdist \ requests \ rstcheck \ ruff \ From 4bef550884f76e20069dafb295259d031253c355 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 14:52:32 +0200 Subject: [PATCH 42/77] progress 10 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b873a87a8..c012a4245 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,7 +59,7 @@ jobs: CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: - env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + make -C {project} install PYTHON="env python" && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test - name: Upload wheels From 172c3ddb3c4cffd1e936c67ee249ed7211cce4dd Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 14:57:17 +0200 Subject: [PATCH 43/77] progress 11 --- .github/workflows/build.yml | 3 +-- Makefile | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c012a4245..05c2734e4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,9 +57,8 @@ jobs: env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True - CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: - make -C {project} install PYTHON="env python" && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + make -C {project} setup-dev-env install PYTHON="env python" && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test - name: Upload wheels diff --git a/Makefile b/Makefile index 14fbd98e8..4677e03df 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,12 @@ # You can set the variables below from the command line. # Configurable. -PYTHON = python3 +ifdef CIBUILDWHEEL + PYTHON = env python +else + PYTHON = python3 +endif + PYTHON_ENV_VARS = PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PYTEST_ARGS = -v -s --tb=short ARGS = @@ -11,7 +16,8 @@ ARGS = # mandatory deps for running tests PY3_DEPS = \ pytest \ - pytest-xdist + pytest-xdist \ + setuptools # dev deps. ifndef GITHUB_ACTIONS PY3_DEPS += \ @@ -26,7 +32,6 @@ ifndef GITHUB_ACTIONS requests \ rstcheck \ ruff \ - setuptools \ sphinx_rtd_theme \ toml-sort \ twine \ From 901ad7586be73be179cacb2d2789bcd2e3781732 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 15:01:29 +0200 Subject: [PATCH 44/77] progress 12 --- .github/workflows/build.yml | 3 ++- Makefile | 12 ++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05c2734e4..96ebb7b63 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,8 +57,9 @@ jobs: env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True + CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: - make -C {project} setup-dev-env install PYTHON="env python" && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + python -m pip install setuptools && make -C {project} install PYTHON="env python" && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test - name: Upload wheels diff --git a/Makefile b/Makefile index 4677e03df..160dbfebd 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,7 @@ # You can set the variables below from the command line. # Configurable. -ifdef CIBUILDWHEEL - PYTHON = env python -else - PYTHON = python3 -endif - +PYTHON = python3 PYTHON_ENV_VARS = PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PYTEST_ARGS = -v -s --tb=short ARGS = @@ -16,8 +11,7 @@ ARGS = # mandatory deps for running tests PY3_DEPS = \ pytest \ - pytest-xdist \ - setuptools + pytest-xdist # dev deps. ifndef GITHUB_ACTIONS PY3_DEPS += \ @@ -29,9 +23,11 @@ ifndef GITHUB_ACTIONS pyperf \ pypinfo \ pytest-cov \ + pytest-xdist \ requests \ rstcheck \ ruff \ + setuptools \ sphinx_rtd_theme \ toml-sort \ twine \ From 840258f65e9a3d9d8ed02cbc97b085bb589bcf4a Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 15:09:45 +0200 Subject: [PATCH 45/77] progress 13 --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 96ebb7b63..3971ebcb6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,9 +57,8 @@ jobs: env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True - CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: - python -m pip install setuptools && make -C {project} install PYTHON="env python" && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + env python -m pip install setuptools pytest pytest-xdist && make -C {project} install PYTHON="env python" && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test - name: Upload wheels From 464571d3d150887910f92f0731c5ff0fa56f13ee Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 15:22:03 +0200 Subject: [PATCH 46/77] progress 14 --- .github/workflows/build.yml | 2 +- Makefile | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3971ebcb6..05c2734e4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,7 +58,7 @@ jobs: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_COMMAND: - env python -m pip install setuptools pytest pytest-xdist && make -C {project} install PYTHON="env python" && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + make -C {project} setup-dev-env install PYTHON="env python" && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test - name: Upload wheels diff --git a/Makefile b/Makefile index 160dbfebd..2d4efee47 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,12 @@ # To use a specific Python version run: "make install PYTHON=python3.3" # You can set the variables below from the command line. -# Configurable. -PYTHON = python3 +ifdef CIBUILDWHEEL + PYTHON = python3 +else + PYTHON = env python +endif + PYTHON_ENV_VARS = PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PYTEST_ARGS = -v -s --tb=short ARGS = From 6ecee70d3ec9085edbb11751f21248ea7ca98c82 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 15:22:19 +0200 Subject: [PATCH 47/77] progress 15 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05c2734e4..b1c46c80b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,7 +58,7 @@ jobs: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_COMMAND: - make -C {project} setup-dev-env install PYTHON="env python" && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + make -C {project} setup-dev-env install && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test - name: Upload wheels From 3add3ede556d595428b0307be96b2ddefa696336 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 15:24:39 +0200 Subject: [PATCH 48/77] progress 16 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2d4efee47..8a1fc64dc 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ PY3_DEPS = \ pytest \ pytest-xdist # dev deps. -ifndef GITHUB_ACTIONS +ifndef CIBUILDWHEEL PY3_DEPS += \ black \ check-manifest \ From ae3fb0034f6e190e728866933e262b3c9741e5a8 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 15:24:59 +0200 Subject: [PATCH 49/77] progress 17 --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 8a1fc64dc..8f48460f2 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ ARGS = # mandatory deps for running tests PY3_DEPS = \ + setuptools \ pytest \ pytest-xdist # dev deps. From 0b20ce3777ce4353252a0b6a5bac3a6e955fb446 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 15:34:47 +0200 Subject: [PATCH 50/77] progress 18 --- .github/workflows/build.yml | 2 +- Makefile | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b1c46c80b..05c2734e4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,7 +58,7 @@ jobs: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_COMMAND: - make -C {project} setup-dev-env install && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + make -C {project} setup-dev-env install PYTHON="env python" && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests CIBW_TEST_EXTRAS: test - name: Upload wheels diff --git a/Makefile b/Makefile index 8f48460f2..3fb26fa71 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,7 @@ # To use a specific Python version run: "make install PYTHON=python3.3" # You can set the variables below from the command line. -ifdef CIBUILDWHEEL - PYTHON = python3 -else - PYTHON = env python -endif - +PYTHON = python3 PYTHON_ENV_VARS = PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PYTEST_ARGS = -v -s --tb=short ARGS = From 8ff70d4b4bbe9ed6e18cba27002d3b484ee14352 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 15:58:35 +0200 Subject: [PATCH 51/77] progress 19 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05c2734e4..e4b26d8d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,7 +58,7 @@ jobs: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_COMMAND: - make -C {project} setup-dev-env install PYTHON="env python" && env PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests + make -C {project} setup-dev-env install PYTHON="env python" && make -C {project} test test-memleaks PSUTIL_SCRIPTS_DIR={project}/scripts CIBW_TEST_EXTRAS: test - name: Upload wheels From bee3417f348d4c4f3c385cf8616fd1db07c0452d Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 16:04:24 +0200 Subject: [PATCH 52/77] progress 20 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4b26d8d0..c73da7ef7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,7 +58,7 @@ jobs: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_COMMAND: - make -C {project} setup-dev-env install PYTHON="env python" && make -C {project} test test-memleaks PSUTIL_SCRIPTS_DIR={project}/scripts + make -C {project} setup-dev-env install test test-memleaks PYTHON="env python" PSUTIL_SCRIPTS_DIR={project}/scripts CIBW_TEST_EXTRAS: test - name: Upload wheels From ce52218976a1e5c3240ce1ad4e7b84de9610e1cc Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 16:16:51 +0200 Subject: [PATCH 53/77] progress 21 --- .github/workflows/build.yml | 144 ++++++++++++++++++------------------ Makefile | 14 +++- 2 files changed, 82 insertions(+), 76 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c73da7ef7..4a34ec16b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -74,82 +74,82 @@ jobs: python setup.py sdist mv dist/psutil*.tar.gz wheelhouse/ - # # Linux + macOS + Python 2 - # py2: - # name: py2, ${{ matrix.os }} - # runs-on: ${{ matrix.os }} - # timeout-minutes: 20 - # strategy: - # fail-fast: false - # matrix: - # os: [ubuntu-latest, macos-12] - # env: - # CIBW_TEST_COMMAND: - # PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_SCRIPTS_DIR={project}/scripts python -m pytest --tb=short -v -s {project}/psutil/tests - # CIBW_TEST_EXTRAS: test - # CIBW_BUILD: 'cp27-*' + # Linux + macOS + Python 2 + py2: + name: py2, ${{ matrix.os }} + runs-on: ${{ matrix.os }} + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-12] + env: + CIBW_TEST_COMMAND: + make -C {project} setup-dev-env install test test-memleaks PYTHON="env python" PSUTIL_SCRIPTS_DIR={project}/scripts + CIBW_TEST_EXTRAS: test + CIBW_BUILD: 'cp27-*' - # steps: - # - uses: actions/checkout@v4 - # - uses: actions/setup-python@v5 - # with: - # python-version: 3.9 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.9 - # - name: Create wheels + run tests - # uses: pypa/cibuildwheel@v1.12.0 + - name: Create wheels + run tests + uses: pypa/cibuildwheel@v1.12.0 - # - name: Upload wheels - # uses: actions/upload-artifact@v4 - # with: - # name: wheels-py2-${{ matrix.os }} - # path: wheelhouse + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-py2-${{ matrix.os }} + path: wheelhouse - # - name: Generate .tar.gz - # if: matrix.os == 'ubuntu-latest' - # run: | - # make generate-manifest - # python setup.py sdist - # mv dist/psutil*.tar.gz wheelhouse/ + - name: Generate .tar.gz + if: matrix.os == 'ubuntu-latest' + run: | + make generate-manifest + python setup.py sdist + mv dist/psutil*.tar.gz wheelhouse/ - # # Run linters - # linters: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: actions/setup-python@v5 - # with: - # python-version: 3.x - # - name: 'Run linters' - # run: | - # python3 -m pip install ruff black rstcheck toml-sort sphinx - # make lint-all + # Run linters + linters: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: 'Run linters' + run: | + python3 -m pip install ruff black rstcheck toml-sort sphinx + make lint-all - # # upload weels as a single artefact - # upload-wheels: - # needs: [py2, py3] - # runs-on: ubuntu-latest - # steps: - # - uses: actions/upload-artifact/merge@v4 - # with: - # name: wheels - # pattern: wheels-* - # separate-directories: false - # delete-merged: true + # upload weels as a single artefact + upload-wheels: + needs: [py2, py3] + runs-on: ubuntu-latest + steps: + - uses: actions/upload-artifact/merge@v4 + with: + name: wheels + pattern: wheels-* + separate-directories: false + delete-merged: true - # # Check sanity of .tar.gz + wheel files - # check-dist: - # needs: [upload-wheels] - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: actions/setup-python@v5 - # with: - # python-version: 3.x - # - uses: actions/download-artifact@v4 - # with: - # name: wheels - # path: wheelhouse - # - run: | - # python scripts/internal/print_hashes.py wheelhouse/ - # pipx run twine check --strict wheelhouse/* - # pipx run abi3audit --verbose --strict wheelhouse/*-abi3-*.whl + # Check sanity of .tar.gz + wheel files + check-dist: + needs: [upload-wheels] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - uses: actions/download-artifact@v4 + with: + name: wheels + path: wheelhouse + - run: | + python scripts/internal/print_hashes.py wheelhouse/ + pipx run twine check --strict wheelhouse/* + pipx run abi3audit --verbose --strict wheelhouse/*-abi3-*.whl diff --git a/Makefile b/Makefile index 3fb26fa71..a6a9c831a 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,8 @@ PY3_DEPS = \ setuptools \ pytest \ pytest-xdist -# dev deps. + +# deps for local development ifndef CIBUILDWHEEL PY3_DEPS += \ black \ @@ -23,7 +24,6 @@ ifndef CIBUILDWHEEL pyperf \ pypinfo \ pytest-cov \ - pytest-xdist \ requests \ rstcheck \ ruff \ @@ -34,12 +34,16 @@ ifndef CIBUILDWHEEL virtualenv \ wheel endif + # python 2 deps PY2_DEPS = \ futures \ ipaddress \ - mock \ - pytest + mock==1.0.1 \ + pytest==4.6.11 \ + pytest-xdist \ + setuptools + PY_DEPS = `$(PYTHON) -c \ "import sys; \ py3 = sys.version_info[0] == 3; \ @@ -48,12 +52,14 @@ PY_DEPS = `$(PYTHON) -c \ print('$(PY3_DEPS)' + py3_extra if py3 else '$(PY2_DEPS)')"` NUM_WORKERS = `$(PYTHON) -c "import os; print(os.cpu_count() or 1)"` + # "python3 setup.py build" can be parallelized on Python >= 3.6. BUILD_OPTS = `$(PYTHON) -c \ "import sys, os; \ py36 = sys.version_info[:2] >= (3, 6); \ cpus = os.cpu_count() or 1 if py36 else 1; \ print('--parallel %s' % cpus if cpus > 1 else '')"` + # In not in a virtualenv, add --user options for install commands. INSTALL_OPTS = `$(PYTHON) -c \ "import sys; print('' if hasattr(sys, 'real_prefix') or hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix else '--user')"` From 334bac6a01f5eed6f4150f81a15e4e1034c26cc3 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 16:18:37 +0200 Subject: [PATCH 54/77] progress 22 --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4a34ec16b..a62dbae4d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,9 +57,9 @@ jobs: env: CIBW_ARCHS: "${{ matrix.arch }}" CIBW_PRERELEASE_PYTHONS: True + CIBW_TEST_EXTRAS: test CIBW_TEST_COMMAND: make -C {project} setup-dev-env install test test-memleaks PYTHON="env python" PSUTIL_SCRIPTS_DIR={project}/scripts - CIBW_TEST_EXTRAS: test - name: Upload wheels uses: actions/upload-artifact@v4 @@ -84,10 +84,10 @@ jobs: matrix: os: [ubuntu-latest, macos-12] env: - CIBW_TEST_COMMAND: - make -C {project} setup-dev-env install test test-memleaks PYTHON="env python" PSUTIL_SCRIPTS_DIR={project}/scripts - CIBW_TEST_EXTRAS: test CIBW_BUILD: 'cp27-*' + CIBW_TEST_EXTRAS: test + CIBW_TEST_COMMAND: + make -C {project} setup-dev-env install test test-memleaks PYTHON="env python" PSUTIL_SCRIPTS_DIR={project}/scripts steps: - uses: actions/checkout@v4 From af760474ffd3a8cef416b669330bd91c1c9e784e Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 16:22:36 +0200 Subject: [PATCH 55/77] progress 23 --- .github/workflows/build.yml | 8 ++++---- Makefile | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a62dbae4d..e5c6fb1d8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,12 +26,12 @@ jobs: matrix: include: - {os: ubuntu-latest, arch: x86_64} - # - {os: ubuntu-latest, arch: i686} - # - {os: ubuntu-latest, arch: aarch64} + - {os: ubuntu-latest, arch: i686} + - {os: ubuntu-latest, arch: aarch64} - {os: macos-12, arch: x86_64} - # - {os: macos-14, arch: arm64} + - {os: macos-14, arch: arm64} - {os: windows-2019, arch: AMD64} - # - {os: windows-2019, arch: x86} + - {os: windows-2019, arch: x86} steps: - uses: actions/checkout@v4 diff --git a/Makefile b/Makefile index a6a9c831a..395e9dce8 100644 --- a/Makefile +++ b/Makefile @@ -138,8 +138,8 @@ install-pip: ## Install pip (no-op if already installed). setup-dev-env: ## Install GIT hooks, pip, test deps (also upgrades them). ${MAKE} install-git-hooks ${MAKE} install-pip - $(PYTHON_ENV_VARS) $(PYTHON) -m pip install $(INSTALL_OPTS) --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip - $(PYTHON_ENV_VARS) $(PYTHON) -m pip install $(INSTALL_OPTS) --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade $(PY_DEPS) + $(PYTHON) -m pip install $(INSTALL_OPTS) --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip + $(PYTHON) -m pip install $(INSTALL_OPTS) --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade $(PY_DEPS) # =================================================================== # Tests From 7d54440b8648635ff682c4ad8dc6bb8569788cd1 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 16:26:35 +0200 Subject: [PATCH 56/77] resync pyproject.toml with master --- pyproject.toml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 878f789f5..e1cde1b33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,12 +23,7 @@ select = [ "D301", # Use `r"""` if any backslashes in a docstring "D403", # [*] First word of the first line should be capitalized "PERF102", # [*] When using only the keys of a dict use the `keys()` method - "PLR5501", # [*] Use `elif` instead of `else` then `if`, to reduce indentation - "PLR6104", # Use `+=` to perform an augmented assignment directly - "PLW0602", # Using global for `x` but no assignment is done "RET507", # Unnecessary `elif` after `continue` statement - "RUF021", # [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear - "RUF023", # [*] `Class.__slots__` is not sorted "S113", # Probable use of requests call without timeout "S602", # `subprocess` call with `shell=True` identified, security issue ] @@ -45,7 +40,6 @@ ignore = [ "COM812", # Trailing comma missing "D", # pydocstyle "DOC", # various docstring warnings - "DOC501", # Raised exception `X` missing from docstring "DTZ", # flake8-datetimez "ERA001", # Found commented-out code "FBT", # flake8-boolean-trap (makes zero sense) From 04f95d55b70e34166e1337a90b72a813b3eb3435 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 16:27:17 +0200 Subject: [PATCH 57/77] resync pyproject.toml with master --- scripts/pidof.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/pidof.py b/scripts/pidof.py index 71314963f..662d5d657 100755 --- a/scripts/pidof.py +++ b/scripts/pidof.py @@ -22,8 +22,10 @@ def pidof(pgname): pids = [] for proc in psutil.process_iter(['name', 'cmdline']): # search for matches in the process name and cmdline - if proc.info['name'] == pgname or ( - proc.info['cmdline'] and proc.info['cmdline'][0] == pgname + if ( + proc.info['name'] == pgname + or proc.info['cmdline'] + and proc.info['cmdline'][0] == pgname ): pids.append(str(proc.pid)) return pids From ff880522eae7c188467cc7b68f5b42310d7727cc Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 16:29:11 +0200 Subject: [PATCH 58/77] resync with master --- psutil/tests/test_process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index 6863108a3..33419de1b 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -623,7 +623,7 @@ def test_memory_full_info(self): for name in mem._fields: value = getattr(mem, name) self.assertGreaterEqual(value, 0, msg=(name, value)) - if (name == 'vms' and OSX) or LINUX: + if name == 'vms' and OSX or LINUX: continue self.assertLessEqual(value, total, msg=(name, value, total)) if LINUX or WINDOWS or MACOS: From 1686b3b173b7ac656bfa0fc8f0c76491d1356429 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 16:45:07 +0200 Subject: [PATCH 59/77] print sysinfo when tests start --- psutil/tests/__init__.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 83d00f708..4744ac4ad 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -1355,14 +1355,19 @@ def print_sysinfo(): print("=" * 70, file=sys.stderr) # NOQA sys.stdout.flush() - if WINDOWS: - os.system("tasklist") - elif which("ps"): - os.system("ps aux") - print("=" * 70, file=sys.stderr) # NOQA + # if WINDOWS: + # os.system("tasklist") + # elif which("ps"): + # os.system("ps aux") + # print("=" * 70, file=sys.stderr) # NOQA + sys.stdout.flush() +if CI_TESTING: + print_sysinfo() + + def is_win_secure_system_proc(pid): # see: https://github.com/giampaolo/psutil/issues/2338 @memoize From 3e2c62b4e946653da6f9136ab5470b7611cf094a Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 16:59:23 +0200 Subject: [PATCH 60/77] progress 24 --- .github/workflows/build.yml | 4 ++-- Makefile | 3 +++ psutil/tests/__init__.py | 4 ---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e5c6fb1d8..448f51eda 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,7 +59,7 @@ jobs: CIBW_PRERELEASE_PYTHONS: True CIBW_TEST_EXTRAS: test CIBW_TEST_COMMAND: - make -C {project} setup-dev-env install test test-memleaks PYTHON="env python" PSUTIL_SCRIPTS_DIR={project}/scripts + make -C {project} PYTHON="env python" PSUTIL_SCRIPTS_DIR="{project}/scripts" setup-dev-env install print-sysinfo test test-memleaks - name: Upload wheels uses: actions/upload-artifact@v4 @@ -87,7 +87,7 @@ jobs: CIBW_BUILD: 'cp27-*' CIBW_TEST_EXTRAS: test CIBW_TEST_COMMAND: - make -C {project} setup-dev-env install test test-memleaks PYTHON="env python" PSUTIL_SCRIPTS_DIR={project}/scripts + make -C {project} PYTHON="env python" PSUTIL_SCRIPTS_DIR="{project}/scripts" setup-dev-env install print-sysinfo test test-memleaks steps: - uses: actions/checkout@v4 diff --git a/Makefile b/Makefile index 395e9dce8..555f41826 100644 --- a/Makefile +++ b/Makefile @@ -362,6 +362,9 @@ print-downloads: ## Print PYPI download statistics print-hashes: ## Prints hashes of files in dist/ directory $(PYTHON) scripts/internal/print_hashes.py dist/ +print-sysinfo: ## Prints system info + $(PYTHON) -c "from psutil.tests import print_sysinfo; print_sysinfo()" + # =================================================================== # Misc # =================================================================== diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 4744ac4ad..faa455bbd 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -1364,10 +1364,6 @@ def print_sysinfo(): sys.stdout.flush() -if CI_TESTING: - print_sysinfo() - - def is_win_secure_system_proc(pid): # see: https://github.com/giampaolo/psutil/issues/2338 @memoize From 6ac9233c66ef6e5d5ade75be1e4909429e9473cb Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 17:46:22 +0200 Subject: [PATCH 61/77] adjust test case for AARCH64 --- psutil/tests/test_posix.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/psutil/tests/test_posix.py b/psutil/tests/test_posix.py index d8b7000e9..79c7252d0 100755 --- a/psutil/tests/test_posix.py +++ b/psutil/tests/test_posix.py @@ -23,6 +23,7 @@ from psutil import OPENBSD from psutil import POSIX from psutil import SUNOS +from psutil.tests import AARCH64 from psutil.tests import HAS_NET_IO_COUNTERS from psutil.tests import PYTHON_EXE from psutil.tests import QEMU_USER @@ -288,7 +289,10 @@ def test_exe(self): def test_cmdline(self): ps_cmdline = ps_args(self.pid) psutil_cmdline = " ".join(psutil.Process(self.pid).cmdline()) - self.assertEqual(ps_cmdline, psutil_cmdline) + if AARCH64 and len(ps_cmdline) < len(psutil_cmdline): + self.assertTrue(psutil_cmdline.startswith(ps_cmdline)) + else: + self.assertEqual(ps_cmdline, psutil_cmdline) # On SUNOS "ps" reads niceness /proc/pid/psinfo which returns an # incorrect value (20); the real deal is getpriority(2) which From fe884c7a872bc5bce7816f00a72f978ee711b533 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 17:49:57 +0200 Subject: [PATCH 62/77] try running bsd tests --- .github/workflows/bsd.yml | 125 ++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 66 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 8182177c0..fdf40e771 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -1,67 +1,60 @@ -# # Execute tests on *BSD platforms. Does not produce wheels. -# # Useful URLs: -# # https://github.com/vmactions/freebsd-vm -# # https://github.com/vmactions/openbsd-vm -# # https://github.com/vmactions/netbsd-vm +# Execute tests on *BSD platforms. Does not produce wheels. +# Useful URLs: +# https://github.com/vmactions/freebsd-vm +# https://github.com/vmactions/openbsd-vm +# https://github.com/vmactions/netbsd-vm -# on: [push, pull_request] -# name: bsd-tests -# concurrency: -# group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || '' }} -# cancel-in-progress: true -# jobs: -# freebsd: -# runs-on: ubuntu-22.04 -# steps: -# - uses: actions/checkout@v4 -# - name: Run tests -# uses: vmactions/freebsd-vm@v1 -# with: -# usesh: true -# prepare: | -# pkg install -y gcc python3 -# run: | -# set -e -x -# make install-pip -# python3 -m pip install --user setuptools -# make install -# make test -# make test-memleaks -# openbsd: -# runs-on: ubuntu-22.04 -# steps: -# - uses: actions/checkout@v4 -# - name: Run tests -# uses: vmactions/openbsd-vm@v1 -# with: -# usesh: true -# prepare: | -# set -e -# pkg_add gcc python3 -# run: | -# set -e -# make install-pip -# python3 -m pip install --user setuptools -# make install -# make test -# make test-memleaks -# netbsd: -# runs-on: ubuntu-22.04 -# steps: -# - uses: actions/checkout@v4 -# - name: Run tests -# uses: vmactions/netbsd-vm@v1 -# with: -# usesh: true -# prepare: | -# set -e -# /usr/sbin/pkg_add -v pkgin -# pkgin update -# pkgin -y install python311-* py311-setuptools-* gcc12-* -# run: | -# set -e -# make install-pip PYTHON=python3.11 -# python3.11 -m pip install --user setuptools -# make install PYTHON=python3.11 -# make test PYTHON=python3.11 -# make test-memleaks PYTHON=python3.11 +on: [push, pull_request] +name: bsd-tests +concurrency: + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || '' }} + cancel-in-progress: true +jobs: + freebsd: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Run tests + uses: vmactions/freebsd-vm@v1 + with: + usesh: true + prepare: | + set -e + pkg install -y gcc python3 + run: | + set -e + make PYTHON=python3.11 setup-dev-env install test-memleaks + openbsd: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Run tests + uses: vmactions/openbsd-vm@v1 + with: + usesh: true + prepare: | + set -e + pkg_add gcc python3 + run: | + set -e + make install-pip + python3 -m pip install --user setuptools + make install + make test + make test-memleaks + netbsd: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Run tests + uses: vmactions/netbsd-vm@v1 + with: + usesh: true + prepare: | + set -e + /usr/sbin/pkg_add -v pkgin + pkgin update + pkgin -y install python311-* py311-setuptools-* gcc12-* + run: | + set -e + make PYTHON=python3.11 setup-dev-env install test-memleaks From 56c81f0c2ca8f9c91d7a7c449be5b29c94a7b78c Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 17:52:32 +0200 Subject: [PATCH 63/77] revert prev commit --- .github/workflows/bsd.yml | 125 ++++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 59 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index fdf40e771..8182177c0 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -1,60 +1,67 @@ -# Execute tests on *BSD platforms. Does not produce wheels. -# Useful URLs: -# https://github.com/vmactions/freebsd-vm -# https://github.com/vmactions/openbsd-vm -# https://github.com/vmactions/netbsd-vm +# # Execute tests on *BSD platforms. Does not produce wheels. +# # Useful URLs: +# # https://github.com/vmactions/freebsd-vm +# # https://github.com/vmactions/openbsd-vm +# # https://github.com/vmactions/netbsd-vm -on: [push, pull_request] -name: bsd-tests -concurrency: - group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || '' }} - cancel-in-progress: true -jobs: - freebsd: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - name: Run tests - uses: vmactions/freebsd-vm@v1 - with: - usesh: true - prepare: | - set -e - pkg install -y gcc python3 - run: | - set -e - make PYTHON=python3.11 setup-dev-env install test-memleaks - openbsd: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - name: Run tests - uses: vmactions/openbsd-vm@v1 - with: - usesh: true - prepare: | - set -e - pkg_add gcc python3 - run: | - set -e - make install-pip - python3 -m pip install --user setuptools - make install - make test - make test-memleaks - netbsd: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - name: Run tests - uses: vmactions/netbsd-vm@v1 - with: - usesh: true - prepare: | - set -e - /usr/sbin/pkg_add -v pkgin - pkgin update - pkgin -y install python311-* py311-setuptools-* gcc12-* - run: | - set -e - make PYTHON=python3.11 setup-dev-env install test-memleaks +# on: [push, pull_request] +# name: bsd-tests +# concurrency: +# group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || '' }} +# cancel-in-progress: true +# jobs: +# freebsd: +# runs-on: ubuntu-22.04 +# steps: +# - uses: actions/checkout@v4 +# - name: Run tests +# uses: vmactions/freebsd-vm@v1 +# with: +# usesh: true +# prepare: | +# pkg install -y gcc python3 +# run: | +# set -e -x +# make install-pip +# python3 -m pip install --user setuptools +# make install +# make test +# make test-memleaks +# openbsd: +# runs-on: ubuntu-22.04 +# steps: +# - uses: actions/checkout@v4 +# - name: Run tests +# uses: vmactions/openbsd-vm@v1 +# with: +# usesh: true +# prepare: | +# set -e +# pkg_add gcc python3 +# run: | +# set -e +# make install-pip +# python3 -m pip install --user setuptools +# make install +# make test +# make test-memleaks +# netbsd: +# runs-on: ubuntu-22.04 +# steps: +# - uses: actions/checkout@v4 +# - name: Run tests +# uses: vmactions/netbsd-vm@v1 +# with: +# usesh: true +# prepare: | +# set -e +# /usr/sbin/pkg_add -v pkgin +# pkgin update +# pkgin -y install python311-* py311-setuptools-* gcc12-* +# run: | +# set -e +# make install-pip PYTHON=python3.11 +# python3.11 -m pip install --user setuptools +# make install PYTHON=python3.11 +# make test PYTHON=python3.11 +# make test-memleaks PYTHON=python3.11 From d6bb787ef39f7ada9c4c7ba7bacd05fba7fcc207 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:00:58 +0200 Subject: [PATCH 64/77] add pytest-xdist dep on windows --- scripts/internal/winmake.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index 36a359798..b91bda7aa 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -45,12 +45,13 @@ "pyperf", "pyreadline", "pytest", + "pytest-xdist", "requests", "setuptools", "wheel", ] -if sys.version_info[0] < 3: +if not PY3: DEPS.append('mock') DEPS.append('ipaddress') DEPS.append('enum34') From 2e7ef43d7c206e907a74bd25c22e0791eb38b23e Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:07:29 +0200 Subject: [PATCH 65/77] try to fix winmake execution --- scripts/internal/winmake.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index b91bda7aa..3875edcb5 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -19,7 +19,6 @@ import errno import fnmatch import os -import shlex import shutil import site import ssl @@ -119,8 +118,6 @@ def win_colorprint(s, color=LIGHTBLUE): def sh(cmd, nolog=False): if not nolog: safe_print("cmd: " + cmd) - if isinstance(cmd, str): - cmd = shlex.split(cmd) p = subprocess.Popen( # noqa S602 cmd, shell=True, env=os.environ, cwd=os.getcwd() ) From 438d10e805963d1c56e36e1c1168f1d1558cc8b2 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:17:32 +0200 Subject: [PATCH 66/77] winmake refact --- appveyor.yml | 2 +- scripts/internal/winmake.py | 53 ++++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 70a4daec2..13798581e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,7 +36,6 @@ init: install: - "%WITH_COMPILER% %PYTHON%/python.exe -m pip --version" - - "%WITH_COMPILER% %PYTHON%/python.exe -m pip install --upgrade --user setuptools pip" - "%WITH_COMPILER% %PYTHON%/python.exe scripts/internal/winmake.py setup-dev-env" - "%WITH_COMPILER% %PYTHON%/python.exe -m pip freeze" - "%WITH_COMPILER% %PYTHON%/python.exe scripts/internal/winmake.py install" @@ -44,6 +43,7 @@ install: build: off test_script: + - "%WITH_COMPILER% %PYTHON%/python.exe scripts/internal/winmake.py print-sysinfo" - "%WITH_COMPILER% %PYTHON%/python.exe scripts/internal/winmake.py test" - "%WITH_COMPILER% %PYTHON%/python.exe scripts/internal/winmake.py test-memleaks" diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index 3875edcb5..b6b9e8b98 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -37,23 +37,36 @@ HERE = os.path.abspath(os.path.dirname(__file__)) ROOT_DIR = os.path.realpath(os.path.join(HERE, "..", "..")) PYPY = '__pypy__' in sys.builtin_module_names -DEPS = [ - "coverage", - "pdbpp", - "pip", - "pyperf", - "pyreadline", - "pytest", - "pytest-xdist", - "requests", - "setuptools", - "wheel", -] +# mandatory deps if not PY3: - DEPS.append('mock') - DEPS.append('ipaddress') - DEPS.append('enum34') + DEPS = [ + "setuptools", + "pytest", + "pytest-xdist", + ] +else: + DEPS = [ + "enum34", + "futures", + "ipaddress", + "mock==1.0.1", + "pytest-xdist", + "pytest==4.6.11", + "setuptools", + ] + +# deps for local development +if not APPVEYOR: + DEPS += [ + "coverage", + "pdbpp", + "pip", + "pyperf", + "pyreadline", + "requests", + "wheel", + ] if not PYPY: DEPS.append("pywin32") @@ -503,6 +516,15 @@ def print_api_speed(): sh("%s -Wa scripts\\internal\\print_api_speed.py" % PYTHON) +def print_sysinfo(): + """Print system info.""" + build() + sh( + "%s -c 'from psutil.tests import print_sysinfo; print_sysinfo()'" + % PYTHON + ) + + def download_appveyor_wheels(): """Download appveyor wheels.""" sh( @@ -561,6 +583,7 @@ def parse_args(): sp.add_parser('install-pip', help="install pip") sp.add_parser('print-access-denied', help="print AD exceptions") sp.add_parser('print-api-speed', help="benchmark all API calls") + sp.add_parser('print-sysinfo', help="print system info") sp.add_parser('setup-dev-env', help="install deps") test = sp.add_parser('test', help="[ARG] run tests") test_by_name = sp.add_parser('test-by-name', help=" run test by name") From 0e52a7397a00364ad5ca7dff78a398ef6f9167d5 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:19:22 +0200 Subject: [PATCH 67/77] winmake refact --- scripts/internal/winmake.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index b6b9e8b98..55740819a 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -520,7 +520,7 @@ def print_sysinfo(): """Print system info.""" build() sh( - "%s -c 'from psutil.tests import print_sysinfo; print_sysinfo()'" + '%s -c "from psutil.tests import print_sysinfo; print_sysinfo()"' % PYTHON ) From 3f246349a6bc52d754e3f682a89f4a5670baf6b5 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:19:53 +0200 Subject: [PATCH 68/77] winmake refact 2 --- scripts/internal/winmake.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index 55740819a..614b01837 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -519,10 +519,9 @@ def print_api_speed(): def print_sysinfo(): """Print system info.""" build() - sh( - '%s -c "from psutil.tests import print_sysinfo; print_sysinfo()"' - % PYTHON - ) + from psutil.tests import print_sysinfo + + print_sysinfo() def download_appveyor_wheels(): From 2e820486549d0a4fa64f1b40a33a3bf9170632ca Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:25:29 +0200 Subject: [PATCH 69/77] try to adjust insta-pip target --- scripts/internal/winmake.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index 614b01837..add2d8f7b 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -29,7 +29,6 @@ APPVEYOR = bool(os.environ.get('APPVEYOR')) PYTHON = sys.executable if APPVEYOR else os.getenv('PYTHON', sys.executable) -GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py" PY3 = sys.version_info[0] >= 3 PYTEST_ARGS = "-v -s --tb=short" if PY3: @@ -37,6 +36,11 @@ HERE = os.path.abspath(os.path.dirname(__file__)) ROOT_DIR = os.path.realpath(os.path.join(HERE, "..", "..")) PYPY = '__pypy__' in sys.builtin_module_names +if PY3: + GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py" +else: + GET_PIP_URL = "https://bootstrap.pypa.io/pip/2.7/get-pip.py" + # mandatory deps if not PY3: From 49ee3c9bbf9785485e0bc4fa3f35ab94d860be94 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:33:00 +0200 Subject: [PATCH 70/77] adjust deps --- scripts/internal/winmake.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index add2d8f7b..c7f7a0f74 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -43,7 +43,7 @@ # mandatory deps -if not PY3: +if PY3: DEPS = [ "setuptools", "pytest", @@ -51,7 +51,6 @@ ] else: DEPS = [ - "enum34", "futures", "ipaddress", "mock==1.0.1", @@ -65,7 +64,6 @@ DEPS += [ "coverage", "pdbpp", - "pip", "pyperf", "pyreadline", "requests", From dd608d96753fdfeae2080ebbab08b7f2e1bc7683 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:37:44 +0200 Subject: [PATCH 71/77] adjust deps --- scripts/internal/winmake.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index c7f7a0f74..f24eaa7de 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -51,6 +51,7 @@ ] else: DEPS = [ + "enum34", "futures", "ipaddress", "mock==1.0.1", From 4106c7b2b447660202edbc0e13c3a9cacdbc253f Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:42:11 +0200 Subject: [PATCH 72/77] disable bsd --- .github/workflows/bsd.yml | 136 +++++++++++++++++++----------------- scripts/internal/winmake.py | 2 + 2 files changed, 72 insertions(+), 66 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 8182177c0..147074f97 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -1,67 +1,71 @@ -# # Execute tests on *BSD platforms. Does not produce wheels. -# # Useful URLs: -# # https://github.com/vmactions/freebsd-vm -# # https://github.com/vmactions/openbsd-vm -# # https://github.com/vmactions/netbsd-vm +# Execute tests on *BSD platforms. Does not produce wheels. +# Useful URLs: +# https://github.com/vmactions/freebsd-vm +# https://github.com/vmactions/openbsd-vm +# https://github.com/vmactions/netbsd-vm -# on: [push, pull_request] -# name: bsd-tests -# concurrency: -# group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || '' }} -# cancel-in-progress: true -# jobs: -# freebsd: -# runs-on: ubuntu-22.04 -# steps: -# - uses: actions/checkout@v4 -# - name: Run tests -# uses: vmactions/freebsd-vm@v1 -# with: -# usesh: true -# prepare: | -# pkg install -y gcc python3 -# run: | -# set -e -x -# make install-pip -# python3 -m pip install --user setuptools -# make install -# make test -# make test-memleaks -# openbsd: -# runs-on: ubuntu-22.04 -# steps: -# - uses: actions/checkout@v4 -# - name: Run tests -# uses: vmactions/openbsd-vm@v1 -# with: -# usesh: true -# prepare: | -# set -e -# pkg_add gcc python3 -# run: | -# set -e -# make install-pip -# python3 -m pip install --user setuptools -# make install -# make test -# make test-memleaks -# netbsd: -# runs-on: ubuntu-22.04 -# steps: -# - uses: actions/checkout@v4 -# - name: Run tests -# uses: vmactions/netbsd-vm@v1 -# with: -# usesh: true -# prepare: | -# set -e -# /usr/sbin/pkg_add -v pkgin -# pkgin update -# pkgin -y install python311-* py311-setuptools-* gcc12-* -# run: | -# set -e -# make install-pip PYTHON=python3.11 -# python3.11 -m pip install --user setuptools -# make install PYTHON=python3.11 -# make test PYTHON=python3.11 -# make test-memleaks PYTHON=python3.11 +on: [push, pull_request] +name: bsd-tests +concurrency: + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || '' }} + cancel-in-progress: true +jobs: + empty-job: # here just so that I can comment the next jobs if I want to temporarily disable them + if: false + runs-on: ubuntu-22.04 + steps: + # freebsd: + # runs-on: ubuntu-22.04 + # steps: + # - uses: actions/checkout@v4 + # - name: Run tests + # uses: vmactions/freebsd-vm@v1 + # with: + # usesh: true + # prepare: | + # pkg install -y gcc python3 + # run: | + # set -e -x + # make install-pip + # python3 -m pip install --user setuptools + # make install + # make test + # make test-memleaks + # openbsd: + # runs-on: ubuntu-22.04 + # steps: + # - uses: actions/checkout@v4 + # - name: Run tests + # uses: vmactions/openbsd-vm@v1 + # with: + # usesh: true + # prepare: | + # set -e + # pkg_add gcc python3 + # run: | + # set -e + # make install-pip + # python3 -m pip install --user setuptools + # make install + # make test + # make test-memleaks + # netbsd: + # runs-on: ubuntu-22.04 + # steps: + # - uses: actions/checkout@v4 + # - name: Run tests + # uses: vmactions/netbsd-vm@v1 + # with: + # usesh: true + # prepare: | + # set -e + # /usr/sbin/pkg_add -v pkgin + # pkgin update + # pkgin -y install python311-* py311-setuptools-* gcc12-* + # run: | + # set -e + # make install-pip PYTHON=python3.11 + # python3.11 -m pip install --user setuptools + # make install PYTHON=python3.11 + # make test PYTHON=python3.11 + # make test-memleaks PYTHON=python3.11 diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index f24eaa7de..c8d3a0e88 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -48,6 +48,7 @@ "setuptools", "pytest", "pytest-xdist", + "wheel", ] else: DEPS = [ @@ -58,6 +59,7 @@ "pytest-xdist", "pytest==4.6.11", "setuptools", + "wheel", ] # deps for local development From 27ab0e69a1a9522d875b71ea3a8ac296ad447d5c Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:45:47 +0200 Subject: [PATCH 73/77] progress --- .github/workflows/bsd.yml | 110 +++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 147074f97..de04b5a5e 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -14,58 +14,58 @@ jobs: if: false runs-on: ubuntu-22.04 steps: - # freebsd: - # runs-on: ubuntu-22.04 - # steps: - # - uses: actions/checkout@v4 - # - name: Run tests - # uses: vmactions/freebsd-vm@v1 - # with: - # usesh: true - # prepare: | - # pkg install -y gcc python3 - # run: | - # set -e -x - # make install-pip - # python3 -m pip install --user setuptools - # make install - # make test - # make test-memleaks - # openbsd: - # runs-on: ubuntu-22.04 - # steps: - # - uses: actions/checkout@v4 - # - name: Run tests - # uses: vmactions/openbsd-vm@v1 - # with: - # usesh: true - # prepare: | - # set -e - # pkg_add gcc python3 - # run: | - # set -e - # make install-pip - # python3 -m pip install --user setuptools - # make install - # make test - # make test-memleaks - # netbsd: - # runs-on: ubuntu-22.04 - # steps: - # - uses: actions/checkout@v4 - # - name: Run tests - # uses: vmactions/netbsd-vm@v1 - # with: - # usesh: true - # prepare: | - # set -e - # /usr/sbin/pkg_add -v pkgin - # pkgin update - # pkgin -y install python311-* py311-setuptools-* gcc12-* - # run: | - # set -e - # make install-pip PYTHON=python3.11 - # python3.11 -m pip install --user setuptools - # make install PYTHON=python3.11 - # make test PYTHON=python3.11 - # make test-memleaks PYTHON=python3.11 +# freebsd: +# runs-on: ubuntu-22.04 +# steps: +# - uses: actions/checkout@v4 +# - name: Run tests +# uses: vmactions/freebsd-vm@v1 +# with: +# usesh: true +# prepare: | +# pkg install -y gcc python3 +# run: | +# set -e -x +# make install-pip +# python3 -m pip install --user setuptools +# make install +# make test +# make test-memleaks +# openbsd: +# runs-on: ubuntu-22.04 +# steps: +# - uses: actions/checkout@v4 +# - name: Run tests +# uses: vmactions/openbsd-vm@v1 +# with: +# usesh: true +# prepare: | +# set -e +# pkg_add gcc python3 +# run: | +# set -e +# make install-pip +# python3 -m pip install --user setuptools +# make install +# make test +# make test-memleaks +# netbsd: +# runs-on: ubuntu-22.04 +# steps: +# - uses: actions/checkout@v4 +# - name: Run tests +# uses: vmactions/netbsd-vm@v1 +# with: +# usesh: true +# prepare: | +# set -e +# /usr/sbin/pkg_add -v pkgin +# pkgin update +# pkgin -y install python311-* py311-setuptools-* gcc12-* +# run: | +# set -e +# make install-pip PYTHON=python3.11 +# python3.11 -m pip install --user setuptools +# make install PYTHON=python3.11 +# make test PYTHON=python3.11 +# make test-memleaks PYTHON=python3.11 From b3e33cdabdab3f24de942f1164725a714f7484b0 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:46:18 +0200 Subject: [PATCH 74/77] progress --- .github/workflows/bsd.yml | 110 +++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index de04b5a5e..15ab0acea 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -14,58 +14,58 @@ jobs: if: false runs-on: ubuntu-22.04 steps: -# freebsd: -# runs-on: ubuntu-22.04 -# steps: -# - uses: actions/checkout@v4 -# - name: Run tests -# uses: vmactions/freebsd-vm@v1 -# with: -# usesh: true -# prepare: | -# pkg install -y gcc python3 -# run: | -# set -e -x -# make install-pip -# python3 -m pip install --user setuptools -# make install -# make test -# make test-memleaks -# openbsd: -# runs-on: ubuntu-22.04 -# steps: -# - uses: actions/checkout@v4 -# - name: Run tests -# uses: vmactions/openbsd-vm@v1 -# with: -# usesh: true -# prepare: | -# set -e -# pkg_add gcc python3 -# run: | -# set -e -# make install-pip -# python3 -m pip install --user setuptools -# make install -# make test -# make test-memleaks -# netbsd: -# runs-on: ubuntu-22.04 -# steps: -# - uses: actions/checkout@v4 -# - name: Run tests -# uses: vmactions/netbsd-vm@v1 -# with: -# usesh: true -# prepare: | -# set -e -# /usr/sbin/pkg_add -v pkgin -# pkgin update -# pkgin -y install python311-* py311-setuptools-* gcc12-* -# run: | -# set -e -# make install-pip PYTHON=python3.11 -# python3.11 -m pip install --user setuptools -# make install PYTHON=python3.11 -# make test PYTHON=python3.11 -# make test-memleaks PYTHON=python3.11 +# freebsd: +# runs-on: ubuntu-22.04 +# steps: +# - uses: actions/checkout@v4 +# - name: Run tests +# uses: vmactions/freebsd-vm@v1 +# with: +# usesh: true +# prepare: | +# pkg install -y gcc python3 +# run: | +# set -e -x +# make install-pip +# python3 -m pip install --user setuptools +# make install +# make test +# make test-memleaks +# openbsd: +# runs-on: ubuntu-22.04 +# steps: +# - uses: actions/checkout@v4 +# - name: Run tests +# uses: vmactions/openbsd-vm@v1 +# with: +# usesh: true +# prepare: | +# set -e +# pkg_add gcc python3 +# run: | +# set -e +# make install-pip +# python3 -m pip install --user setuptools +# make install +# make test +# make test-memleaks +# netbsd: +# runs-on: ubuntu-22.04 +# steps: +# - uses: actions/checkout@v4 +# - name: Run tests +# uses: vmactions/netbsd-vm@v1 +# with: +# usesh: true +# prepare: | +# set -e +# /usr/sbin/pkg_add -v pkgin +# pkgin update +# pkgin -y install python311-* py311-setuptools-* gcc12-* +# run: | +# set -e +# make install-pip PYTHON=python3.11 +# python3.11 -m pip install --user setuptools +# make install PYTHON=python3.11 +# make test PYTHON=python3.11 +# make test-memleaks PYTHON=python3.11 From a33358b78f199241444defc31d6c12fe076d84c5 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:47:19 +0200 Subject: [PATCH 75/77] progress 2 --- .github/workflows/bsd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 15ab0acea..2b4ed483e 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -13,7 +13,7 @@ jobs: empty-job: # here just so that I can comment the next jobs if I want to temporarily disable them if: false runs-on: ubuntu-22.04 - steps: + # freebsd: # runs-on: ubuntu-22.04 # steps: From 40af359a4030f9e38edea9a7b66eb8a4ff6cb3e0 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:48:48 +0200 Subject: [PATCH 76/77] progress 3 --- .github/workflows/bsd.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 2b4ed483e..492daa023 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -13,6 +13,8 @@ jobs: empty-job: # here just so that I can comment the next jobs if I want to temporarily disable them if: false runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 # freebsd: # runs-on: ubuntu-22.04 From 52c1e5e1c2ce0892f04c201e30b67697aa2e09ed Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Oct 2024 21:49:59 +0200 Subject: [PATCH 77/77] progress --- .github/workflows/bsd.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 492daa023..cba937d00 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -10,7 +10,8 @@ concurrency: group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || '' }} cancel-in-progress: true jobs: - empty-job: # here just so that I can comment the next jobs if I want to temporarily disable them + # here just so that I can comment the next jobs to temporarily disable them + empty-job: if: false runs-on: ubuntu-22.04 steps: