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

Commit

Permalink
Merge pull request #47 from giampaolo/master
Browse files Browse the repository at this point in the history
[pull] master from giampaolo:master
  • Loading branch information
pull[bot] authored May 5, 2023
2 parents 10ce894 + 5c52826 commit 2d67779
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 42 deletions.
70 changes: 35 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ PY2_DEPS = \
ipaddress \
mock
PY_DEPS = `$(PYTHON) -c \
"import sys; print('$(PY3_DEPS)' if sys.version_info[0] == 3 else '$(PY2_DEPS)')"`
"import sys; \
py3 = sys.version_info[0] == 3; \
py38 = sys.version_info[:2] >= (3, 8); \
py3_extra = ' abi3audit' if py38 else ''; \
print('$(PY3_DEPS)' + py3_extra if py3 else '$(PY2_DEPS)')"`
NUM_WORKERS = `$(PYTHON) -c "import os; print(os.cpu_count() or 1)"`
# "python3 setup.py build" can be parallelized on Python >= 3.6.
BUILD_OPTS = `$(PYTHON) -c \
Expand All @@ -50,7 +54,7 @@ INSTALL_OPTS = `$(PYTHON) -c \
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
.DEFAULT_GOAL := help

# ===================================================================
# Install
Expand Down Expand Up @@ -234,9 +238,13 @@ install-git-hooks: ## Install GIT pre-commit hook.
chmod +x .git/hooks/pre-commit

# ===================================================================
# Wheels
# Distribution
# ===================================================================

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

download-wheels-github: ## Download latest wheels hosted on github.
$(PYTHON) scripts/internal/download_wheels_github.py --tokenfile=~/.github.token
${MAKE} print-dist
Expand All @@ -245,43 +253,26 @@ download-wheels-appveyor: ## Download latest wheels hosted on appveyor.
$(PYTHON) scripts/internal/download_wheels_appveyor.py
${MAKE} print-dist

print-dist: ## Print downloaded wheels / tar.gs
$(PYTHON) scripts/internal/print_dist.py

# ===================================================================
# Distribution
# ===================================================================

git-tag-release: ## Git-tag a new release.
git tag -a release-`python3 -c "import setup; print(setup.get_version())"` -m `git rev-list HEAD --count`:`git rev-parse --short HEAD`
git push --follow-tags

sdist: ## Create tar.gz source distribution.
${MAKE} generate-manifest
$(PYTHON) setup.py sdist
$(PYTHON) -m twine check --strict dist/*.tar.gz

# --- others

check-sdist: ## Create source distribution and checks its sanity (MANIFEST)
rm -rf dist
${MAKE} clean
check-sdist: ## Check sanity of source distribution.
$(PYTHON) -m virtualenv --clear --no-wheel --quiet build/venv
PYTHONWARNINGS=all $(PYTHON) setup.py sdist
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) -m twine check --strict dist/*.tar.gz

check-wheels: ## Check sanity of wheels.
$(PYTHON) -m abi3audit --verbose --strict dist/*-abi3-*.whl
$(PYTHON) -m twine check --strict dist/*.whl

pre-release: ## Check if we're ready to produce a new release.
${MAKE} clean
${MAKE} sdist
${MAKE} check-sdist
${MAKE} install
${MAKE} generate-manifest
git diff MANIFEST.in > /dev/null # ...otherwise 'git diff-index HEAD' will complain
${MAKE} sdist
${MAKE} download-wheels-github
${MAKE} download-wheels-appveyor
${MAKE} check-wheels
${MAKE} print-hashes
${MAKE} print-dist
$(PYTHON) -m twine check --strict dist/*
$(PYTHON) -c \
"from psutil import __version__ as ver; \
doc = open('docs/index.rst').read(); \
Expand All @@ -290,17 +281,23 @@ pre-release: ## Check if we're ready to produce a new release.
assert ver in history, '%r not in HISTORY.rst' % ver; \
assert 'XXXX' not in history, 'XXXX in HISTORY.rst';"

release: ## Create a release (down/uploads tar.gz, wheels, git tag release).
$(PYTHON) -m twine check --strict dist/*
$(PYTHON) -m twine upload dist/* # upload tar.gz and Windows wheels on PyPI
release: ## Upload a new release.
${MAKE} check-sdist
${MAKE} check-wheels
$(PYTHON) -m twine upload dist/*.tar.gz
$(PYTHON) -m twine upload dist/*.whl
${MAKE} git-tag-release

check-manifest: ## Inspect MANIFEST.in file.
$(PYTHON) -m check_manifest -v $(ARGS)

generate-manifest: ## Generates MANIFEST.in file.
$(PYTHON) scripts/internal/generate_manifest.py > MANIFEST.in

print-dist: ## Print downloaded wheels / tar.gs
$(PYTHON) scripts/internal/print_dist.py

git-tag-release: ## Git-tag a new release.
git tag -a release-`python3 -c "import setup; print(setup.get_version())"` -m `git rev-list HEAD --count`:`git rev-parse --short HEAD`
git push --follow-tags

# ===================================================================
# Printers
# ===================================================================
Expand Down Expand Up @@ -343,5 +340,8 @@ bench-oneshot-2: ## Same as above but using perf module (supposed to be more pr
check-broken-links: ## Look for broken links in source files.
git ls-files | xargs $(PYTHON) -Wa scripts/internal/check_broken_links.py

check-manifest: ## Inspect MANIFEST.in file.
$(PYTHON) -m check_manifest -v $(ARGS)

help: ## Display callable targets.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
| |downloads| |stars| |forks| |contributors| |coverage|
| |version| |py-versions| |packages| |license|
| |github-actions-wheels| |github-actions-bsd| |appveyor| |doc| |twitter| |tidelift|
| |version| |py-versions| |packages| |license| |twitter| |tidelift|
| |github-actions-wheels| |github-actions-bsd| |appveyor| |doc|
.. |downloads| image:: https://img.shields.io/pypi/dm/psutil.svg
:target: https://pepy.tech/project/psutil
Expand Down
10 changes: 6 additions & 4 deletions psutil/_psbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from ._common import ZombieProcess
from ._common import conn_tmap
from ._common import conn_to_ntuple
from ._common import debug
from ._common import memoize
from ._common import memoize_when_activated
from ._common import usage_percent
Expand Down Expand Up @@ -662,10 +663,10 @@ def cmdline(self):
if OPENBSD and self.pid == 0:
return [] # ...else it crashes
elif NETBSD:
# XXX - most of the times the underlying sysctl() call on Net
# and Open BSD returns a truncated string.
# Also /proc/pid/cmdline behaves the same so it looks
# like this is a kernel bug.
# XXX - most of the times the underlying sysctl() call on
# NetBSD and OpenBSD returns a truncated string. Also
# /proc/pid/cmdline behaves the same so it looks like this
# is a kernel bug.
try:
return cext.proc_cmdline(self.pid)
except OSError as err:
Expand All @@ -677,6 +678,7 @@ def cmdline(self):
else:
# XXX: this happens with unicode tests. It means the C
# routine is unable to decode invalid unicode chars.
debug("ignoring %r and returning an empty list" % err)
return []
else:
raise
Expand Down
3 changes: 2 additions & 1 deletion psutil/tests/test_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,9 @@ def test_users_started(self):
started = [x.capitalize() for x in started]

if not tstamp:
raise ValueError(
raise unittest.SkipTest(
"cannot interpret tstamp in who output\n%s" % (out))

with self.subTest(psutil=psutil.users(), who=out):
for idx, u in enumerate(psutil.users()):
psutil_value = datetime.datetime.fromtimestamp(
Expand Down

0 comments on commit 2d67779

Please sign in to comment.