Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

Commit

Permalink
Merge branch 'giampaolo-master'
Browse files Browse the repository at this point in the history
* giampaolo-master:
  Fix workflow visibility badges in README (giampaolo#2399)
  OpenBSD: pid_exists() returns True for thread IDs (TIDs) (giampaolo#2395)
  pid_exists() and Process() disagree on whether a pid exists when ERROR_ACCESS_DENIED (giampaolo#2394)
  fix ruff errors
  Fix typos again (giampaolo#2388)
  fix doc style
  update HISTORY / CREDITS
  Include CoreFoundation/CoreFoundation.h (giampaolo#2364)
  Tests: Compare floats less strictly (giampaolo#2372)
  chore: build macOS arm64 wheels on macos-14 (giampaolo#2375)
  Update to fix OSX older version build failure (giampaolo#2379)
  Makefile: define a PYTHON_ENV_VARS var to use with the $PYTHON var.
  fix win tests
  refact serialization tests
  always use unittest.SkipTest where needed
  Add pickle support to psutil Exceptions (giampaolo#2380)
  enable ruff preview mode
  • Loading branch information
ddelange committed Apr 9, 2024
2 parents 35d747b + f4e51dd commit 4845910
Show file tree
Hide file tree
Showing 30 changed files with 302 additions and 114 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ jobs:
fail-fast: false
matrix:
include:
- {os: macos-12, archs: "x86_64 arm64"}
- {os: macos-13, archs: "x86_64"}
- {os: macos-14, archs: "arm64"}
- {os: ubuntu-latest, archs: "x86_64 i686"}
- {os: ubuntu-latest, archs: "aarch64"}
- {os: windows-2019, archs: "AMD64 x86"}
Expand All @@ -59,7 +60,7 @@ jobs:
if: matrix.archs == 'aarch64'

- name: Create wheels + run tests
uses: pypa/cibuildwheel@v2.16.5
uses: pypa/cibuildwheel@v2.17.0
with:
config-file: "./cibuildwheel.toml"
env:
Expand Down Expand Up @@ -161,7 +162,7 @@ jobs:
python-version: 3.x
- name: 'Run linters'
run: |
python3 -m pip install ruff black rstcheck toml-sort sphinx
python3 -m pip install ruff==0.3.4 black rstcheck toml-sort sphinx
make lint-all
# Check sanity of .tar.gz + wheel files
Expand Down
10 changes: 8 additions & 2 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Github usernames of people to CC on github when in need of help.
- alxchk, Oleksii Shevchuk
- AIX:
- wiggin15, Arnon Yaari (maintainer)
- wheels / packaging / CI matrix:
- mayeut, Matthieu Darbois

Top contributors
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -820,8 +822,12 @@ I: 2222

N: Ryan Carsten Schmidt
W: https://github.com/ryandesign
I: 2361
I: 2361, 2365

N: Shade Gladden
W: https://github.com/shadeyg56
I: 2376
I: 2376

N: Anthony Ryan
W: https://github.com/anthonyryan1
I: 2272
10 changes: 9 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@
**Enhancements**

- 2366_, [Windows]: log debug message when using slower process APIs.
- 2375_, [macOS]: provide arm64 wheels. (patch by Matthieu Darbois)

**Bug fixes**

- 2360_, [macOS]: can't compile on macOS < 10.13. (patch by Ryan Schmidt)
- 2395_, [OpenBSD]: `pid_exists()`_ erroneously return True if the argument is
a thread ID (TID) instead of a PID (process ID).
- 2254_, [Linux]: offline cpus raise NotImplementedError in cpu_freq() (patch by Shade Gladden)
- 2272_: Add pickle support to psutil Exceptions.
- 2359_, [Windows], [CRITICAL]: `pid_exists()`_ disagrees with `Process`_ on
whether a pid exists when ERROR_ACCESS_DENIED.
- 2360_, [macOS]: can't compile on macOS < 10.13. (patch by Ryan Schmidt)
- 2362_, [macOS]: can't compile on macOS 10.11. (patch by Ryan Schmidt)
- 2365_, [macOS]: can't compile on macOS < 10.9. (patch by Ryan Schmidt)

5.9.8
=====
Expand Down
74 changes: 37 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# Configurable.
PYTHON = python3
PYTHON_ENV_VARS = PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1
ARGS =
TSCRIPT = psutil/tests/runner.py

Expand All @@ -19,7 +20,7 @@ PY3_DEPS = \
pypinfo \
requests \
rstcheck \
ruff \
ruff==0.3.4 \
setuptools \
sphinx_rtd_theme \
teyit \
Expand Down Expand Up @@ -47,7 +48,6 @@ BUILD_OPTS = `$(PYTHON) -c \
# 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')"`
TEST_PREFIX = PSUTIL_SCRIPTS_DIR=`pwd`/scripts PYTHONWARNINGS=always PSUTIL_DEBUG=1

# if make is invoked with no arg, default to `make help`
.DEFAULT_GOAL := help
Expand Down Expand Up @@ -87,17 +87,17 @@ build: ## Compile (in parallel) without installing.
@# "build_ext -i" copies compiled *.so files in ./psutil directory in order
@# to allow "import psutil" when using the interactive interpreter from
@# within this directory.
PYTHONWARNINGS=all $(PYTHON) setup.py build_ext -i $(BUILD_OPTS)
$(PYTHON) -c "import psutil" # make sure it actually worked
$(PYTHON_ENV_VARS) $(PYTHON) setup.py build_ext -i $(BUILD_OPTS)
$(PYTHON_ENV_VARS) $(PYTHON) -c "import psutil" # make sure it actually worked

install: ## Install this package as current user in "edit" mode.
${MAKE} build
PYTHONWARNINGS=all $(PYTHON) setup.py develop $(INSTALL_OPTS)
$(PYTHON) -c "import psutil" # make sure it actually worked
$(PYTHON_ENV_VARS) $(PYTHON) setup.py develop $(INSTALL_OPTS)
$(PYTHON_ENV_VARS) $(PYTHON) -c "import psutil" # make sure it actually worked

uninstall: ## Uninstall this package via pip.
cd ..; $(PYTHON) -m pip uninstall -y -v psutil || true
$(PYTHON) scripts/internal/purge_installation.py
cd ..; $(PYTHON_ENV_VARS) $(PYTHON) -m pip uninstall -y -v psutil || true
$(PYTHON_ENV_VARS) $(PYTHON) scripts/internal/purge_installation.py

install-pip: ## Install pip (no-op if already installed).
@$(PYTHON) -c \
Expand All @@ -123,74 +123,74 @@ 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) -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)
$(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)

# ===================================================================
# Tests
# ===================================================================

test: ## Run all tests. To run a specific test do "make test ARGS=psutil.tests.test_system.TestDiskAPIs"
${MAKE} build
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS)
$(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS)

test-parallel: ## Run all tests in parallel.
${MAKE} build
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS) --parallel
$(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) --parallel

test-process: ## Run process-related API tests.
${MAKE} build
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_process.py
$(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_process.py

test-process-all: ## Run tests which iterate over all process PIDs.
${MAKE} build
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_process_all.py
$(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_process_all.py

test-system: ## Run system-related API tests.
${MAKE} build
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_system.py
$(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_system.py

test-misc: ## Run miscellaneous tests.
${MAKE} build
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_misc.py
$(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_misc.py

test-testutils: ## Run test utils tests.
${MAKE} build
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_testutils.py
$(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_testutils.py

test-unicode: ## Test APIs dealing with strings.
${MAKE} build
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_unicode.py
$(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_unicode.py

test-contracts: ## APIs sanity tests.
${MAKE} build
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_contracts.py
$(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_contracts.py

test-connections: ## Test net_connections() and Process.connections().
${MAKE} build
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_connections.py
$(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_connections.py

test-posix: ## POSIX specific tests.
${MAKE} build
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_posix.py
$(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_posix.py

test-platform: ## Run specific platform tests only.
${MAKE} build
$(TEST_PREFIX) $(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) $(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

test-memleaks: ## Memory leak tests.
${MAKE} build
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_memleaks.py
$(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) psutil/tests/test_memleaks.py

test-last-failed: ## Re-run tests which failed on last run
${MAKE} build
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS) --last-failed
$(PYTHON_ENV_VARS) $(PYTHON) $(TSCRIPT) $(ARGS) --last-failed

test-coverage: ## Run test coverage.
${MAKE} build
# Note: coverage options are controlled by .coveragerc file
rm -rf .coverage htmlcov
$(TEST_PREFIX) $(PYTHON) -m coverage run -m unittest -v
$(PYTHON_ENV_VARS) $(PYTHON) -m coverage run -m unittest -v
$(PYTHON) -m coverage report
@echo "writing results to htmlcov/index.html"
$(PYTHON) -m coverage html
Expand Down Expand Up @@ -230,10 +230,10 @@ lint-all: ## Run all linters
# ===================================================================

fix-black:
git ls-files '*.py' | xargs $(PYTHON) -m black
@git ls-files '*.py' | xargs $(PYTHON) -m black

fix-ruff:
@git ls-files '*.py' | xargs $(PYTHON) -m ruff --no-cache --fix
@git ls-files '*.py' | xargs $(PYTHON) -m ruff check --no-cache --fix

fix-unittests: ## Fix unittest idioms.
@git ls-files '*test_*.py' | xargs $(PYTHON) -m teyit --show-stats
Expand Down Expand Up @@ -261,20 +261,20 @@ install-git-hooks: ## Install GIT pre-commit hook.

sdist: ## Create tar.gz source distribution.
${MAKE} generate-manifest
PYTHONWARNINGS=all $(PYTHON) setup.py sdist
$(PYTHON_ENV_VARS) $(PYTHON) setup.py sdist

download-wheels-github: ## Download latest wheels hosted on github.
$(PYTHON) scripts/internal/download_wheels_github.py --tokenfile=~/.github.token
$(PYTHON_ENV_VARS) $(PYTHON) scripts/internal/download_wheels_github.py --tokenfile=~/.github.token
${MAKE} print-dist

download-wheels-appveyor: ## Download latest wheels hosted on appveyor.
$(PYTHON) scripts/internal/download_wheels_appveyor.py
$(PYTHON_ENV_VARS) $(PYTHON) scripts/internal/download_wheels_appveyor.py
${MAKE} print-dist

check-sdist: ## Check sanity of source distribution.
$(PYTHON) -m virtualenv --clear --no-wheel --quiet build/venv
build/venv/bin/python -m pip install -v --isolated --quiet dist/*.tar.gz
build/venv/bin/python -c "import os; os.chdir('build/venv'); import psutil"
$(PYTHON_ENV_VARS) $(PYTHON) -m virtualenv --clear --no-wheel --quiet build/venv
$(PYTHON_ENV_VARS) build/venv/bin/python -m pip install -v --isolated --quiet dist/*.tar.gz
$(PYTHON_ENV_VARS) build/venv/bin/python -c "import os; os.chdir('build/venv'); import psutil"
$(PYTHON) -m twine check --strict dist/*.tar.gz

check-wheels: ## Check sanity of wheels.
Expand Down Expand Up @@ -335,11 +335,11 @@ print-timeline: ## Print releases' timeline.

print-access-denied: ## Print AD exceptions
${MAKE} build
@$(TEST_PREFIX) $(PYTHON) scripts/internal/print_access_denied.py
@$(PYTHON_ENV_VARS) $(PYTHON) scripts/internal/print_access_denied.py

print-api-speed: ## Benchmark all API calls
${MAKE} build
@$(TEST_PREFIX) $(PYTHON) scripts/internal/print_api_speed.py $(ARGS)
@$(PYTHON_ENV_VARS) $(PYTHON) scripts/internal/print_api_speed.py $(ARGS)

print-downloads: ## Print PYPI download statistics
$(PYTHON) scripts/internal/print_downloads.py
Expand All @@ -356,11 +356,11 @@ grep-todos: ## Look for TODOs in the source files.

bench-oneshot: ## Benchmarks for oneshot() ctx manager (see #799).
${MAKE} build
$(TEST_PREFIX) $(PYTHON) scripts/internal/bench_oneshot.py
$(PYTHON_ENV_VARS) $(PYTHON) scripts/internal/bench_oneshot.py

bench-oneshot-2: ## Same as above but using perf module (supposed to be more precise)
${MAKE} build
$(TEST_PREFIX) $(PYTHON) scripts/internal/bench_oneshot_2.py
$(PYTHON_ENV_VARS) $(PYTHON) scripts/internal/bench_oneshot_2.py

check-broken-links: ## Look for broken links in source files.
git ls-files | xargs $(PYTHON) -Wa scripts/internal/check_broken_links.py
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
:target: https://github.com/giampaolo/psutil/graphs/contributors
:alt: Contributors

.. |github-actions-wheels| image:: https://img.shields.io/github/actions/workflow/status/giampaolo/psutil/.github/workflows/build.yml?label=Linux%2C%20macOS%2C%20Windows
.. |github-actions-wheels| image:: https://img.shields.io/github/actions/workflow/status/giampaolo/psutil/.github/workflows/build.yml.svg?label=Linux%2C%20macOS%2C%20Windows
:target: https://github.com/giampaolo/psutil/actions?query=workflow%3Abuild
:alt: Linux, macOS, Windows

.. |github-actions-bsd| image:: https://img.shields.io/github/actions/workflow/status/giampaolo/psutil/.github/workflows/bsd.yml?label=FreeBSD,%20NetBSD,%20OpenBSD
.. |github-actions-bsd| image:: https://img.shields.io/github/actions/workflow/status/giampaolo/psutil/.github/workflows/bsd.yml.svg?label=FreeBSD,%20NetBSD,%20OpenBSD
:target: https://github.com/giampaolo/psutil/actions?query=workflow%3Absd-tests
:alt: FreeBSD, NetBSD, OpenBSD

Expand Down
2 changes: 1 addition & 1 deletion docs/DEVGUIDE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Once you have a compiler installed run:
make test-memleaks
make test-coverage
make lint-all # Run Python and C linter
make fix-all # Fix linting erors
make fix-all # Fix linting errors
make uninstall
make help
Expand Down
12 changes: 12 additions & 0 deletions docs/_static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
margin-bottom: 0px !important;
}

.rst-content li {
list-style: outside;
margin-left: 15px;
}

.document td {
padding-bottom: 0px !important;
}
Expand Down Expand Up @@ -536,3 +541,10 @@ div.body div.admonition, div.body div.impl-detail {
.highlight .il {
color: #208050
}

.rst-content pre.literal-block, .rst-content div[class^='highlight'] {
border: 1px solid #e1e4e5;
padding: 0px;
overflow-x: auto;
margin: 1px 0 0px 0;
}
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ Process class
.. method:: cwd()

The process current working directory as an absolute path. If cwd cannot be
determined for some internal reason (e.g. system process or directiory no
determined for some internal reason (e.g. system process or directory no
longer exists) it may return an empty string.

.. versionchanged:: 5.6.4 added support for NetBSD
Expand Down Expand Up @@ -3048,6 +3048,7 @@ Timeline
.. _`nettop.py`: https://github.com/giampaolo/psutil/blob/master/scripts/nettop.py
.. _`open`: https://docs.python.org/3/library/functions.html#open
.. _`os.cpu_count`: https://docs.python.org/3/library/os.html#os.cpu_count
.. _`os.getloadavg`: https://docs.python.org//library/os.html#os.getloadavg
.. _`os.getpid`: https://docs.python.org/3/library/os.html#os.getpid
.. _`os.getpriority`: https://docs.python.org/3/library/os.html#os.getpriority
.. _`os.getresgid`: https://docs.python.org//library/os.html#os.getresgid
Expand Down
4 changes: 2 additions & 2 deletions psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
AF_LINK = _psplatform.AF_LINK

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

_timer = getattr(time, 'monotonic', time.time)
Expand Down Expand Up @@ -2037,7 +2037,7 @@ def swap_memory():


# =====================================================================
# --- disks/paritions related functions
# --- disks/partitions related functions
# =====================================================================


Expand Down
Loading

0 comments on commit 4845910

Please sign in to comment.