On some container, such as manylinux_2_39_riscv64, based on Rocky Linux, ps utility is not installed by default, making some test to fail:
=================================== FAILURES ===================================
______________________________ test_setproctitle _______________________________
def test_setproctitle():
"""setproctitle() can set the process title, duh."""
rv = run_script(
r"""
import setproctitle
setproctitle.setproctitle('Hello, world!')
import os
print(os.getpid())
# ps can fail on kfreebsd arch
# (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=460331)
print(os.popen("ps -x -o pid,command 2> /dev/null").read())
"""
)
lines = [line for line in rv.splitlines() if line]
pid = lines.pop(0)
pids = dict([r.strip().split(None, 1) for r in lines])
> title = _clean_up_title(pids[pid])
E KeyError: '150'
/project/tests/setproctitle_test.py:68: KeyError
_________________________________ test_issue_8 _________________________________
tmp_pypath = PosixPath('/tmp/pytest-of-root/pytest-0/test_issue_80')
def test_issue_8(tmp_pypath):
"""Test that the module works with 'python -m'."""
module = "spt_issue_8"
with open(tmp_pypath / f"{module}.py", "w") as f:
f.write(
r"""
import setproctitle
setproctitle.setproctitle("Hello, module!")
import os
print(os.getpid())
print(os.popen("ps -x -o pid,command 2> /dev/null").read())
"""
)
rv = run_script(args="-m " + module)
lines = [line for line in rv.splitlines() if line]
pid = lines.pop(0)
pids = dict([r.strip().split(None, 1) for r in lines])
> title = _clean_up_title(pids[pid])
E KeyError: '159'
/project/tests/setproctitle_test.py:192: KeyError
______________________________ test_large_cmdline ______________________________
tmp_pypath = PosixPath('/tmp/pytest-of-root/pytest-0/test_large_cmdline0')
def test_large_cmdline(tmp_pypath):
"""Test with a 64KB command line."""
module = "longargs"
with open(tmp_pypath / f"{module}.py", "w") as f:
f.write(
r"""
import setproctitle
setproctitle.setproctitle("Hello, long!")
import os
print(os.getpid())
print(os.popen("ps -x -o pid,command 2> /dev/null").read())
"""
)
rv = run_script(args=f"-m {module} {' '.join(['X' * 1024] * 64)}")
lines = [line for line in rv.splitlines() if line]
pid = lines.pop(0)
pids = dict([r.strip().split(None, 1) for r in lines])
> title = _clean_up_title(pids[pid])
E KeyError: '162'
/project/tests/setproctitle_test.py:216: KeyError
_________________________________ test_unicode _________________________________
def test_unicode():
"""Title can contain unicode characters."""
snowman = "\u2603"
try:
snowman.encode(sys.getdefaultencoding())
except UnicodeEncodeError:
pytest.skip(
"default encoding '%s' can't deal with snowmen"
% sys.getdefaultencoding()
)
try:
snowman.encode(sys.getfilesystemencoding())
except UnicodeEncodeError:
pytest.skip(
"file system encoding '%s' can't deal with snowmen"
% sys.getfilesystemencoding()
)
rv = run_script(
r"""
snowman = u'\u2603'
import setproctitle
setproctitle.setproctitle("Hello, " + snowman + "!")
import os
import locale
from subprocess import Popen, PIPE
print(os.getpid())
proc = Popen("ps -x -o pid,command 2> /dev/null", shell=True,
close_fds=True, stdout=PIPE, stderr=PIPE)
buf = proc.stdout.read()
print(buf.decode(locale.getpreferredencoding(), 'replace'))
"""
)
lines = [line for line in rv.splitlines() if line]
pid = lines.pop(0)
pids = dict([r.strip().split(None, 1) for r in lines])
snowmen = [
"\u2603", # ps supports unicode
r"\M-b\M^X\M^C", # ps output on BSD
r"M-bM^XM^C", # ps output on some Darwin < 11.2
"\ufffdM^XM^C", # ps output on Darwin 11.2
]
> title = _clean_up_title(pids[pid])
E KeyError: '165'
/project/tests/setproctitle_test.py:266: KeyError
_______________________________ test_weird_args ________________________________
def test_weird_args():
"""No problem with encoded arguments."""
euro = "\u20ac"
snowman = "\u2603"
try:
rv = run_script(
r"""
import setproctitle
setproctitle.setproctitle("Hello, weird args!")
import os
print(os.getpid())
print(os.popen("ps -x -o pid,command 2> /dev/null").read())
""",
args=" ".join(["-", "hello", euro, snowman]),
)
except TypeError:
pytest.skip("apparently we can't pass unicode args to a program")
lines = [line for line in rv.splitlines() if line]
pid = lines.pop(0)
pids = dict([r.strip().split(None, 1) for r in lines])
> title = _clean_up_title(pids[pid])
E KeyError: '168'
/project/tests/setproctitle_test.py:297: KeyError
_______________________________ test_weird_path ________________________________
tmp_path = PosixPath('/tmp/pytest-of-root/pytest-0/test_weird_path0')
spt_directory = '/tmp/tmp.xz8WNoRJrN/venv/lib/python3.8/site-packages'
def test_weird_path(tmp_path, spt_directory):
"""No problem with encoded argv[0] path."""
_check_4388()
euro = "\u20ac"
snowman = "\u2603"
dir = tmp_path / euro / snowman
try:
os.makedirs(dir)
except UnicodeEncodeError:
pytest.skip("file system doesn't support unicode")
exc = dir / os.path.basename(sys.executable)
os.symlink(sys.executable, exc)
rv = run_script(
f"""
import sys
sys.path.insert(0, {repr(spt_directory)})
import setproctitle
setproctitle.setproctitle("Hello, weird path!")
import os
print(os.getpid())
print(os.popen("ps -x -o pid,command 2> /dev/null").read())
""",
args=" ".join(["-", "foo", "bar", "baz"]),
executable=exc,
)
lines = [line for line in rv.splitlines() if line]
pid = lines.pop(0)
pids = dict([r.strip().split(None, 1) for r in lines])
> title = _clean_up_title(pids[pid])
E KeyError: '173'
/project/tests/setproctitle_test.py:334: KeyError
=========================== short test summary info ============================
FAILED ../../../project/tests/setproctitle_test.py::test_setproctitle - KeyError: '150'
FAILED ../../../project/tests/setproctitle_test.py::test_issue_8 - KeyError: '159'
FAILED ../../../project/tests/setproctitle_test.py::test_large_cmdline - KeyError: '162'
FAILED ../../../project/tests/setproctitle_test.py::test_unicode - KeyError: '165'
FAILED ../../../project/tests/setproctitle_test.py::test_weird_args - KeyError: '168'
FAILED ../../../project/tests/setproctitle_test.py::test_weird_path - KeyError: '173'
============ 6 failed, 17 passed, 3 skipped, 2 deselected in 5.71s =============
This is an important issue, because this is the container image used by cibuildwheel on newer version. We need a recent version because we are building and deploying py-setproctitle for riscv64, and riscv64 is supported only on latest version.
I can help fixing the bug by submitting a patch, just let me know how you would like to handle this: skip test if ps is missing? add a script to check and install system dependencies?
On some container, such as manylinux_2_39_riscv64, based on Rocky Linux, ps utility is not installed by default, making some test to fail:
This is an important issue, because this is the container image used by cibuildwheel on newer version. We need a recent version because we are building and deploying py-setproctitle for riscv64, and riscv64 is supported only on latest version.
I can help fixing the bug by submitting a patch, just let me know how you would like to handle this: skip test if ps is missing? add a script to check and install system dependencies?