From e6d06161b35c1965ced8b89da68e439e6403149a Mon Sep 17 00:00:00 2001 From: layday Date: Thu, 11 May 2023 16:32:38 +0300 Subject: [PATCH 1/2] main: limit help text width --- src/build/__main__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/build/__main__.py b/src/build/__main__.py index 916964b3..5f2c51cf 100644 --- a/src/build/__main__.py +++ b/src/build/__main__.py @@ -16,6 +16,7 @@ import warnings from collections.abc import Iterator, Sequence +from functools import partial from typing import NoReturn, TextIO import build @@ -275,7 +276,12 @@ def main_parser() -> argparse.ArgumentParser: ).strip(), ' ', ), - formatter_class=argparse.RawTextHelpFormatter, + formatter_class=partial( + argparse.RawDescriptionHelpFormatter, + # Prevent argparse from taking up the entire width of the terminal window + # which impedes readability. + width=min(shutil.get_terminal_size().columns - 2, 127), + ), ) parser.add_argument( 'srcdir', From 971a782a37c4f7ee4419555769948d85c68ada5a Mon Sep 17 00:00:00 2001 From: layday Date: Thu, 11 May 2023 16:34:16 +0300 Subject: [PATCH 2/2] main: improve help text Closes https://github.com/pypa/build/issues/613. --- src/build/__main__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/build/__main__.py b/src/build/__main__.py index 5f2c51cf..743c28a9 100644 --- a/src/build/__main__.py +++ b/src/build/__main__.py @@ -313,6 +313,7 @@ def main_parser() -> argparse.ArgumentParser: '-o', type=str, help=f'output directory (defaults to {{srcdir}}{os.sep}dist)', + metavar='PATH', ) parser.add_argument( '--skip-dependency-check', @@ -324,14 +325,17 @@ def main_parser() -> argparse.ArgumentParser: '--no-isolation', '-n', action='store_true', - help='do not isolate the build in a virtual environment', + help='disable building the project in an isolated virtual environment. ' + 'Build dependencies must be installed separately when this option is used', ) parser.add_argument( '--config-setting', '-C', action='append', - help='pass options to the backend. options which begin with a hyphen must be in the form of ' - '"--config-setting=--opt(=value)" or "-C--opt(=value)"', + help='settings to pass to the backend. Multiple settings can be provided. ' + 'Settings beginning with a hyphen will erroneously be interpreted as options to build if separated ' + 'by a space character; use ``--config-setting=--my-setting -C--my-other-setting``', + metavar='KEY[=VALUE]', ) return parser