classification
Title: Small inconsistency in usage message between the python and shell script versions of python-config
Type: behavior Stage: patch review
Components: Demos and Tools Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, kiendang
Priority: normal Keywords: patch

Created on 2021-09-04 18:32 by kiendang, last changed 2021-09-10 19:53 by eric.araujo.

Pull Requests
URL Status Linked Edit
PR 28162 open kiendang, 2021-09-04 18:38
Messages (2)
msg401054 - (view) Author: Kien Dang (kiendang) * Date: 2021-09-04 18:32
`python-config` outputs a usage instruction message in case either the `--help` option or invalid arguments are provided.

However there is a small different in the output I/O between the python and shell script versions of `python-config`. In the python version, the message always prints to `stderr`.

https://github.com/python/cpython/blob/bc1c49fa94b2abf70e6937373bf1e6b5378035c5/Misc/python-config.in#L15-L18

def exit_with_usage(code=1):
    print("Usage: {0} [{1}]".format(
        sys.argv[0], '|'.join('--'+opt for opt in valid_opts)), file=sys.stderr)
    sys.exit(code)

while in the shell script version it always prints to `stdout`.

https://github.com/python/cpython/blob/bc1c49fa94b2abf70e6937373bf1e6b5378035c5/Misc/python-config.sh.in#L5-L9

exit_with_usage ()
{
    echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed"
    exit $1
}

This inconsistency does not affect most users of `python-config`, who runs the script interactively. However it might cause issues when run programmatically.
msg401612 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2021-09-10 19:53
I think python-config is modelled after pkg-config: what does the latter do?

Also, I’m not sure it would be appropriate to change behaviour in existing releases.
History
Date User Action Args
2021-09-10 19:53:48eric.araujosetnosy: + eric.araujo

messages: + msg401612
versions: - Python 3.9, Python 3.10
2021-09-04 18:38:18kiendangsetkeywords: + patch
stage: patch review
pull_requests: + pull_request26594
2021-09-04 18:32:12kiendangcreate