Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small inconsistency in usage message between the python and shell script versions of python-config #89264

Closed
kiendang mannequin opened this issue Sep 4, 2021 · 3 comments
Labels
3.13 bugs and security fixes build The build process and cross-build type-bug An unexpected behavior, bug, or error

Comments

@kiendang
Copy link
Mannequin

kiendang mannequin commented Sep 4, 2021

BPO 45101
Nosy @merwok, @kiendang
PRs
  • bpo-45101: Add consistency in usage message IO between 2 versions of python-config #28162
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2021-09-04.18:32:12.094>
    labels = ['type-bug', '3.11']
    title = 'Small inconsistency in usage message between the python and shell script versions of python-config'
    updated_at = <Date 2021-09-23.20:57:44.512>
    user = 'https://github.com/kiendang'

    bugs.python.org fields:

    activity = <Date 2021-09-23.20:57:44.512>
    actor = 'kiendang'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Demos and Tools']
    creation = <Date 2021-09-04.18:32:12.094>
    creator = 'kiendang'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45101
    keywords = ['patch']
    message_count = 3.0
    messages = ['401054', '401612', '402526']
    nosy_count = 2.0
    nosy_names = ['eric.araujo', 'kiendang']
    pr_nums = ['28162']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45101'
    versions = ['Python 3.11']

    @kiendang
    Copy link
    Mannequin Author

    kiendang mannequin commented Sep 4, 2021

    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.

    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)

    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.

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

    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.

    @kiendang kiendang mannequin added 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes type-bug An unexpected behavior, bug, or error labels Sep 4, 2021
    @merwok
    Copy link
    Member

    merwok commented Sep 10, 2021

    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.

    @merwok merwok removed 3.9 only security fixes 3.10 only security fixes labels Sep 10, 2021
    @kiendang
    Copy link
    Mannequin Author

    kiendang mannequin commented Sep 23, 2021

    Thanks. I didn't know about the pkg-config thing. I just checked with pkg-config on macOS

    pkg-config --help prints usage instructions to stdout

    pkg-config followed by invalid options prints output to stderr, for example pkg-config --asdf prints Unknown option --asdf to stderr.

    The PR I submitted does something similar, making both python and shell script versions of python-config to print out the usage instruction message to stdout when --help is provided and stderr when given invalid arguments.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel iritkatriel added the build The build process and cross-build label Nov 26, 2023
    @serhiy-storchaka serhiy-storchaka added 3.13 bugs and security fixes and removed 3.11 only security fixes labels Feb 26, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.13 bugs and security fixes build The build process and cross-build type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants