From 445387f962cca21bb958fb208a93b15d1ed75aa7 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 22 Oct 2022 12:19:55 +0200 Subject: [PATCH 1/3] Drop Python 3.4 support Signed-off-by: mayeut --- README.rst | 2 +- docs/index.rst | 4 ++-- psutil/__init__.py | 4 ++-- psutil/_common.py | 2 +- psutil/_pslinux.py | 2 +- psutil/_psposix.py | 2 +- psutil/_pswindows.py | 2 +- psutil/tests/__init__.py | 5 +---- psutil/tests/test_contracts.py | 2 +- psutil/tests/test_system.py | 2 +- scripts/internal/print_announce.py | 2 +- scripts/internal/winmake.py | 9 ++++----- setup.py | 3 ++- 13 files changed, 19 insertions(+), 22 deletions(-) diff --git a/README.rst b/README.rst index 95a7f359f6..14975bcfab 100644 --- a/README.rst +++ b/README.rst @@ -98,7 +98,7 @@ psutil currently supports the following platforms: - **Sun Solaris** - **AIX** -Supported Python versions are **2.7**, **3.4+** and +Supported Python versions are **2.7**, **3.5+** and `PyPy `__. Funding diff --git a/docs/index.rst b/docs/index.rst index 669b8b4620..9dd8b0205f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -38,7 +38,7 @@ psutil currently supports the following platforms: - **Sun Solaris** - **AIX** -Supported Python versions are **2.7** and **3.4+**. +Supported Python versions are **2.7** and **3.5+**. `PyPy `__ is also known to work. The psutil documentation you're reading is distributed as a single HTML page. @@ -2632,7 +2632,7 @@ Platforms support history * psutil 0.1.1 (2009-03): **FreeBSD** * psutil 0.1.0 (2009-01): **Linux, Windows, macOS** -Supported Python versions are 2.7, 3.4+ and PyPy3. +Supported Python versions are 2.7, 3.5+ and PyPy3. Timeline ======== diff --git a/psutil/__init__.py b/psutil/__init__.py index 35a3c9ad59..f66790bf0f 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -17,7 +17,7 @@ - Sun Solaris - AIX -Works with Python versions 2.7 and 3.4+. +Works with Python versions 2.7 and 3.5+. """ from __future__ import division @@ -2189,7 +2189,7 @@ def net_if_addrs(): Note: you can have more than one address of the same family associated with each interface. """ - has_enums = sys.version_info >= (3, 4) + has_enums = sys.version_info[0] >= 3 if has_enums: import socket rawlist = _psplatform.net_if_addrs() diff --git a/psutil/_common.py b/psutil/_common.py index 63792edbd0..b9049e63a4 100644 --- a/psutil/_common.py +++ b/psutil/_common.py @@ -35,7 +35,7 @@ except ImportError: AF_UNIX = None -if sys.version_info >= (3, 4): +if sys.version_info[0] >= 3: import enum else: enum = None diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index d178fe1638..aaee9df86e 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -53,7 +53,7 @@ from ._compat import basestring -if sys.version_info >= (3, 4): +if sys.version_info[0] >= 3: import enum else: enum = None diff --git a/psutil/_psposix.py b/psutil/_psposix.py index 1d250bf75c..4cc63439c4 100644 --- a/psutil/_psposix.py +++ b/psutil/_psposix.py @@ -28,7 +28,7 @@ from . import _psutil_osx -if sys.version_info >= (3, 4): +if sys.version_info[0] >= 3: import enum else: enum = None diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py index 5a10efc5f7..eeabc81feb 100644 --- a/psutil/_pswindows.py +++ b/psutil/_pswindows.py @@ -56,7 +56,7 @@ else: raise -if sys.version_info >= (3, 4): +if sys.version_info[0] >= 3: import enum else: enum = None diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 521c3a612b..51b6279796 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -67,7 +67,7 @@ warnings.simplefilter("ignore") import mock # NOQA - requires "pip install mock" -if sys.version_info >= (3, 4): +if sys.version_info[0] >= 3: import enum else: enum = None @@ -1714,9 +1714,6 @@ def import_module_by_path(path): if sys.version_info[0] == 2: import imp return imp.load_source(name, path) - elif sys.version_info[:2] <= (3, 4): - from importlib.machinery import SourceFileLoader - return SourceFileLoader(name, path).load_module() else: import importlib.util spec = importlib.util.spec_from_file_location(name, path) diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py index 7f299a6243..b1a5af5665 100755 --- a/psutil/tests/test_contracts.py +++ b/psutil/tests/test_contracts.py @@ -723,7 +723,7 @@ def nice(self, ret, info): priorities = [getattr(psutil, x) for x in dir(psutil) if x.endswith('_PRIORITY_CLASS')] self.assertIn(ret, priorities) - if sys.version_info > (3, 4): + if sys.version_info[0] >= 3: self.assertIsInstance(ret, enum.IntEnum) else: self.assertIsInstance(ret, int) diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py index 0385a2b925..aba88be8d6 100755 --- a/psutil/tests/test_system.py +++ b/psutil/tests/test_system.py @@ -751,7 +751,7 @@ def test_net_if_addrs(self): self.assertIsInstance(addr.netmask, (str, type(None))) self.assertIsInstance(addr.broadcast, (str, type(None))) self.assertIn(addr.family, families) - if sys.version_info >= (3, 4) and not PYPY: + if sys.version_info[0] >= 3 and not PYPY: self.assertIsInstance(addr.family, enum.IntEnum) if nic_stats[nic].isup: # Do not test binding to addresses of interfaces diff --git a/scripts/internal/print_announce.py b/scripts/internal/print_announce.py index 510dc15f64..f33150f6df 100755 --- a/scripts/internal/print_announce.py +++ b/scripts/internal/print_announce.py @@ -47,7 +47,7 @@ nice, ionice, iostat, iotop, uptime, pidof, tty, taskset, pmap. It \ currently supports Linux, Windows, macOS, Sun Solaris, FreeBSD, OpenBSD, \ NetBSD and AIX, both 32-bit and 64-bit architectures. Supported Python \ -versions are 2.7 and 3.4+. PyPy is also known to work. +versions are 2.7 and 3.5+. PyPy is also known to work. What's new ========== diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index f92b2a8969..5ec2ecbfd2 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -54,14 +54,13 @@ "wheel", ] -if sys.version_info[:2] >= (3, 5): - DEPS.append('flake8-bugbear') -if sys.version_info[:2] <= (2, 7): +if sys.version_info[0] == 2: DEPS.append('mock') -if sys.version_info[:2] <= (3, 2): DEPS.append('ipaddress') -if sys.version_info[:2] <= (3, 4): DEPS.append('enum34') +else: + DEPS.append('flake8-bugbear') + if not PYPY: DEPS.append("pywin32") DEPS.append("wmi") diff --git a/setup.py b/setup.py index 2b8b2abb22..ce9afc7349 100755 --- a/setup.py +++ b/setup.py @@ -444,7 +444,8 @@ def main(): ) if setuptools is not None: kwargs.update( - python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", + python_requires=( + ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"), extras_require=extras_require, zip_safe=False, ) From 37a5ea45844b35a16447c457735a2d25d98c43f0 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 22 Apr 2023 13:03:21 +0200 Subject: [PATCH 2/3] Drop Python 3.5 support Signed-off-by: mayeut --- README.rst | 2 +- docs/index.rst | 4 ++-- psutil/__init__.py | 2 +- scripts/internal/print_announce.py | 2 +- setup.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 14975bcfab..7c7408a591 100644 --- a/README.rst +++ b/README.rst @@ -98,7 +98,7 @@ psutil currently supports the following platforms: - **Sun Solaris** - **AIX** -Supported Python versions are **2.7**, **3.5+** and +Supported Python versions are **2.7**, **3.6+** and `PyPy `__. Funding diff --git a/docs/index.rst b/docs/index.rst index 9dd8b0205f..6b0408dea8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -38,7 +38,7 @@ psutil currently supports the following platforms: - **Sun Solaris** - **AIX** -Supported Python versions are **2.7** and **3.5+**. +Supported Python versions are **2.7** and **3.6+**. `PyPy `__ is also known to work. The psutil documentation you're reading is distributed as a single HTML page. @@ -2632,7 +2632,7 @@ Platforms support history * psutil 0.1.1 (2009-03): **FreeBSD** * psutil 0.1.0 (2009-01): **Linux, Windows, macOS** -Supported Python versions are 2.7, 3.5+ and PyPy3. +Supported Python versions are 2.7, 3.6+ and PyPy3. Timeline ======== diff --git a/psutil/__init__.py b/psutil/__init__.py index f66790bf0f..7e36e4fb6e 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -17,7 +17,7 @@ - Sun Solaris - AIX -Works with Python versions 2.7 and 3.5+. +Works with Python versions 2.7 and 3.6+. """ from __future__ import division diff --git a/scripts/internal/print_announce.py b/scripts/internal/print_announce.py index f33150f6df..33fca4220d 100755 --- a/scripts/internal/print_announce.py +++ b/scripts/internal/print_announce.py @@ -47,7 +47,7 @@ nice, ionice, iostat, iotop, uptime, pidof, tty, taskset, pmap. It \ currently supports Linux, Windows, macOS, Sun Solaris, FreeBSD, OpenBSD, \ NetBSD and AIX, both 32-bit and 64-bit architectures. Supported Python \ -versions are 2.7 and 3.5+. PyPy is also known to work. +versions are 2.7 and 3.6+. PyPy is also known to work. What's new ========== diff --git a/setup.py b/setup.py index ce9afc7349..35467e131a 100755 --- a/setup.py +++ b/setup.py @@ -445,7 +445,7 @@ def main(): if setuptools is not None: kwargs.update( python_requires=( - ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"), + ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"), extras_require=extras_require, zip_safe=False, ) From 44d5b64ba3a0375526928632af8450208096c79d Mon Sep 17 00:00:00 2001 From: mayeut Date: Mon, 31 Jul 2023 09:39:24 +0200 Subject: [PATCH 3/3] use PY3 Signed-off-by: mayeut --- psutil/__init__.py | 2 +- psutil/_common.py | 7 ++++--- psutil/_pslinux.py | 2 +- psutil/_psposix.py | 2 +- psutil/_pswindows.py | 2 +- psutil/tests/__init__.py | 2 +- psutil/tests/test_contracts.py | 4 ++-- psutil/tests/test_system.py | 3 ++- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/psutil/__init__.py b/psutil/__init__.py index 7e36e4fb6e..2b15670658 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -2189,7 +2189,7 @@ def net_if_addrs(): Note: you can have more than one address of the same family associated with each interface. """ - has_enums = sys.version_info[0] >= 3 + has_enums = _PY3 if has_enums: import socket rawlist = _psplatform.net_if_addrs() diff --git a/psutil/_common.py b/psutil/_common.py index b9049e63a4..a0d49d6384 100644 --- a/psutil/_common.py +++ b/psutil/_common.py @@ -35,14 +35,15 @@ except ImportError: AF_UNIX = None -if sys.version_info[0] >= 3: + +# can't take it from _common.py as this script is imported by setup.py +PY3 = sys.version_info[0] == 3 +if PY3: import enum else: enum = None -# can't take it from _common.py as this script is imported by setup.py -PY3 = sys.version_info[0] == 3 PSUTIL_DEBUG = bool(os.getenv('PSUTIL_DEBUG')) _DEFAULT = object() diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index aaee9df86e..e0acb0e297 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -53,7 +53,7 @@ from ._compat import basestring -if sys.version_info[0] >= 3: +if PY3: import enum else: enum = None diff --git a/psutil/_psposix.py b/psutil/_psposix.py index 4cc63439c4..0039daf44a 100644 --- a/psutil/_psposix.py +++ b/psutil/_psposix.py @@ -28,7 +28,7 @@ from . import _psutil_osx -if sys.version_info[0] >= 3: +if PY3: import enum else: enum = None diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py index eeabc81feb..eec2db84db 100644 --- a/psutil/_pswindows.py +++ b/psutil/_pswindows.py @@ -56,7 +56,7 @@ else: raise -if sys.version_info[0] >= 3: +if PY3: import enum else: enum = None diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 51b6279796..0781f06862 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -67,7 +67,7 @@ warnings.simplefilter("ignore") import mock # NOQA - requires "pip install mock" -if sys.version_info[0] >= 3: +if PY3: import enum else: enum = None diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py index b1a5af5665..e0bb92ce56 100755 --- a/psutil/tests/test_contracts.py +++ b/psutil/tests/test_contracts.py @@ -15,7 +15,6 @@ import platform import signal import stat -import sys import time import traceback import unittest @@ -36,6 +35,7 @@ from psutil._compat import long from psutil._compat import range from psutil._compat import unicode +from psutil._compat import PY3 from psutil.tests import APPVEYOR from psutil.tests import CI_TESTING from psutil.tests import GITHUB_ACTIONS @@ -723,7 +723,7 @@ def nice(self, ret, info): priorities = [getattr(psutil, x) for x in dir(psutil) if x.endswith('_PRIORITY_CLASS')] self.assertIn(ret, priorities) - if sys.version_info[0] >= 3: + if PY3: self.assertIsInstance(ret, enum.IntEnum) else: self.assertIsInstance(ret, int) diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py index aba88be8d6..3f96762947 100755 --- a/psutil/tests/test_system.py +++ b/psutil/tests/test_system.py @@ -32,6 +32,7 @@ from psutil import WINDOWS from psutil._compat import FileNotFoundError from psutil._compat import long +from psutil._compat import PY3 from psutil.tests import ASCII_FS from psutil.tests import CI_TESTING from psutil.tests import DEVNULL @@ -751,7 +752,7 @@ def test_net_if_addrs(self): self.assertIsInstance(addr.netmask, (str, type(None))) self.assertIsInstance(addr.broadcast, (str, type(None))) self.assertIn(addr.family, families) - if sys.version_info[0] >= 3 and not PYPY: + if PY3 and not PYPY: self.assertIsInstance(addr.family, enum.IntEnum) if nic_stats[nic].isup: # Do not test binding to addresses of interfaces