Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/giampaolo/psutil
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/giampaolo/psutil:
  add windows test for free physical mem giampaolo#2074
  fix OSX tests broken by accident
  update HISTORY + give CREDITS for @arossert, @smoofra, @mayeut for giampaolo#2102, giampaolo#2156, giampaolo#2010
  build fix for Mac OS, Apple Silicon (giampaolo#2010)
  Linux: fix missing SPEED_UNKNOWN definition (giampaolo#2156)
  Use system-level values for Windows virtual memory (giampaolo#2077)
  feature: use ABI3 for cp36+ (giampaolo#2102)
  fix py2 compatibility
  improve API speed benchmark script giampaolo#2102
  fix: linter issues from giampaolo#2146 (giampaolo#2155)
  chore: skip test_cpu_freq on macOS arm64 (giampaolo#2146)
  pre-release + give CREDITS to @mayeut (PR giampaolo#2040) and @eallrich (new supporter)
  Fix a typo (giampaolo#2047)
  move isort and coverage config into pyproject.toml
  fix giampaolo#2021, fix giampaolo#1954, provide OSX arm64 bins + add pyproject.toml (giampaolo#2040)
  refactor git_log.py
  • Loading branch information
ddelange committed Oct 28, 2022
2 parents 6148cde + 8e4099d commit 201f8a5
Show file tree
Hide file tree
Showing 26 changed files with 359 additions and 139 deletions.
32 changes: 0 additions & 32 deletions .coveragerc

This file was deleted.

34 changes: 15 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
tag: ${{ github.run_id }}
generateReleaseNotes: true
# Linux + macOS + Windows CPython 3.6+
cp36:
name: cp36+, ${{ matrix.os }}, ${{ matrix.archs }}
py3:
name: py3, ${{ matrix.os }}, ${{ matrix.archs }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
if: matrix.archs == 'aarch64'

- name: Run tests
uses: pypa/cibuildwheel@v2.10.2
uses: pypa/cibuildwheel@v2.11.1
with:
config-file: "./cibuildwheel.toml"
env:
Expand Down Expand Up @@ -101,15 +101,15 @@ jobs:
# Windows cp37+ tests
# psutil tests do not like running from a virtualenv with python>=3.7 so
# not using cibuildwheel for those. run them "manually" with this job.
windows-cp3-test:
name: windows tests ${{ matrix.python }} ${{ matrix.architecture }}
needs: cp36
windows-py3-test:
name: windows-py3-test-${{ matrix.python }}-${{ matrix.architecture }}
needs: py3
runs-on: windows-2019
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11-dev"]
python: ["3.7", "3.8", "3.9", "3.10", "~3.11.0-0"]
architecture: ["x86", "x64"]

steps:
Expand All @@ -118,7 +118,7 @@ jobs:
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python }}"
architecture: "${{ matrix.architecture }}"
Expand All @@ -141,9 +141,9 @@ jobs:
python ../psutil/tests/test_memleaks.py
shell: bash

# Linux + macOS + CPython 2.7 & 3.5
linux-macos-cp27-cp35:
name: cp27/cp35, ${{ matrix.os }}
# Linux + macOS + Python 2
linux-macos-py2:
name: ${{ matrix.os }}-py2
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
Expand All @@ -155,8 +155,7 @@ jobs:
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
CIBW_TEST_EXTRAS: test
CIBW_BUILD: 'cp27-* cp35-*'
CIBW_SKIP: 'cp35-macosx_x86_64'
CIBW_BUILD: 'cp27-*'

steps:
- name: Cancel previous runs
Expand All @@ -171,11 +170,8 @@ jobs:
cache: pip
cache-dependency-path: .github/workflows/build.yml

- name: Install cibuildwheel
run: pip install cibuildwheel==1.12.0

- name: Run tests
run: cibuildwheel .
uses: pypa/cibuildwheel@v1.12.0

- name: Create wheels
uses: actions/upload-artifact@v3
Expand All @@ -202,7 +198,7 @@ jobs:
gh-pages:
# only run when action-gh-release ran
if: github.event_name == 'release' || github.event_name == 'push'
needs: [cp36, linux-macos-cp27-cp35]
needs: [py3, linux-macos-py2]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
Expand Down Expand Up @@ -262,6 +258,6 @@ jobs:
# py3
python3 -m pip install flake8 isort
python3 -m flake8 .
python3 -m isort --settings=.isort.cfg .
python3 -m isort .
# clinter
find . -type f \( -iname "*.c" -o -iname "*.h" \) | xargs python3 scripts/internal/clinter.py
7 changes: 0 additions & 7 deletions .isort.cfg

This file was deleted.

14 changes: 13 additions & 1 deletion CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ I: 1956

N: Matthieu Darbois
W: https://github.com/mayeut
I: 2039, 2142, 2147, 2153
I: 2039, 2142, 2147, 2153, 2040, 2102

N: Hugo van Kemenade
W: https://github.com/hugovk
Expand All @@ -801,3 +801,15 @@ I: 2135

N: Daniel Li
I: 2150

N: Daniel Widdis
W: https://github.com/dbwiddis
I: 2077

N: Amir Rossert
W: https://github.com/arossert
I: 2156

N: Lawrence D'Anna
W: https://github.com/smoofra
I: 2010
27 changes: 26 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
*Bug tracker at https://github.com/giampaolo/psutil/issues*

5.9.3 (IN DEVELOPMENT)
5.9.4 (IN DEVELOPMENT)
======================

XXXX-XX-XX

**Enhancements**

- 2102_: use Limited API when building wheels with CPython 3.6+ on Linux,
macOS and Windows. This allows to use pre-built wheels in all future versions
of cPython 3. (patch by Matthieu Darbois)

**Bug fixes**

- 2077_, [Windows]: Use system-level values for `virtual_memory()`_. (patch by
Daniel Widdis)
- 2156_, [Linux]: compilation may fail on very old gcc compilers due to missing
``SPEED_UNKNOWN`` definition. (patch by Amir Rossert)
- 2010_, [macOS]: on MacOS, arm64 ``IFM_1000_TX`` and ``IFM_1000_T`` are the
same value, causing a build failure. (patch by Lawrence D'Anna)

5.9.3
=====

2022-10-18

**Enhancements**

- 2040_, [macOS]: provide wheels for arm64 architecture. (patch by Matthieu
Darbois)

**Bug fixes**

- 2116_, [macOS], [critical]: `psutil.net_connections`_ fails with RuntimeError.
Expand Down
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
include .coveragerc
include .flake8
include .gitignore
include .isort.cfg
include CONTRIBUTING.md
include CREDITS
include HISTORY.rst
Expand Down Expand Up @@ -123,6 +121,7 @@ include psutil/tests/test_system.py
include psutil/tests/test_testutils.py
include psutil/tests/test_unicode.py
include psutil/tests/test_windows.py
include pyproject.toml
include scripts/battery.py
include scripts/cpu_distribution.py
include scripts/disk_usage.py
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TSCRIPT = psutil/tests/runner.py

# Internal.
DEPS = \
git+https://github.com/PyCQA/autoflake.git \
autoflake \
autopep8 \
check-manifest \
concurrencytest \
Expand Down Expand Up @@ -195,7 +195,7 @@ flake8: ## Run flake8 linter.
@git ls-files '*.py' | xargs $(PYTHON) -m flake8 --config=.flake8

isort: ## Run isort linter.
@git ls-files '*.py' | xargs $(PYTHON) -m isort --settings=.isort.cfg --check-only
@git ls-files '*.py' | xargs $(PYTHON) -m isort --check-only

c-linter: ## Run C linter.
@git ls-files '*.c' '*.h' | xargs $(PYTHON) scripts/internal/clinter.py
Expand All @@ -214,7 +214,7 @@ fix-flake8: ## Run autopep8, fix some Python flake8 / pep8 issues.
@git ls-files '*.py' | xargs $(PYTHON) -m autoflake --in-place --jobs 0 --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys

fix-imports: ## Fix imports with isort.
@git ls-files '*.py' | xargs $(PYTHON) -m isort --settings=.isort.cfg
@git ls-files '*.py' | xargs $(PYTHON) -m isort

fix-all: ## Run all code fixers.
${MAKE} fix-flake8
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ Supporters
<a href="https://github.com/PySimpleGUI"><img height="40" width="40" title="PySimpleGUI" src="https://avatars.githubusercontent.com/u/46163555?v=4" /></a>
<a href="https://github.com/u93"><img height="40" width="40" title="Eugenio E Breijo" src="https://avatars.githubusercontent.com/u/16807302?v=4" /></a>
<a href="https://github.com/guilt"><img height="40" width="40" title="Karthik Kumar Viswanathan" src="https://avatars.githubusercontent.com/u/195178?v=4" /></a>
<a href="https://github.com/eallrich"><img height="40" width="40" title="Evan Allrich" src="https://avatars.githubusercontent.com/u/17393?v=4" /></a>

</div>
<sup><a href="https://github.com/sponsors/giampaolo">add your avatar</a></sup>
Expand Down Expand Up @@ -241,7 +242,7 @@ Disks
>>> psutil.disk_partitions()
[sdiskpart(device='/dev/sda1', mountpoint='/', fstype='ext4', opts='rw,nosuid', maxfile=255, maxpath=4096),
sdiskpart(device='/dev/sda2', mountpoint='/home', fstype='ext, opts='rw', maxfile=255, maxpath=4096)]
sdiskpart(device='/dev/sda2', mountpoint='/home', fstype='ext', opts='rw', maxfile=255, maxpath=4096)]
>>>
>>> psutil.disk_usage('/')
sdiskusage(total=21378641920, used=4809781248, free=15482871808, percent=22.5)
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3036,4 +3036,3 @@ Timeline
.. _`threading.Thread`: https://docs.python.org/3/library/threading.html#threading.Thread
.. _Tidelift security contact: https://tidelift.com/security
.. _Tidelift Subscription: https://tidelift.com/subscription/pkg/pypi-psutil?utm_source=pypi-psutil&utm_medium=referral&utm_campaign=readme
.. _Tidelift Subscription: https://tidelift.com/subscription/pkg/pypi-psutil?utm_source=pypi-psutil&utm_medium=referral&utm_campaign=readme
2 changes: 1 addition & 1 deletion psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
AF_LINK = _psplatform.AF_LINK

__author__ = "Giampaolo Rodola'"
__version__ = "5.9.3"
__version__ = "5.9.4"
version_info = tuple([int(num) for num in __version__.split('.')])

_timer = getattr(time, 'monotonic', time.time)
Expand Down
3 changes: 2 additions & 1 deletion psutil/_psposix.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import sys
import time

from ._common import MACOS
from ._common import TimeoutExpired
from ._common import memoize
from ._common import sdiskusage
from ._common import usage_percent
from ._common import MACOS
from ._compat import PY3
from ._compat import ChildProcessError
from ._compat import FileNotFoundError
Expand All @@ -23,6 +23,7 @@
from ._compat import ProcessLookupError
from ._compat import unicode


if MACOS:
from . import _psutil_osx

Expand Down
24 changes: 15 additions & 9 deletions psutil/_psutil_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ static const int NCPUS_START = sizeof(unsigned long) * CHAR_BIT;
#endif


#ifndef SPEED_UNKNOWN
#define SPEED_UNKNOWN -1
#endif


#if PSUTIL_HAVE_IOPRIO
enum {
IOPRIO_WHO_PROCESS = 1,
Expand Down Expand Up @@ -296,21 +301,26 @@ psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args) {
cpu_set_t cpu_set;
size_t len;
pid_t pid;
int i, seq_len;
Py_ssize_t i, seq_len;
PyObject *py_cpu_set;

if (!PyArg_ParseTuple(args, _Py_PARSE_PID "O", &pid, &py_cpu_set))
return NULL;

if (!PySequence_Check(py_cpu_set)) {
PyErr_Format(PyExc_TypeError, "sequence argument expected, got %R", Py_TYPE(py_cpu_set));
goto error;
return PyErr_Format(PyExc_TypeError, "sequence argument expected, got %R", Py_TYPE(py_cpu_set));
}

seq_len = PySequence_Size(py_cpu_set);
if (seq_len < 0) {
return NULL;
}
CPU_ZERO(&cpu_set);
for (i = 0; i < seq_len; i++) {
PyObject *item = PySequence_GetItem(py_cpu_set, i);
if (!item) {
return NULL;
}
#if PY_MAJOR_VERSION >= 3
long value = PyLong_AsLong(item);
#else
Expand All @@ -320,21 +330,17 @@ psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args) {
if ((value == -1) || PyErr_Occurred()) {
if (!PyErr_Occurred())
PyErr_SetString(PyExc_ValueError, "invalid CPU value");
goto error;
return NULL;
}
CPU_SET(value, &cpu_set);
}

len = sizeof(cpu_set);
if (sched_setaffinity(pid, len, &cpu_set)) {
PyErr_SetFromErrno(PyExc_OSError);
goto error;
return PyErr_SetFromErrno(PyExc_OSError);
}

Py_RETURN_NONE;

error:
return NULL;
}
#endif /* PSUTIL_HAVE_CPU_AFFINITY */

Expand Down
3 changes: 2 additions & 1 deletion psutil/_psutil_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,13 +708,14 @@ int psutil_get_nic_speed(int ifm_active) {
case(IFM_1000_LX): // 1000baseLX - single-mode fiber
case(IFM_1000_CX): // 1000baseCX - 150ohm STP
#if defined(IFM_1000_TX) && !defined(PSUTIL_OPENBSD)
#define HAS_CASE_IFM_1000_TX 1
// FreeBSD 4 and others (but NOT OpenBSD) -> #define IFM_1000_T in net/if_media.h
case(IFM_1000_TX):
#endif
#ifdef IFM_1000_FX
case(IFM_1000_FX):
#endif
#ifdef IFM_1000_T
#if defined(IFM_1000_T) && (!HAS_CASE_IFM_1000_TX || IFM_1000_T != IFM_1000_TX)
case(IFM_1000_T):
#endif
return 1000;
Expand Down

0 comments on commit 201f8a5

Please sign in to comment.