diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-11-15 21:54:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-15 21:54:42 +0100 |
commit | e58b0fdaeaedd73a0ca19ad23a63874708d86b91 (patch) | |
tree | 600b3f21857a2f4622e33988963e768c2b7dc335 | |
parent | 21bb0822c7d30adc1e144e87d730cd67eb4fa828 (diff) | |
download | psutil-e58b0fdaeaedd73a0ca19ad23a63874708d86b91.tar.gz |
Remove Travis and Cirrus, use GH also for FreeBSD (#1880)
35 files changed, 269 insertions, 478 deletions
diff --git a/.ci/appveyor/run_with_compiler.cmd b/.ci/appveyor/run_with_compiler.cmd index 5da547c4..7965f865 100644 --- a/.ci/appveyor/run_with_compiler.cmd +++ b/.ci/appveyor/run_with_compiler.cmd @@ -29,6 +29,7 @@ :: The CALL lines at the end of this file look redundant, but if you move them :: outside of the IF clauses, they do not run properly in the SET_SDK_64==Y :: case, I don't know why. + @ECHO OFF SET COMMAND_TO_RUN=%* diff --git a/.ci/travis/README b/.ci/travis/README deleted file mode 100644 index d9d5f65a..00000000 --- a/.ci/travis/README +++ /dev/null @@ -1,2 +0,0 @@ -This directory contains support files for Travis, a continuous integration -service which runs tests on Linux and Windows on every push. diff --git a/.ci/travis/install.sh b/.ci/travis/install.sh deleted file mode 100755 index ff6b9378..00000000 --- a/.ci/travis/install.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -set -e -set -x - -uname -a -python -c "import sys; print(sys.version)" - -if [[ "$(uname -s)" == 'Darwin' ]]; then - brew update || brew update - brew outdated pyenv || brew upgrade pyenv - brew install pyenv-virtualenv - - if which pyenv > /dev/null; then - eval "$(pyenv init -)" - fi - - case "${PYVER}" in - py27) - pyenv install 2.7.16 - pyenv virtualenv 2.7.16 psutil - ;; - py36) - pyenv install 3.6.6 - pyenv virtualenv 3.6.6 psutil - ;; - py37) - pyenv install 3.7.6 - pyenv virtualenv 3.7.6 psutil - ;; - py38) - pyenv install 3.8.5 - pyenv virtualenv 3.8.5 psutil - ;; - py39) - pyenv install 3.9.0 - pyenv virtualenv 3.9.0 psutil - ;; - esac - pyenv rehash - pyenv activate psutil -fi - -if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]] || [[ $PYVER == 'py27' ]]; then - pip install -U ipaddress mock unittest2 -fi - -pip install -U coverage coveralls flake8 setuptools twine diff --git a/.ci/travis/run.sh b/.ci/travis/run.sh deleted file mode 100755 index ae593df5..00000000 --- a/.ci/travis/run.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -set -e -set -x - -PYVER=`python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))'` - -# setup macOS -if [[ "$(uname -s)" == 'Darwin' ]]; then - if which pyenv > /dev/null; then - eval "$(pyenv init -)" - fi - pyenv activate psutil -fi - -# install psutil -make clean -python setup.py build -python setup.py develop - -# run tests (with coverage) -if [[ $PYVER == '2.7' ]] && [[ "$(uname -s)" != 'Darwin' ]]; then - PSUTIL_TESTING=1 python -Wa -m coverage run psutil/tests/runner.py -else - PSUTIL_TESTING=1 python -Wa psutil/tests/runner.py -fi - -if [ "$PYVER" == "2.7" ] || [ "$PYVER" == "3.6" ]; then - # run mem leaks test - PSUTIL_TESTING=1 python -Wa psutil/tests/test_memleaks.py - # run linter (on Linux only) - if [[ "$(uname -s)" != 'Darwin' ]]; then - make lint PYTHON=python - fi -fi - -PSUTIL_TESTING=1 python -Wa scripts/internal/print_access_denied.py -PSUTIL_TESTING=1 python -Wa scripts/internal/print_api_speed.py diff --git a/.cirrus.yml b/.cirrus.yml deleted file mode 100644 index a0b8f1f0..00000000 --- a/.cirrus.yml +++ /dev/null @@ -1,31 +0,0 @@ -freebsd_13_py3_task: - freebsd_instance: - image: freebsd-12-1-release-amd64 - env: - CIRRUS: 1 - install_script: - - pkg install -y python3 gcc py37-pip - script: - - python3 -m pip install --user setuptools - - make clean - - make install - - make test - - make test-memleaks - - make print-access-denied - - make print-api-speed - -freebsd_11_py2_task: - freebsd_instance: - image: freebsd-12-1-release-amd64 - env: - CIRRUS: 1 - install_script: - - pkg install -y python gcc py27-pip - script: - - python2.7 -m pip install --user setuptools ipaddress mock - - make clean - - make install - - make test - - make test-memleaks - - make print-access-denied - - make print-api-speed diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index 67a9601b..1cdba810 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -7,13 +7,9 @@ labels: 'bug' --- **Platform** * { OS version } -* { psutil version: python3 -c "import psutil; print(psutil.__version__)" } +* { psutil version (print psutil.__version__) } * { python version } **Bug description** ... - - -**Test results** -{ output of `python -c psutil.tests` (failures only, not full result) } diff --git a/.github/ISSUE_TEMPLATE/enhancement.md b/.github/ISSUE_TEMPLATE/enhancement.md index 7e7159f2..2111c572 100644 --- a/.github/ISSUE_TEMPLATE/enhancement.md +++ b/.github/ISSUE_TEMPLATE/enhancement.md @@ -6,4 +6,3 @@ title: "[OS] title" --- -{ a clear and concise description of what the enhancment is about } diff --git a/.github/lock.yml b/.github/lock.yml deleted file mode 100644 index 7099c810..00000000 --- a/.github/lock.yml +++ /dev/null @@ -1,35 +0,0 @@ -# Configuration for Lock Threads - https://github.com/dessant/lock-threads-app - -# Number of days of inactivity before a closed issue or pull request is locked -daysUntilLock: 3 - -# Skip issues and pull requests created before a given timestamp. Timestamp must -# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable -skipCreatedBefore: false - -# Issues and pull requests with these labels will be ignored. Set to `[]` to disable -exemptLabels: [] - -# Label to add before locking, such as `outdated`. Set to `false` to disable -lockLabel: false - -# Comment to post before locking. Set to `false` to disable -lockComment: false - -# Assign `resolved` as the reason for locking. Set to `false` to disable -setLockReason: false - -# Limit to only `issues` or `pulls` -# only: issues - -# Optionally, specify configuration settings just for `issues` or `pulls` -# issues: -# exemptLabels: -# - help-wanted -# lockLabel: outdated - -# pulls: -# daysUntilLock: 30 - -# Repository to extend settings from -# _extends: repo diff --git a/.github/workflows/build_wheel.yml b/.github/workflows/build_wheel.yml deleted file mode 100644 index 1a8b4868..00000000 --- a/.github/workflows/build_wheel.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Linux, macOS, Windows - -on: [push, pull_request] - -jobs: - wheel: - name: ${{ matrix.os }} - runs-on: ${{ matrix.os }} - timeout-minutes: 30 - strategy: - fail-fast: false # whether to exit the whole run on first failure - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - include: - - {name: Linux, python: '3.9', os: ubuntu-latest} - env: - CIBW_TEST_COMMAND: python -u -Wa {project}/psutil/tests/runner.py - CIBW_TEST_COMMAND_MACOS: LC_ALL='en_US.utf8' python -Wa {project}/psutil/tests/runner.py - CIBW_TEST_EXTRAS: test - # https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip - CIBW_SKIP: cp35-* pp* - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - - name: (Windows) install Visual C++ for Python 2.7 - if: matrix.os == 'windows-latest' - run: | - choco install vcpython27 -f -y - - - name: Run tests - run: | - pip install cibuildwheel - cibuildwheel . - - - name: Create wheels - uses: actions/upload-artifact@v2 - with: - name: wheels - path: wheelhouse - - - name: Print hashes - if: matrix.os == 'ubuntu-latest' - run: | - make generate-manifest - python setup.py sdist - mv dist/psutil*.tar.gz wheelhouse/ - python scripts/internal/print_hashes.py wheelhouse/ - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..c93ad480 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,95 @@ +# Executed on every push by GitHub Actions. This runs CI tests and +# generates wheels on the following platforms: +# +# * Linux +# * macOS +# * FreeBSD +# +# Windows works as well but it's disabled (we do it via AppVeyor). +# To skip certain builds see: +# https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip + +name: CI +on: [push] +jobs: + linux-macos-win: + name: ${{ matrix.os }} + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + # os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-latest] + include: + - {name: Linux, python: '3.9', os: ubuntu-latest} + env: + CIBW_TEST_COMMAND: + PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_TESTING=1 PSUTIL_DEBUG=1 + python {project}/psutil/tests/runner.py && + PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_TESTING=1 PSUTIL_DEBUG=1 + python {project}/psutil/tests/test_memleaks.py + CIBW_TEST_EXTRAS: test + CIBW_SKIP: cp35-* pp* + steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.6.0 + with: + access_token: ${{ github.token }} + + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + + # - name: (Windows) install Visual C++ for Python 2.7 + # if: matrix.os == 'windows-latest' + # run: | + # choco install vcpython27 -f -y + + - name: Run tests + run: | + pip install cibuildwheel + cibuildwheel . + + - name: Create wheels + uses: actions/upload-artifact@v2 + with: + name: wheels + path: wheelhouse + + - name: Print hashes + if: matrix.os == 'ubuntu-latest' + run: | + make generate-manifest + python setup.py sdist + mv dist/psutil*.tar.gz wheelhouse/ + python scripts/internal/print_hashes.py wheelhouse/ + + freebsd: + runs-on: macos-latest + steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.6.0 + with: + access_token: ${{ github.token }} + + - uses: actions/checkout@v2 + + - name: Run tests + id: test + uses: vmactions/freebsd-vm@v0.0.8 + with: + usesh: true + prepare: pkg install -y gcc python3 + run: | + set +e + export \ + PYTHONWARNINGS=always \ + PYTHONUNBUFFERED=1 \ + PSUTIL_TESTING=1 \ + PSUTIL_DEBUG=1 + python3 -m pip install --user setuptools + python3 setup.py install + python3 psutil/tests/runner.py + python3 psutil/tests/test_memleaks.py diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d9420682..00000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: python -cache: pip -matrix: - include: - # Linux - - python: 3.8 - - python: 3.9-dev - # macOS - - language: generic - os: osx - env: PYVER=py38 - - language: generic - os: osx - env: PYVER=py27 - # pypy - - python: pypy - - python: pypy3 -install: - - ./.ci/travis/install.sh -script: - - ./.ci/travis/run.sh -after_success: - - | - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]] && [[ "$(uname -s)" != 'Darwin' ]]; then - echo "sending test coverage results to coveralls.io" - coveralls - fi diff --git a/HISTORY.rst b/HISTORY.rst index bcbffa69..58626e10 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,9 +7,12 @@ XXXX-XX-XX **Enhancements** -- 1872_: [Windows] added support for PyPy 2.7. - 1863_: `disk_partitions()` exposes 2 extra fields: `maxfile` and `maxpath`, which are the maximum file name and path name length. +- 1872_: [Windows] added support for PyPy 2.7. +- 1879_: provide pre-compiled wheels for Linux and macOS (yey!). +- 1880_: get rid of Travis and Cirrus CI services (they are no longer free). + CI testing is now done by GitHub Actions on Linux, macOS and FreeBSD (yes). AppVeyor is still being used for Windows CI. **Bug fixes** diff --git a/MANIFEST.in b/MANIFEST.in index 780bbdc7..2bed87e7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -111,6 +111,27 @@ include scripts/disk_usage.py include scripts/fans.py include scripts/free.py include scripts/ifconfig.py +include scripts/internal/README +include scripts/internal/bench_oneshot.py +include scripts/internal/bench_oneshot_2.py +include scripts/internal/check_broken_links.py +include scripts/internal/clinter.py +include scripts/internal/convert_readme.py +include scripts/internal/download_wheels_appveyor.py +include scripts/internal/download_wheels_github.py +include scripts/internal/fix_flake8.py +include scripts/internal/generate_manifest.py +include scripts/internal/git_pre_commit.py +include scripts/internal/print_access_denied.py +include scripts/internal/print_announce.py +include scripts/internal/print_api_speed.py +include scripts/internal/print_downloads.py +include scripts/internal/print_hashes.py +include scripts/internal/print_timeline.py +include scripts/internal/print_wheels.py +include scripts/internal/purge_installation.py +include scripts/internal/tidelift.py +include scripts/internal/winmake.py include scripts/iotop.py include scripts/killall.py include scripts/meminfo.py @@ -128,4 +149,3 @@ include scripts/top.py include scripts/who.py include scripts/winservices.py include setup.py -include tox.ini @@ -63,7 +63,6 @@ clean: ## Remove all build files. *\@psutil-* \ .coverage \ .failed-tests.txt \ - .tox \ build/ \ dist/ \ docs/_build/ \ @@ -212,13 +211,11 @@ install-git-hooks: ## Install GIT pre-commit hook. # Wheels # =================================================================== -download-wheels-appveyor: ## Download latest wheels hosted on appveyor. - $(PYTHON) scripts/internal/download_wheels_appveyor.py --user giampaolo --project psutil - ${MAKE} print-wheels - download-wheels-github: ## Download latest wheels hosted on github. $(PYTHON) scripts/internal/download_wheels_github.py --user=giampaolo --project=psutil --tokenfile=~/.github.token - ${MAKE} print-wheels + +download-wheels-appveyor: ## Download latest wheels hosted on appveyor. + $(PYTHON) scripts/internal/download_wheels_appveyor.py --user giampaolo --project psutil print-wheels: ## Print downloaded wheels $(PYTHON) scripts/internal/print_wheels.py @@ -261,10 +258,11 @@ pre-release: ## Check if we're ready to produce a new release. ${MAKE} install ${MAKE} generate-manifest git diff MANIFEST.in > /dev/null # ...otherwise 'git diff-index HEAD' will complain - ${MAKE} download-wheels-github ${MAKE} sdist + ${MAKE} download-wheels-github + ${MAKE} download-wheels-appveyor + ${MAKE} print-wheels $(PYTHON) -m twine check dist/* - ${MAKE} md5-dist $(PYTHON) -c \ "from psutil import __version__ as ver; \ doc = open('docs/index.rst').read(); \ @@ -1,6 +1,6 @@ | |downloads| |stars| |forks| |contributors| |coverage| |quality| | |version| |py-versions| |packages| |license| -| |travis| |appveyor| |cirrus| |doc| |twitter| |tidelift| +| |github-actions| |appveyor| |doc| |twitter| |tidelift| .. |downloads| image:: https://img.shields.io/pypi/dm/psutil.svg :target: https://pepy.tech/project/psutil @@ -22,18 +22,14 @@ :target: https://www.codacy.com/app/g-rodola/psutil?utm_source=github.com&utm_medium=referral&utm_content=giampaolo/psutil&utm_campaign=Badge_Grade :alt: Code quality -.. |travis| image:: https://img.shields.io/travis/giampaolo/psutil/master.svg?maxAge=3600&label=Linux,%20OSX,%20PyPy - :target: https://travis-ci.org/giampaolo/psutil - :alt: Linux tests (Travis) +.. |github-actions| image:: https://img.shields.io/github/workflow/status/giampaolo/psutil/CI?label=Linux%2C%20macOS%2C%20FreeBSD + :target: https://github.com/giampaolo/psutil/actions?query=workflow%3ACI + :alt: Linux, macOS, Windows tests .. |appveyor| image:: https://img.shields.io/appveyor/ci/giampaolo/psutil/master.svg?maxAge=3600&label=Windows :target: https://ci.appveyor.com/project/giampaolo/psutil :alt: Windows tests (Appveyor) -.. |cirrus| image:: https://img.shields.io/cirrus/github/giampaolo/psutil?label=FreeBSD - :target: https://cirrus-ci.com/github/giampaolo/psutil-cirrus-ci - :alt: FreeBSD tests (Cirrus-Ci) - .. |coverage| image:: https://coveralls.io/repos/github/giampaolo/psutil/badge.svg?branch=master :target: https://coveralls.io/github/giampaolo/psutil?branch=master :alt: Test coverage (coverall.io) @@ -283,10 +279,12 @@ Process management >>> import psutil >>> psutil.pids() - [1, 2, 3, 4, 5, 6, 7, 46, 48, 50, 51, 178, 182, 222, 223, 224, 268, 1215, 1216, 1220, 1221, 1243, 1244, - 1301, 1601, 2237, 2355, 2637, 2774, 3932, 4176, 4177, 4185, 4187, 4189, 4225, 4243, 4245, 4263, 4282, - 4306, 4311, 4312, 4313, 4314, 4337, 4339, 4357, 4358, 4363, 4383, 4395, 4408, 4433, 4443, 4445, 4446, - 5167, 5234, 5235, 5252, 5318, 5424, 5644, 6987, 7054, 7055, 7071] + [1, 2, 3, 4, 5, 6, 7, 46, 48, 50, 51, 178, 182, 222, 223, 224, 268, 1215, + 1216, 1220, 1221, 1243, 1244, 1301, 1601, 2237, 2355, 2637, 2774, 3932, + 4176, 4177, 4185, 4187, 4189, 4225, 4243, 4245, 4263, 4282, 4306, 4311, + 4312, 4313, 4314, 4337, 4339, 4357, 4358, 4363, 4383, 4395, 4408, 4433, + 4443, 4445, 4446, 5167, 5234, 5235, 5252, 5318, 5424, 5644, 6987, 7054, + 7055, 7071] >>> >>> p = psutil.Process(7055) >>> p diff --git a/appveyor.yml b/appveyor.yml index ff9d35b9..a0532206 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,13 +1,23 @@ # Build: 3 (bump this up by 1 to force an appveyor run) os: Visual Studio 2015 - +# avoid 2 builds when pushing on PRs +skip_branch_with_pr: true +# avoid build on new GIT tag +skip_tags: true +matrix: + # stop build on first failure + fast_finish: true environment: global: # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the # /E:ON and /V:ON options are not enabled in the batch script intepreter # See: http://stackoverflow.com/a/13751649/163740 WITH_COMPILER: "cmd /E:ON /V:ON /C .\\.ci\\appveyor\\run_with_compiler.cmd" + PYTHONWARNINGS: always + PYTHONUNBUFFERED: 1 + PSUTIL_TESTING: 1 + PSUTIL_DEBUG: 1 matrix: # 32 bits @@ -75,6 +85,7 @@ test_script: after_test: - "%WITH_COMPILER% %PYTHON%/python.exe scripts/internal/winmake.py wheel" + - "%WITH_COMPILER% %PYTHON%/python.exe scripts/internal/print_hashes.py dist" - "%WITH_COMPILER% %PYTHON%/python.exe scripts/internal/print_access_denied.py" - "%WITH_COMPILER% %PYTHON%/python.exe scripts/internal/print_api_speed.py" @@ -105,4 +116,3 @@ only_commits: - psutil/tests/* - scripts/* - setup.py - diff --git a/docs/DEVGUIDE.rst b/docs/DEVGUIDE.rst index 573afdd5..2ed8c42a 100644 --- a/docs/DEVGUIDE.rst +++ b/docs/DEVGUIDE.rst @@ -107,30 +107,24 @@ All of the services listed below are automatically run on each ``git push``. Unit tests ---------- -Tests are automatically run on every GIT push on **Linux**, **macOS**, +Tests are automatically run on every GIT push and PR on **Linux**, **macOS**, **Windows** and **FreeBSD** by using: -- `Travis`_ (Linux, macOS) - `Github Actions`_ (Linux, macOS, Windows) - `Appveyor`_ (Windows) -- `Cirrus CI`_ (FreeBSD) -.. image:: https://img.shields.io/travis/giampaolo/psutil/master.svg?maxAge=3600&label=Linux,%20OSX,%20PyPy - :target: https://travis-ci.org/giampaolo/psutil +.. image:: https://img.shields.io/github/workflow/status/giampaolo/psutil/CI?label=linux%2C%20macos%2C%20freebsd + :target: https://github.com/giampaolo/psutil/actions?query=workflow%3ACI -.. image:: https://img.shields.io/appveyor/ci/giampaolo/psutil/master.svg?maxAge=3600&label=Windows +.. image:: https://img.shields.io/appveyor/ci/giampaolo/psutil/master.svg?maxAge=3600&label=windows :target: https://ci.appveyor.com/project/giampaolo/psutil -.. image:: https://img.shields.io/cirrus/github/giampaolo/psutil?label=FreeBSD - :target: https://cirrus-ci.com/github/giampaolo/psutil-cirrus-ci - OpenBSD, NetBSD, AIX and Solaris does not have continuos test integration. Test coverage ------------- -Test coverage is provided by `coveralls.io`_ and it is controlled via -`.travis.yml`_. +Test coverage is provided by `coveralls.io`_. .. image:: https://coveralls.io/repos/giampaolo/psutil/badge.svg?branch=master&service=github :target: https://coveralls.io/github/giampaolo/psutil?branch=master @@ -144,10 +138,8 @@ Documentation - public doc is hosted at https://psutil.readthedocs.io -.. _`.travis.yml`: https://github.com/giampaolo/psutil/blob/master/.travis.yml .. _`appveyor.yml`: https://github.com/giampaolo/psutil/blob/master/appveyor.yml .. _`Appveyor`: https://ci.appveyor.com/project/giampaolo/psuti -.. _`Cirrus CI`: https://cirrus-ci.com/github/giampaolo/psutil-cirrus-ci .. _`coveralls.io`: https://coveralls.io/github/giampaolo/psuti .. _`CREDITS`: https://github.com/giampaolo/psutil/blob/master/CREDITS .. _`doc/index.rst`: https://github.com/giampaolo/psutil/blob/master/doc/index.rst @@ -165,4 +157,3 @@ Documentation .. _`psutil/tests/test_system.py`: https://github.com/giampaolo/psutil/blob/master/psutil/tests/test_system.py .. _`RsT syntax`: http://docutils.sourceforge.net/docs/user/rst/quickref.htm .. _`sphinx`: http://sphinx-doc.org -.. _`Travis`: https://travis-ci.org/giampaolo/psuti diff --git a/psutil/__init__.py b/psutil/__init__.py index 9b4eb894..acd42ac2 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -209,7 +209,7 @@ if hasattr(_psplatform.Process, "rlimit"): AF_LINK = _psplatform.AF_LINK __author__ = "Giampaolo Rodola'" -__version__ = "5.7.4" +__version__ = "5.8.0" version_info = tuple([int(num) for num in __version__.split('.')]) _timer = getattr(time, 'monotonic', time.time) diff --git a/psutil/_psutil_common.c b/psutil/_psutil_common.c index a01919d5..e72904de 100644 --- a/psutil/_psutil_common.c +++ b/psutil/_psutil_common.c @@ -142,6 +142,7 @@ AccessDenied(const char *syscall) { PyObject * psutil_set_testing(PyObject *self, PyObject *args) { PSUTIL_TESTING = 1; + PSUTIL_DEBUG = 1; Py_INCREF(Py_None); return Py_None; } diff --git a/psutil/tests/README.rst b/psutil/tests/README.rst index 61e066b7..9dca1186 100644 --- a/psutil/tests/README.rst +++ b/psutil/tests/README.rst @@ -12,12 +12,3 @@ Instructions for running tests make setup-dev-env # install missing third-party deps make test # serial run make test-parallel # parallel run - -* To run tests on all supported Python versions install tox - (``pip install tox``) then run ``tox`` from within psutil root directory. - -* Every time a commit is pushed tests are automatically run on Travis - (Linux, MACOS) and appveyor (Windows): - - * Travis builds: https://travis-ci.org/giampaolo/psutil - * AppVeyor builds: https://ci.appveyor.com/project/giampaolo/psutil diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 36f83435..e0df67fa 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -37,6 +37,7 @@ from socket import SOCK_STREAM import psutil from psutil import AIX +from psutil import FREEBSD from psutil import LINUX from psutil import MACOS from psutil import POSIX @@ -76,7 +77,7 @@ __all__ = [ # constants 'APPVEYOR', 'DEVNULL', 'GLOBAL_TIMEOUT', 'TOLERANCE_SYS_MEM', 'NO_RETRIES', 'PYPY', 'PYTHON_EXE', 'ROOT_DIR', 'SCRIPTS_DIR', 'TESTFN_PREFIX', - 'UNICODE_SUFFIX', 'INVALID_UNICODE_SUFFIX', 'TRAVIS', 'CIRRUS', + 'UNICODE_SUFFIX', 'INVALID_UNICODE_SUFFIX', 'CI_TESTING', 'VALID_PROC_STATUSES', 'TOLERANCE_DISK_USAGE', 'IS_64BIT', "HAS_CPU_AFFINITY", "HAS_CPU_FREQ", "HAS_ENVIRON", "HAS_PROC_IO_COUNTERS", "HAS_IONICE", "HAS_MEMORY_MAPS", "HAS_PROC_CPU_NUM", "HAS_RLIMIT", @@ -119,11 +120,9 @@ __all__ = [ PYPY = '__pypy__' in sys.builtin_module_names # whether we're running this test suite on a Continuous Integration service -TRAVIS = 'TRAVIS' in os.environ APPVEYOR = 'APPVEYOR' in os.environ -CIRRUS = 'CIRRUS' in os.environ GITHUB_ACTIONS = 'GITHUB_ACTIONS' in os.environ or 'CIBUILDWHEEL' in os.environ -CI_TESTING = TRAVIS or APPVEYOR or CIRRUS or GITHUB_ACTIONS +CI_TESTING = APPVEYOR or GITHUB_ACTIONS # are we a 64 bit process? IS_64BIT = sys.maxsize > 2 ** 32 @@ -137,8 +136,7 @@ TOLERANCE_SYS_MEM = 5 * 1024 * 1024 # 5MB TOLERANCE_DISK_USAGE = 10 * 1024 * 1024 # 10MB # the timeout used in functions which have to wait GLOBAL_TIMEOUT = 5 -# be more tolerant if we're on travis / appveyor in order to avoid -# false positives +# be more tolerant if we're on CI in order to avoid false positives if CI_TESTING: NO_RETRIES *= 3 GLOBAL_TIMEOUT *= 3 @@ -207,6 +205,8 @@ def _get_py_exe(): if GITHUB_ACTIONS: if PYPY: return which("pypy3") if PY3 else which("pypy") + elif FREEBSD: + return os.path.realpath(sys.executable) else: return which('python') elif MACOS: @@ -1126,22 +1126,23 @@ def print_sysinfo(): info['user'] = getpass.getuser() info['home'] = os.path.expanduser("~") info['cwd'] = os.getcwd() + info['pyexe'] = PYTHON_EXE info['hostname'] = platform.node() info['PID'] = os.getpid() # metrics - pinfo = psutil.Process().as_dict() - pinfo.pop('memory_maps', None) info['cpus'] = psutil.cpu_count() info['loadavg'] = "%.1f%%, %.1f%%, %.1f%%" % ( tuple([x / psutil.cpu_count() * 100 for x in psutil.getloadavg()])) mem = psutil.virtual_memory() - info['memory'] = "%s%%, %s/%s" % ( + info['memory'] = "%s%%, used=%s, total=%s" % ( int(mem.percent), bytes2human(mem.used), bytes2human(mem.total)) swap = psutil.swap_memory() - info['swap'] = "%s%%, %s/%s" % ( + info['swap'] = "%s%%, used=%s, total=%s" % ( int(swap.percent), bytes2human(swap.used), bytes2human(swap.total)) info['pids'] = len(psutil.pids()) + pinfo = psutil.Process().as_dict() + pinfo.pop('memory_maps', None) info['proc'] = pprint.pformat(pinfo) print("=" * 70, file=sys.stderr) # NOQA diff --git a/psutil/tests/runner.py b/psutil/tests/runner.py index 0777f5e7..d761cd21 100755 --- a/psutil/tests/runner.py +++ b/psutil/tests/runner.py @@ -304,9 +304,9 @@ def run_from_name(name): def setup(): - if 'PSUTIL_TESTING' not in os.environ: - # This won't work on Windows but set_testing() below will do it. - os.environ['PSUTIL_TESTING'] = '1' + # Note: doc states that altering os.environment may cause memory + # leaks on some platforms. + # Sets PSUTIL_TESTING and PSUTIL_DEBUG in the C module. psutil._psplatform.cext.set_testing() diff --git a/psutil/tests/test_connections.py b/psutil/tests/test_connections.py index ba019ec0..6bbf2194 100755 --- a/psutil/tests/test_connections.py +++ b/psutil/tests/test_connections.py @@ -31,7 +31,6 @@ from psutil.tests import AF_UNIX from psutil.tests import bind_socket from psutil.tests import bind_unix_socket from psutil.tests import check_connection_ntuple -from psutil.tests import CIRRUS from psutil.tests import create_sockets from psutil.tests import HAS_CONNECTIONS_UNIX from psutil.tests import PsutilTestCase @@ -41,7 +40,6 @@ from psutil.tests import serialrun from psutil.tests import skip_on_access_denied from psutil.tests import SKIP_SYSCONS from psutil.tests import tcp_socketpair -from psutil.tests import TRAVIS from psutil.tests import unittest from psutil.tests import unix_socketpair from psutil.tests import wait_for_file @@ -246,9 +244,6 @@ class TestConnectedSocket(ConnectionTestCase): # On NetBSD creating a UNIX socket will cause # a UNIX connection to /var/run/log. cons = [c for c in cons if c.raddr != '/var/run/log'] - if CIRRUS: - cons = [c for c in cons if c.fd in - (server.fileno(), client.fileno())] self.assertEqual(len(cons), 2, msg=cons) if LINUX or FREEBSD or SUNOS: # remote path is never set @@ -495,10 +490,6 @@ class TestSystemWideConnections(ConnectionTestCase): self.assertEqual(len(cons), len(set(cons))) check(cons, families, types_) - # See: https://travis-ci.org/giampaolo/psutil/jobs/237566297 - @unittest.skipIf(MACOS and TRAVIS, "unreliable on MACOS + TRAVIS") - # XXX - @unittest.skipIf(TRAVIS and PYTHON_39, "unreliable on TRAVIS + PYTHON_39") @retry_on_failure() def test_multi_sockets_procs(self): # Creates multiple sub processes, each creating different diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index fbfa05a9..f8a9e008 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -44,7 +44,6 @@ from psutil.tests import skip_on_not_implemented from psutil.tests import ThreadTask from psutil.tests import TOLERANCE_DISK_USAGE from psutil.tests import TOLERANCE_SYS_MEM -from psutil.tests import TRAVIS from psutil.tests import unittest from psutil.tests import which @@ -261,7 +260,6 @@ class TestSystemVirtualMemory(PsutilTestCase): free_value, psutil_value, delta=TOLERANCE_SYS_MEM, msg='%s %s \n%s' % (free_value, psutil_value, free.output)) - @unittest.skipIf(TRAVIS, "unreliable on TRAVIS") @retry_on_failure() def test_free(self): vmstat_value = vmstat('free memory') * 1024 @@ -276,8 +274,6 @@ class TestSystemVirtualMemory(PsutilTestCase): self.assertAlmostEqual( vmstat_value, psutil_value, delta=TOLERANCE_SYS_MEM) - # https://travis-ci.org/giampaolo/psutil/jobs/226719664 - @unittest.skipIf(TRAVIS, "unreliable on TRAVIS") @retry_on_failure() def test_active(self): vmstat_value = vmstat('active memory') * 1024 @@ -285,8 +281,6 @@ class TestSystemVirtualMemory(PsutilTestCase): self.assertAlmostEqual( vmstat_value, psutil_value, delta=TOLERANCE_SYS_MEM) - # https://travis-ci.org/giampaolo/psutil/jobs/227242952 - @unittest.skipIf(TRAVIS, "unreliable on TRAVIS") @retry_on_failure() def test_inactive(self): vmstat_value = vmstat('inactive memory') * 1024 @@ -638,7 +632,6 @@ class TestSystemSwapMemory(PsutilTestCase): @unittest.skipIf(not LINUX, "LINUX only") class TestSystemCPUTimes(PsutilTestCase): - @unittest.skipIf(TRAVIS, "unknown failure on travis") def test_fields(self): fields = psutil.cpu_times()._fields kernel_ver = re.findall(r'\d+\.\d+\.\d+', os.uname()[2])[0] @@ -753,7 +746,6 @@ class TestSystemCPUCountPhysical(PsutilTestCase): @unittest.skipIf(not LINUX, "LINUX only") class TestSystemCPUFrequency(PsutilTestCase): - @unittest.skipIf(TRAVIS, "fails on Travis") @unittest.skipIf(not HAS_CPU_FREQ, "not supported") def test_emulate_use_second_file(self): # https://github.com/giampaolo/psutil/issues/981 @@ -874,7 +866,6 @@ class TestSystemCPUFrequency(PsutilTestCase): if freq[1].max != 0.0: self.assertEqual(freq[1].max, 600.0) - @unittest.skipIf(TRAVIS, "fails on Travis") @unittest.skipIf(not HAS_CPU_FREQ, "not supported") def test_emulate_no_scaling_cur_freq_file(self): # See: https://github.com/giampaolo/psutil/issues/1071 @@ -901,13 +892,11 @@ class TestSystemCPUFrequency(PsutilTestCase): @unittest.skipIf(not LINUX, "LINUX only") class TestSystemCPUStats(PsutilTestCase): - @unittest.skipIf(TRAVIS, "fails on Travis") 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) - @unittest.skipIf(TRAVIS, "fails on Travis") def test_interrupts(self): vmstat_value = vmstat("interrupts") psutil_value = psutil.cpu_stats().interrupts @@ -961,7 +950,6 @@ class TestSystemNetIfAddrs(PsutilTestCase): # XXX - not reliable when having virtual NICs installed by Docker. # @unittest.skipIf(not which('ip'), "'ip' utility not available") - # @unittest.skipIf(TRAVIS, "skipped on Travis") # def test_net_if_names(self): # out = sh("ip addr").strip() # nics = [x for x in psutil.net_if_addrs().keys() if ':' not in x] diff --git a/psutil/tests/test_memleaks.py b/psutil/tests/test_memleaks.py index 48a65dd5..ab6aac69 100755 --- a/psutil/tests/test_memleaks.py +++ b/psutil/tests/test_memleaks.py @@ -49,7 +49,6 @@ from psutil.tests import spawn_testproc from psutil.tests import system_namespace from psutil.tests import terminate from psutil.tests import TestMemoryLeak -from psutil.tests import TRAVIS from psutil.tests import unittest @@ -219,9 +218,8 @@ class TestProcessObjectLeaks(TestMemoryLeak): def test_cpu_affinity_set(self): affinity = thisproc.cpu_affinity() self.execute(lambda: self.proc.cpu_affinity(affinity)) - if not TRAVIS: - self.execute_w_exc( - ValueError, lambda: self.proc.cpu_affinity([-1])) + self.execute_w_exc( + ValueError, lambda: self.proc.cpu_affinity([-1])) @fewtimes_if_linux() def test_open_files(self): @@ -429,7 +427,6 @@ class TestModuleFunctionsLeaks(TestMemoryLeak): tolerance = 80 * 1024 if WINDOWS else self.tolerance self.execute(psutil.net_if_addrs, tolerance=tolerance) - # @unittest.skipIf(TRAVIS, "EPERM on travis") def test_net_if_stats(self): self.execute(psutil.net_if_stats) diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py index dac81859..81fa8f39 100755 --- a/psutil/tests/test_misc.py +++ b/psutil/tests/test_misc.py @@ -43,7 +43,6 @@ from psutil.tests import reload_module from psutil.tests import ROOT_DIR from psutil.tests import SCRIPTS_DIR from psutil.tests import sh -from psutil.tests import TRAVIS from psutil.tests import unittest import psutil import psutil.tests @@ -638,8 +637,6 @@ class TestWrapNumbers(PsutilTestCase): @unittest.skipIf(not os.path.exists(SCRIPTS_DIR), "can't locate scripts directory") -# XXX -@unittest.skipIf(TRAVIS and PYTHON_39, "unreliable on TRAVIS + PYTHON_39") class TestScripts(PsutilTestCase): """Tests for scripts in the "scripts" directory.""" @@ -713,8 +710,6 @@ class TestScripts(PsutilTestCase): def test_netstat(self): self.assert_stdout('netstat.py') - # permission denied on travis - @unittest.skipIf(TRAVIS, "unreliable on TRAVIS") def test_ifconfig(self): self.assert_stdout('ifconfig.py') @@ -751,14 +746,12 @@ class TestScripts(PsutilTestCase): self.assert_syntax('cpu_distribution.py') @unittest.skipIf(not HAS_SENSORS_TEMPERATURES, "not supported") - @unittest.skipIf(TRAVIS, "unreliable on TRAVIS") def test_temperatures(self): if not psutil.sensors_temperatures(): self.skipTest("no temperatures") self.assert_stdout('temperatures.py') @unittest.skipIf(not HAS_SENSORS_FANS, "not supported") - @unittest.skipIf(TRAVIS, "unreliable on TRAVIS") def test_fans(self): if not psutil.sensors_fans(): self.skipTest("no fans") diff --git a/psutil/tests/test_posix.py b/psutil/tests/test_posix.py index 54cf5ceb..d9513eed 100755 --- a/psutil/tests/test_posix.py +++ b/psutil/tests/test_posix.py @@ -32,7 +32,6 @@ from psutil.tests import retry_on_failure from psutil.tests import sh from psutil.tests import skip_on_access_denied from psutil.tests import terminate -from psutil.tests import TRAVIS from psutil.tests import unittest from psutil.tests import which @@ -307,7 +306,6 @@ class TestSystemAPIs(PsutilTestCase): # for some reason ifconfig -a does not report all interfaces # returned by psutil @unittest.skipIf(SUNOS, "unreliable on SUNOS") - @unittest.skipIf(TRAVIS, "unreliable on TRAVIS") @unittest.skipIf(not which('ifconfig'), "no ifconfig cmd") @unittest.skipIf(not HAS_NET_IO_COUNTERS, "not supported") def test_nic_names(self): diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index bf301ed0..af35a58c 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -40,7 +40,6 @@ from psutil._compat import super from psutil.tests import APPVEYOR from psutil.tests import call_until from psutil.tests import CI_TESTING -from psutil.tests import CIRRUS from psutil.tests import copyload_shared_lib from psutil.tests import create_exe from psutil.tests import GITHUB_ACTIONS @@ -64,7 +63,6 @@ from psutil.tests import sh from psutil.tests import skip_on_access_denied from psutil.tests import skip_on_not_implemented from psutil.tests import ThreadTask -from psutil.tests import TRAVIS from psutil.tests import unittest from psutil.tests import wait_for_pid @@ -295,7 +293,6 @@ class TestProcess(PsutilTestCase): time.strftime("%Y %m %d %H:%M:%S", time.localtime(p.create_time())) @unittest.skipIf(not POSIX, 'POSIX only') - @unittest.skipIf(TRAVIS or CIRRUS, 'not reliable on TRAVIS/CIRRUS') def test_terminal(self): terminal = psutil.Process().terminal() if terminal is not None: @@ -758,9 +755,6 @@ class TestProcess(PsutilTestCase): "import time; [time.sleep(0.01) for x in range(3000)];" "arg1", "arg2", "", "arg3", ""] p = self.spawn_psproc(cmdline) - # ...in order to try to prevent occasional failures on travis - if TRAVIS: - wait_for_pid(p.pid) self.assertEqual(p.cmdline(), cmdline) self.assertEqual(p.name(), os.path.basename(funky_path)) self.assertEqual(os.path.normcase(p.exe()), @@ -875,9 +869,7 @@ class TestProcess(PsutilTestCase): self.assertEqual(len(initial), len(set(initial))) all_cpus = list(range(len(psutil.cpu_percent(percpu=True)))) - # Work around travis failure: - # https://travis-ci.org/giampaolo/psutil/builds/284173194 - for n in all_cpus if not TRAVIS else initial: + for n in all_cpus: p.cpu_affinity([n]) self.assertEqual(p.cpu_affinity(), [n]) if hasattr(os, "sched_getaffinity"): @@ -902,9 +894,8 @@ class TestProcess(PsutilTestCase): self.assertRaises(TypeError, p.cpu_affinity, 1) p.cpu_affinity(initial) # it should work with all iterables, not only lists - if not TRAVIS: - p.cpu_affinity(set(all_cpus)) - p.cpu_affinity(tuple(all_cpus)) + p.cpu_affinity(set(all_cpus)) + p.cpu_affinity(tuple(all_cpus)) @unittest.skipIf(not HAS_CPU_AFFINITY, 'not supported') def test_cpu_affinity_errs(self): @@ -1310,14 +1301,10 @@ class TestProcess(PsutilTestCase): succeed_or_zombie_p_exc(fun) assert psutil.pid_exists(zproc.pid) - if not TRAVIS and MACOS: - # For some reason this started failing all of the sudden. - # Maybe they upgraded MACOS version? - # https://travis-ci.org/giampaolo/psutil/jobs/310896404 - self.assertIn(zproc.pid, psutil.pids()) - self.assertIn(zproc.pid, [x.pid for x in psutil.process_iter()]) - psutil._pmap = {} - self.assertIn(zproc.pid, [x.pid for x in psutil.process_iter()]) + self.assertIn(zproc.pid, psutil.pids()) + self.assertIn(zproc.pid, [x.pid for x in psutil.process_iter()]) + psutil._pmap = {} + self.assertIn(zproc.pid, [x.pid for x in psutil.process_iter()]) @unittest.skipIf(not POSIX, 'POSIX only') def test_zombie_process_is_running_w_exc(self): diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py index 69f318b4..4da4e784 100755 --- a/psutil/tests/test_system.py +++ b/psutil/tests/test_system.py @@ -48,7 +48,6 @@ from psutil.tests import mock from psutil.tests import PsutilTestCase from psutil.tests import PYPY from psutil.tests import retry_on_failure -from psutil.tests import TRAVIS from psutil.tests import GITHUB_ACTIONS from psutil.tests import UNICODE_SUFFIX from psutil.tests import unittest @@ -533,8 +532,6 @@ class TestCpuAPIs(PsutilTestCase): self.assertGreaterEqual(value, 0) ls = psutil.cpu_freq(percpu=True) - if TRAVIS and not ls: - raise self.skipTest("skipped on Travis") if FREEBSD and not ls: raise self.skipTest("returns empty list on FreeBSD") @@ -606,9 +603,6 @@ class TestDiskAPIs(PsutilTestCase): # all = False ls = psutil.disk_partitions(all=False) - # on travis we get: - # self.assertEqual(p.cpu_affinity(), [n]) - # AssertionError: Lists differ: [0, 1, 2, 3, 4, 5, 6, 7,... != [0] self.assertTrue(ls, msg=ls) for disk in ls: check_ntuple(disk) @@ -633,8 +627,7 @@ class TestDiskAPIs(PsutilTestCase): try: os.stat(disk.mountpoint) except OSError as err: - if (GITHUB_ACTIONS or TRAVIS) and \ - MACOS and err.errno == errno.EIO: + if GITHUB_ACTIONS and MACOS and err.errno == errno.EIO: continue # http://mail.python.org/pipermail/python-dev/ # 2012-June/120787.html @@ -655,7 +648,6 @@ class TestDiskAPIs(PsutilTestCase): mounts = [x.mountpoint.lower() for x in psutil.disk_partitions(all=True) if x.mountpoint] self.assertIn(mount, mounts) - psutil.disk_usage(mount) @unittest.skipIf(LINUX and not os.path.exists('/proc/diskstats'), '/proc/diskstats not available on this linux version') @@ -817,7 +809,6 @@ class TestNetAPIs(PsutilTestCase): else: self.assertEqual(addr.address, '06-3d-29-00-00-00') - @unittest.skipIf(TRAVIS, "unreliable on TRAVIS") # raises EPERM def test_net_if_stats(self): nics = psutil.net_if_stats() assert nics, nics diff --git a/psutil/tests/test_unicode.py b/psutil/tests/test_unicode.py index 7ec6c497..9edb8c89 100755 --- a/psutil/tests/test_unicode.py +++ b/psutil/tests/test_unicode.py @@ -90,7 +90,6 @@ from psutil.tests import ASCII_FS from psutil.tests import bind_unix_socket from psutil.tests import chdir from psutil.tests import CI_TESTING -from psutil.tests import CIRRUS from psutil.tests import copyload_shared_lib from psutil.tests import create_exe from psutil.tests import get_testfn @@ -124,9 +123,9 @@ if APPVEYOR: # https://github.com/giampaolo/psutil/blob/ # 68c7a70728a31d8b8b58f4be6c4c0baa2f449eda/psutil/arch/ # windows/process_info.c#L146 - from psutil.tests import safe_rmpath as _rm + from psutil.tests import safe_rmpath as rm try: - return _rm(path) + return rm(path) except WindowsError: traceback.print_exc() @@ -158,11 +157,22 @@ def try_unicode(suffix): # =================================================================== +class BaseUnicodeTest(PsutilTestCase): + funky_suffix = None + + def setUp(self): + if self.funky_suffix is not None: + if not try_unicode(self.funky_suffix): + raise self.skipTest("can't handle unicode str") + + @serialrun @unittest.skipIf(ASCII_FS, "ASCII fs") @unittest.skipIf(PYPY and not PY3, "too much trouble on PYPY2") -class _BaseFSAPIsTests(object): - funky_suffix = None +class TestFSAPIs(BaseUnicodeTest): + """Test FS APIs with a funky, valid, UTF8 path name.""" + + funky_suffix = UNICODE_SUFFIX @classmethod def setUpClass(cls): @@ -174,7 +184,12 @@ class _BaseFSAPIsTests(object): safe_rmpath(cls.funky_name) def expect_exact_path_match(self): - raise NotImplementedError("must be implemented in subclass") + # Do not expect psutil to correctly handle unicode paths on + # Python 2 if os.listdir() is not able either. + here = '.' if isinstance(self.funky_name, str) else u('.') + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + return self.funky_name in os.listdir(here) # --- @@ -243,7 +258,7 @@ class _BaseFSAPIsTests(object): conn = psutil.Process().connections('unix')[0] self.assertIsInstance(conn.laddr, str) # AF_UNIX addr not set on OpenBSD - if not OPENBSD and not CIRRUS: # XXX + if not OPENBSD: # XXX self.assertEqual(conn.laddr, name) @unittest.skipIf(not POSIX, "POSIX only") @@ -296,28 +311,8 @@ class _BaseFSAPIsTests(object): self.assertIsInstance(path, str) -# https://travis-ci.org/giampaolo/psutil/jobs/440073249 -# @unittest.skipIf(PYPY and TRAVIS, "unreliable on PYPY + TRAVIS") -# @unittest.skipIf(MACOS and TRAVIS, "unreliable on TRAVIS") # TODO -@unittest.skipIf(not try_unicode(UNICODE_SUFFIX), - "can't deal with unicode str") -class TestFSAPIs(_BaseFSAPIsTests, PsutilTestCase): - """Test FS APIs with a funky, valid, UTF8 path name.""" - funky_suffix = UNICODE_SUFFIX - - def expect_exact_path_match(self): - # Do not expect psutil to correctly handle unicode paths on - # Python 2 if os.listdir() is not able either. - here = '.' if isinstance(self.funky_name, str) else u('.') - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - return self.funky_name in os.listdir(here) - - @unittest.skipIf(CI_TESTING, "unreliable on CI") -@unittest.skipIf(not try_unicode(INVALID_UNICODE_SUFFIX), - "can't deal with invalid unicode str") -class TestFSAPIsWithInvalidPath(_BaseFSAPIsTests, PsutilTestCase): +class TestFSAPIsWithInvalidPath(TestFSAPIs): """Test FS APIs with a funky, invalid path name.""" funky_suffix = INVALID_UNICODE_SUFFIX @@ -332,8 +327,9 @@ class TestFSAPIsWithInvalidPath(_BaseFSAPIsTests, PsutilTestCase): # =================================================================== -class TestNonFSAPIS(PsutilTestCase): +class TestNonFSAPIS(BaseUnicodeTest): """Unicode tests for non fs-related APIs.""" + funky_suffix = UNICODE_SUFFIX if PY3 else 'è' @unittest.skipIf(not HAS_ENVIRON, "not supported") @unittest.skipIf(PYPY and WINDOWS, "segfaults on PYPY + WINDOWS") @@ -344,15 +340,14 @@ class TestNonFSAPIS(PsutilTestCase): # we use "è", which is part of the extended ASCII table # (unicode point <= 255). env = os.environ.copy() - funky_str = UNICODE_SUFFIX if PY3 else 'è' - env['FUNNY_ARG'] = funky_str + env['FUNNY_ARG'] = self.funky_suffix sproc = self.spawn_testproc(env=env) p = psutil.Process(sproc.pid) env = p.environ() for k, v in env.items(): self.assertIsInstance(k, str) self.assertIsInstance(v, str) - self.assertEqual(env['FUNNY_ARG'], funky_str) + self.assertEqual(env['FUNNY_ARG'], self.funky_suffix) if __name__ == '__main__': diff --git a/scripts/internal/download_wheels_github.py b/scripts/internal/download_wheels_github.py index 5623bb59..9de66fc2 100755 --- a/scripts/internal/download_wheels_github.py +++ b/scripts/internal/download_wheels_github.py @@ -57,12 +57,14 @@ def rename_win27_wheels(): # See: https://github.com/giampaolo/psutil/issues/810 src = 'dist/psutil-%s-cp27-cp27m-win32.whl' % PSUTIL_VERSION dst = 'dist/psutil-%s-cp27-none-win32.whl' % PSUTIL_VERSION - print("rename: %s\n %s" % (src, dst)) - os.rename(src, dst) + if os.path.exists(src): + print("rename: %s\n %s" % (src, dst)) + os.rename(src, dst) src = 'dist/psutil-%s-cp27-cp27m-win_amd64.whl' % PSUTIL_VERSION dst = 'dist/psutil-%s-cp27-none-win_amd64.whl' % PSUTIL_VERSION - print("rename: %s\n %s" % (src, dst)) - os.rename(src, dst) + if os.path.exists(src): + print("rename: %s\n %s" % (src, dst)) + os.rename(src, dst) def run(): diff --git a/scripts/internal/generate_manifest.py b/scripts/internal/generate_manifest.py index f760dd65..384fb329 100755 --- a/scripts/internal/generate_manifest.py +++ b/scripts/internal/generate_manifest.py @@ -13,8 +13,8 @@ import subprocess SKIP_EXTS = ('.png', '.jpg', '.jpeg') -SKIP_FILES = ('.cirrus.yml', '.travis.yml', 'appveyor.yml') -SKIP_PREFIXES = ('.ci/', '.github/', 'scripts/internal/') +SKIP_FILES = ('appveyor.yml') +SKIP_PREFIXES = ('.ci/', '.github/') def sh(cmd): diff --git a/scripts/internal/print_wheels.py b/scripts/internal/print_wheels.py index 3c966173..c2b8d36b 100755 --- a/scripts/internal/print_wheels.py +++ b/scripts/internal/print_wheels.py @@ -14,57 +14,83 @@ from psutil._common import print_color from psutil._common import bytes2human -def main(): - def is64bit(name): - return name.endswith(('x86_64.whl', 'amd64.whl')) +class Wheel: - groups = collections.defaultdict(list) - for path in glob.glob('dist/*.whl'): - name = os.path.basename(path) - plat = name.split('-')[-1] - pyimpl = name.split('-')[3] + def __init__(self, path): + self._path = path + self._name = os.path.basename(path) + + def __repr__(self): + return "<Wheel(name=%s, plat=%s, arch=%s, pyver=%s)>" % ( + self.name, self.platform(), self.arch(), self.pyver()) + + __str__ = __repr__ + + @property + def name(self): + return self._name + + def platform(self): + plat = self.name.split('-')[-1] + pyimpl = self.name.split('-')[3] ispypy = 'pypy' in pyimpl if 'linux' in plat: if ispypy: - groups['pypy_on_linux'].append(name) + return 'pypy_on_linux' else: - groups['linux'].append(name) + return 'linux' elif 'win' in plat: if ispypy: - groups['pypy_on_windows'].append(name) + return 'pypy_on_windows' else: - groups['windows'].append(name) + return 'windows' elif 'macosx' in plat: if ispypy: - groups['pypy_on_macos'].append(name) + return 'pypy_on_macos' else: - groups['macos'].append(name) + return 'macos' else: - assert 0, name + raise ValueError("unknown platform %r" % self.name) + + def arch(self): + if self.name.endswith(('x86_64.whl', 'amd64.whl')): + return '64' + return '32' + + def pyver(self): + pyver = 'pypy' if self.name.split('-')[3].startswith('pypy') else 'py' + pyver += self.name.split('-')[2][2:] + return pyver + + def size(self): + return os.path.getsize(self._path) + + +def main(): + groups = collections.defaultdict(list) + for path in glob.glob('dist/*.whl'): + wheel = Wheel(path) + groups[wheel.platform()].append(wheel) tot_files = 0 tot_size = 0 templ = "%-54s %7s %7s %7s" - for platf, names in groups.items(): - ppn = "%s (total = %s)" % (platf.replace('_', ' '), len(names)) + for platf, wheels in groups.items(): + ppn = "%s (total = %s)" % (platf, len(wheels)) s = templ % (ppn, "size", "arch", "pyver") print_color('\n' + s, color=None, bold=True) - for name in sorted(names): + for wheel in sorted(wheels, key=lambda x: x.name): tot_files += 1 - path = os.path.join('dist', name) - size = os.path.getsize(path) - tot_size += size - arch = '64' if is64bit(name) else '32' - pyver = 'pypy' if name.split('-')[3].startswith('pypy') else 'py' - pyver += name.split('-')[2][2:] - s = templ % (name, bytes2human(size), arch, pyver) - if 'pypy' in pyver: + tot_size += wheel.size() + s = templ % (wheel.name, bytes2human(wheel.size()), wheel.arch(), + wheel.pyver()) + if 'pypy' in wheel.pyver(): print_color(s, color='violet') else: print_color(s, color='brown') print_color("\ntotals: files=%s, size=%s" % ( - tot_files, bytes2human(tot_size)), bold=1) + tot_files, bytes2human(tot_size)), bold=True) if __name__ == '__main__': diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index faa2aea8..933951a2 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -208,12 +208,6 @@ def recursive_rm(*patterns): safe_rmtree(os.path.join(root, dir)) -def test_setup(): - os.environ['PYTHONWARNINGS'] = 'all' - os.environ['PSUTIL_TESTING'] = '1' - os.environ['PSUTIL_DEBUG'] = '1' - - # =================================================================== # commands # =================================================================== @@ -368,7 +362,6 @@ def clean(): "*__pycache__", ".coverage", ".failed-tests.txt", - ".tox", ) safe_rmtree("build") safe_rmtree(".coverage") @@ -398,7 +391,6 @@ def lint(): def test(name=RUNNER_PY): """Run tests""" build() - test_setup() sh("%s %s" % (PYTHON, name)) @@ -406,7 +398,6 @@ def coverage(): """Run coverage tests.""" # Note: coverage options are controlled by .coveragerc file build() - test_setup() sh("%s -m coverage run %s" % (PYTHON, RUNNER_PY)) sh("%s -m coverage report" % PYTHON) sh("%s -m coverage html" % PYTHON) @@ -416,70 +407,60 @@ def coverage(): def test_process(): """Run process tests""" build() - test_setup() sh("%s psutil\\tests\\test_process.py" % PYTHON) def test_system(): """Run system tests""" build() - test_setup() sh("%s psutil\\tests\\test_system.py" % PYTHON) def test_platform(): """Run windows only tests""" build() - test_setup() sh("%s psutil\\tests\\test_windows.py" % PYTHON) def test_misc(): """Run misc tests""" build() - test_setup() sh("%s psutil\\tests\\test_misc.py" % PYTHON) def test_unicode(): """Run unicode tests""" build() - test_setup() sh("%s psutil\\tests\\test_unicode.py" % PYTHON) def test_connections(): """Run connections tests""" build() - test_setup() sh("%s psutil\\tests\\test_connections.py" % PYTHON) def test_contracts(): """Run contracts tests""" build() - test_setup() sh("%s psutil\\tests\\test_contracts.py" % PYTHON) def test_testutils(): """Run test utilities tests""" build() - test_setup() sh("%s psutil\\tests\\test_testutils.py" % PYTHON) def test_by_name(name): """Run test by name""" build() - test_setup() sh("%s -m unittest -v %s" % (PYTHON, name)) def test_failed(): """Re-run tests which failed on last run.""" build() - test_setup() sh("%s %s --last-failed" % (PYTHON, RUNNER_PY)) @@ -514,14 +495,12 @@ def bench_oneshot_2(): def print_access_denied(): """Print AD exceptions raised by all Process methods.""" build() - test_setup() sh("%s -Wa scripts\\internal\\print_access_denied.py" % PYTHON) def print_api_speed(): """Benchmark all API calls.""" build() - test_setup() sh("%s -Wa scripts\\internal\\print_api_speed.py" % PYTHON) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index b148642b..00000000 --- a/tox.ini +++ /dev/null @@ -1,28 +0,0 @@ -# Tox (http://tox.testrun.org/) is a tool for running tests -# in multiple virtualenvs. This configuration file will run the -# test suite on all supported python versions. -# To use it run "pip install tox" and then run "tox" from this -# directory. - -[tox] -envlist = py26, py27, py34, py35, py36, py37, py38, lint - -[testenv] -deps = - py26: ipaddress - py26: mock==1.0.1 - py26: unittest2 - py27: ipaddress - py27: mock - -setenv = - TOX = 1 - -commands = python psutil/tests/runner.py - -usedevelop = True - -[testenv:lint] -deps = flake8 -commands = flake8 -skip_install = True |