Skip to content

Silencing stdout/stderr by default makes some errors extremely hard to debug #142

@exhuma

Description

@exhuma

Using pep517 to extract the project version number resulted in the following error:

Traceback (most recent call last):
  File "/usr/local/bin/get-version", line 7, in <module>
    meta = pep517.meta.load(".")
  File "/usr/local/lib/python3.9/site-packages/pep517/meta.py", line 71, in load
    path = Path(build_as_zip(builder))
  File "/usr/local/lib/python3.9/site-packages/pep517/meta.py", line 58, in build_as_zip
    builder(dest=out_dir)
  File "/usr/local/lib/python3.9/site-packages/pep517/meta.py", line 53, in build
    _prep_meta(hooks, env, dest)
  File "/usr/local/lib/python3.9/site-packages/pep517/meta.py", line 28, in _prep_meta
    reqs = hooks.get_requires_for_build_wheel({})
  File "/usr/local/lib/python3.9/site-packages/pep517/wrappers.py", line 179, in get_requires_for_build_wheel
    return self._call_hook('get_requires_for_build_wheel', {
  File "/usr/local/lib/python3.9/site-packages/pep517/wrappers.py", line 329, in _call_hook
    self._subprocess_runner(
  File "/usr/local/lib/python3.9/site-packages/pep517/wrappers.py", line 76, in quiet_subprocess_runner
    check_output(cmd, cwd=cwd, env=env, stderr=STDOUT)
  File "/usr/local/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/local/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/local/bin/python3', '/usr/local/lib/python3.9/site-packages/pep517/in_process/_in_process.py', 'get_requires_for_build_wheel', '/tmp/tmp5zbzjtns']' returned non-zero exit status 1.

Note that the line-numbers may not be representative as I had to resort to some fairly ugly print-debugging with a pinch of pdb.

After a lengthy session I found quiet_subprocess_runner which completely suppresses any output. Wrapping that with a try/except and printing the exception content has shown me this message:

b'0\n1\n2\nrunning egg_info\nerror: [Errno 13] Permission denied\n'

Which is pretty clear and helped me to fix the issue in my environment.

But this should not have taken me over an hour to fix. At least put a debug-log or something with the error to make it easier to detect. My first try was actually to set the root-logger level to DEBUG but I could also not see anything there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions