-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop Python 2.6 support in unit tests and scripts, deprecate it in psutil #1053
Comments
…ll raise a deprecation warning on import
Here's the pip installs for psutil from PyPI for the last month, showing relatively low numbers for 2.6.
Python 3.3 also went EOL and has even lower numbers, so you could consider dropping that too. However, there's not as great a benefit as in dropping 2.6. |
Thanks a lot for this. I will definitively drop support for 3.3 as well then. I had no idea download numbers were so big. |
psutil was the 42nd most-pip-installed from PyPI over the last month!
|
* 'pslisten' of github.com:nlevitt/psutil: (922 commits) Update INSTALL.rst Pass python_requires argument to setuptools (giampaolo#1208) giampaolo#1152: fix doc to mention CLI command necessary to enable disk_io_counters() on win pre release pre release pre release pre-release fix giampaolo#1201: document that timeout kwarg is expressed in seconds Add mount points to disk_partitions() in Windows (giampaolo#775) (giampaolo#1192) add test for cpu_affinity what a stupid bug! (giampaolo#1190) update doc pre release pre-release; also get rid of PSUTIL_DEBUG doc instructions (it's kinda useless for the user after all) Use FutureWarning instead of DeprecationWarning (giampaolo#1188) fix test refactor environ() test Fix OSX pid 0 bug (giampaolo#1187) change assert in test refactor Process.__repr__ Faster Process.children(recursive=True) (giampaolo#1186) Speedup Process.children() (giampaolo#1185) update doc update HISTORY fix giampaolo#1179 / linux / cmdline: handle processes erroneously overwriting /proc/pid/cmdline by using spaces instead of null bytes as args separator set x bit to test_aix.py fix giampaolo#1181: raise AD if task_for_pid() fails with 5 and errno == ENOENT fix posix failure Arguments for NoSuchProcess and AccessDenied for the C ext (giampaolo#1180) fix travis failure https://travis-ci.org/giampaolo/psutil/jobs/306424509 be smarter in searching python exe do not test platf specific modules on wheelhouse try to fix travis failure fix travis failures try to use PYTHON_EXE instead of sys.executable giampaolo#1177: give credits to @wiggin15 OSX: implement sensors_battery (giampaolo#1177) improve error msg for old windows systems giampaolo#811 add debug messages do not mention apt-get as method of installation as it's not recommended syntax highlight in doc files syntax highlight in doc files fix doc indentation 1173 debug mode (giampaolo#1176) code style update MANIFEST giampaolo#1174: use TimeoutExpired in wait_pid() sort imports by name Move exceptions to separate file (giampaolo#1174) appveyor: enable python warnings when running tests refactor winmake.py use a C global variable to figure out whether we're in testing mode fix unicode err define a setup() function which is called on import by all C modules move PyUnicode compt fun definition up in the file rename C func re-enable test on appveyor; remove unused C code refactor PSUTIL_TESTING C APIs inspect PSUTIL_TESTING env var from C again giampaolo#1152: (DeviceIOControl), skip disk on ERROR_INVALID_FUNCTION and ERROR_NOT_SUPPORTED giampaolo#1152 / win / disk_io_counters(): DeviceIOControl errors were ignored; che return value and retry call on ERROR_INSUFFICIENT_BUFFER upgrade dist cmds change make cmds disable IPv6 tests if IPv6 is not supported travis / OSX: run py 3.6 instead of 3.4 fix giampaolo#1169: (Linux) users() hostname returns username instead update README, bump up version get rid of PSUTIL_TESTING env var: it must be necessarily set from cmdline, hence 'python -m psutil.tests' won't work out of the box try to set PSUTIL_TESTING env var from python before failing skip cpu_freq tests if not available (giampaolo#1170) update doc pre-release giampaolo#1053: drop python 3.3 support try to fix appveyor failure; also refactor generate_manifest.py giampaolo#1167 give CREDITS to @matray Including non-unicast packets in packet count calculation (giampaolo#1167) fix giampaolo#1166 (doc mistake) provide a 'make help' command ifconfig.py humanize bytes try to limit false positives on appveyor/windows reap_children() in a finally block in order to limit false positives unicode tests: use different name for test dir fix failure on osx/travis update Makefile fix test giampaolo#1164 give CREDITS to @wiggin15 AIX: implement num_ctx_switches (giampaolo#1164) use new PYTHON_EXE improve logic to determine python exe location add DEVNOTES file; move TODO.aix into _psutil_aix.c Fix test_emulate_energy_full_not_avail (giampaolo#1163) update README try to limit occasional appveyor failure Remove trove classifiers for untested and unsupported platforms (giampaolo#1162) Fix giampaolo#1154: remove 'threads' method on older AIX (giampaolo#1156) give CREDITS to @adpag for giampaolo#1159, giampaolo#1160 and giampaolo#1161 Fix test asserts due to leftover test subprocesses (giampaolo#1161) Fix network tests for newer ifconfig versions. (giampaolo#1160) Fix pre-commit hook for python 3.x. (giampaolo#1159) revert last commit ...
Stats from last month:
|
Signed-off-by: Giampaolo Rodola <[email protected]>
About dropping Python 2.7 support, 3 years ago [I stated](#2014 (comment)): > [...] not a chance, for many years to come. [Python 2.7] currently represents 7-10% of total downloads, aka around 70k /100k downloads per day 3 years later (and to my surprise) **downloads for Python 2.7 dropped to 0.36%**. These are downloads per month: ``` $ pypinfo --percent psutil pyversion Served from cache: False Data processed: 4.65 GiB Data billed: 4.65 GiB Estimated cost: $0.03 | python_version | percent | download_count | | -------------- | ------- | -------------- | | 3.10 | 23.84% | 26,354,506 | | 3.8 | 18.87% | 20,862,015 | | 3.7 | 17.38% | 19,217,960 | | 3.9 | 17.00% | 18,798,843 | | 3.11 | 13.63% | 15,066,706 | | 3.12 | 7.01% | 7,754,751 | | 3.13 | 1.15% | 1,267,008 | | 3.6 | 0.73% | 803,189 | | 2.7 | 0.36% | 402,111 | | 3.5 | 0.03% | 28,656 | | Total | | 110,555,745 | ``` According to [pypistats.org](https://archive.is/wip/knzql) it's 0.28% of the total, and around 15.000 downloads per day. Maintaining 2.7 support has become increasingly difficult, but still possible. E.g. we can still run tests by using [old PYPI backports](https://github.com/giampaolo/psutil/blob/fbb6d9ce98f930d3d101b7df5a4f4d0f1d2b35a3/setup.py#L76-L85). GitHub Actions can still be [tweaked](https://github.com/giampaolo/psutil/blob/fbb6d9ce98f930d3d101b7df5a4f4d0f1d2b35a3/.github/workflows/build.yml#L77-L112) to run tests and produce wheels on Linux and macOS. Not Windows though, for which we have to use a separate service (Appveyor). Still, the amount of hacks in psutil source code necessary to support Python 2.7 piled up over the years, and became quite big. Some disadvantages that come to mind: * (high) having to maintain various python compatibility layers (e.g. [psutil/_compat.py](https://github.com/giampaolo/psutil/blob/fbb6d9ce98f930d3d101b7df5a4f4d0f1d2b35a3/psutil/_compat.py#L1)) + all the compromises that come with it (extra imports, extra code, str vs. unicode differences, etc.) * (medium) having to maintain a C compatibility layer (`#if PY_MAJOR_VERSION <= 3`, etc.) * (medium) inability to use modern language features, especially f-strings * (low) inability to freely use `enum`s, which creates a difference on how CONSTANTS are exposed in terms of API * (medium) having to install a specific version of pip and other (outdated) [deps](https://github.com/giampaolo/psutil/blob/fbb6d9ce98f930d3d101b7df5a4f4d0f1d2b35a3/setup.py#L76-L85) * (high) relying on third-party Appveyor CI service, just to run tests on python 2.7 and produce wheels, when we could rely on a single CI service instead (GitHub) * (high) soon I want to distribute wheels via GitHub instead of manually via `twine`, so that'll be a problem (CC @potiuk) * (high) gradual lack of support from third-party libraries and services * (medium) 4 extra CI jobs which are run on every commit (Linux, macOS, Windows 32-bit, Windows 64-bit) * (medium) the distribution of 7 wheels specific for Python 2.7. From last release: * psutil-6.1.1-cp27-cp27m-macosx_10_9_x86_64.whl * psutil-6.1.1-cp27-none-win32.whl * psutil-6.1.1-cp27-none-win_amd64.whl * psutil-6.1.1-cp27-cp27m-manylinux2010_i686.whl * psutil-6.1.1-cp27-cp27m-manylinux2010_x86_64.whl * psutil-6.1.1-cp27-cp27mu-manylinux2010_i686.whl * psutil-6.1.1-cp27-cp27mu-manylinux2010_x86_64.whl * etc. As such I decided to finally **drop support for Python 2.7**. Current psutil 6.1.1 release will still support Python 2.7, but next 7.0.0 will not. We can still make a promise that the 6.1.* line (EDIT: see [python2 branch](https://github.com/giampaolo/psutil/tree/python2)) will keep supporting Python 2.7 and will **receive critical bug-fixes only** (no new features). In 7.0.0 we can keep the [setup.py](https://github.com/giampaolo/psutil/blob/fbb6d9ce98f930d3d101b7df5a4f4d0f1d2b35a3/setup.py) script compatible with Python 2.7 in terms of syntax, so that it can emit an informative error message on pip install. E.g. the user will see something like this: ``` $ pip2 install psutil As of version 7.0.0 psutil no longer supports Python 2.7. Latest version supporting Python 2.7 is psutil 6.1.X. Install it with: "pip2 install psutil==6.1.*". ``` Related tickets: * 2017-06: #1053 * 2022-04: #2099 * 2023-04: #2246 * giampaolo/pyftpdlib#635
Maintaining Python 2.6 support is a pain in the butt from a CI / testing perspective for a variety of reason (unittest2, a specific version of mock, setuptools, etc.). Also, both pip and setuptools dropped support for 2.6, so installing psutil on 2.6 is becoming harder (although still possible). For these reasons I would like to drop python 2.6 for tests only.
There is an argument for not dropping 2.6 support in psutil "as a lib" (so excluding tests) yet: CentOS 6. CentOS 6 still ships 2.6 by default and AFAIK it is still in use on a non negligible number of servers (unfortunately). Being psutil a "system library" I am kind of worried about that so I think it'd be nice to keep support for a little while longer and just deprecate it by issuing a warning on import.
CentOS 6 EOL is scheduled for November 2020. I am not sure I want to maintain support 'till then, but the point is that there currently are no 2.7-only features such as set literals, set/dict comprehensions, multiple ctx managers or OrderedDict which I may want to use in psutil code, so why break it?
On the other hand, some of those 2.7-only features may be used in the test suite (e.g. replace
contextlib.nexted
with multiple ctx managers). As far as 2.6 goes I would still like travis to test it by installing psutil on 2.6 and import it (that's it), but the test suite will not be run.At the same time,
setup.py
may print a warning telling that 2.6 is supported but not testable.As for scripts (/scripts dir): we can also drop support (and e.g. be free to use the
argparse
module).TODOs:
The text was updated successfully, but these errors were encountered: