Make %pyproject_buildrequires and %pyproject_save_files argparser errors nicer to macro users
Before: %pyproject_buildrequires bogus_arg usage: pyproject_buildrequires.py [-h] [-r] [-w] [--wheeldir PATH] [-R] [-e TOXENVS] [-t] [-x EXTRAS] [--generate-extras] [-p PYTHON3_PKGVERSION] [-N] [requirement_files ...] pyproject_buildrequires.py: error: argument requirement_files: can't open 'bogus_arg': ... %pyproject_save_files ... usage: pyproject_save_files.py [-h] --output-files OUTPUT_FILES --output-modules OUTPUT_MODULES --buildroot BUILDROOT --sitelib SITELIB --sitearch SITEARCH --python-version PYTHON_VERSION --pyproject-record PYPROJECT_RECORD --prefix PREFIX varargs [varargs ...] pyproject_save_files.py: error: the following arguments are required: varargs After: %pyproject_buildrequires bogus_arg usage: %pyproject_buildrequires [-w] [-R] [-e TOXENVS] [-t] [-x EXTRAS] [-N] [REQUIREMENTS.TXT ...] %pyproject_buildrequires: error: argument REQUIREMENTS.TXT: can't open 'bogus_arg': ... %pyproject_save_files ... usage: %pyproject_save_files MODULE_GLOB [MODULE_GLOB ...] [+auto] %pyproject_save_files: error: the following arguments are required: MODULE_GLOB
This commit is contained in:
parent
516e1511a7
commit
222ec5f4f5
@ -424,11 +424,18 @@ def generate_requires(
|
||||
|
||||
def main(argv):
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Generate BuildRequires for a Python project.'
|
||||
description='Generate BuildRequires for a Python project.',
|
||||
prog='%pyproject_buildrequires',
|
||||
add_help=False,
|
||||
)
|
||||
parser.add_argument(
|
||||
'--help', action='help',
|
||||
default=argparse.SUPPRESS,
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
parser.add_argument(
|
||||
'-r', '--runtime', action='store_true', default=True,
|
||||
help='Generate run-time requirements (default, disable with -R)',
|
||||
help=argparse.SUPPRESS, # Generate run-time requirements (backwards-compatibility only)
|
||||
)
|
||||
parser.add_argument(
|
||||
'-w', '--wheel', action='store_true', default=False,
|
||||
@ -437,7 +444,7 @@ def main(argv):
|
||||
)
|
||||
parser.add_argument(
|
||||
'--wheeldir', metavar='PATH', default=None,
|
||||
help='The directory with wheel, used when -w.',
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
parser.add_argument(
|
||||
'-R', '--no-runtime', action='store_false', dest='runtime',
|
||||
@ -460,12 +467,11 @@ def main(argv):
|
||||
)
|
||||
parser.add_argument(
|
||||
'--generate-extras', action='store_true',
|
||||
help='Generate build requirements on Python Extras',
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
parser.add_argument(
|
||||
'-p', '--python3_pkgversion', metavar='PYTHON3_PKGVERSION',
|
||||
default="3", help=('Python version for pythonXdist()'
|
||||
'or pythonX.Ydist() requirements'),
|
||||
default="3", help=argparse.SUPPRESS,
|
||||
)
|
||||
parser.add_argument(
|
||||
'-N', '--no-use-build-system', dest='use_build_system',
|
||||
@ -473,6 +479,7 @@ def main(argv):
|
||||
)
|
||||
parser.add_argument(
|
||||
'requirement_files', nargs='*', type=argparse.FileType('r'),
|
||||
metavar='REQUIREMENTS.TXT',
|
||||
help=('Add buildrequires from file'),
|
||||
)
|
||||
|
||||
|
@ -742,17 +742,31 @@ def main(cli_args):
|
||||
|
||||
|
||||
def argparser():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Create %{pyproject_files} for a Python project.",
|
||||
prog="%pyproject_save_files",
|
||||
add_help=False,
|
||||
# custom usage to add +auto
|
||||
usage="%(prog)s MODULE_GLOB [MODULE_GLOB ...] [+auto]",
|
||||
)
|
||||
parser.add_argument(
|
||||
'--help', action='help',
|
||||
default=argparse.SUPPRESS,
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
r = parser.add_argument_group("required arguments")
|
||||
r.add_argument("--output-files", type=PosixPath, required=True)
|
||||
r.add_argument("--output-modules", type=PosixPath, required=True)
|
||||
r.add_argument("--buildroot", type=PosixPath, required=True)
|
||||
r.add_argument("--sitelib", type=BuildrootPath, required=True)
|
||||
r.add_argument("--sitearch", type=BuildrootPath, required=True)
|
||||
r.add_argument("--python-version", type=str, required=True)
|
||||
r.add_argument("--pyproject-record", type=PosixPath, required=True)
|
||||
r.add_argument("--prefix", type=PosixPath, required=True)
|
||||
parser.add_argument("varargs", nargs="+")
|
||||
r.add_argument("--output-files", type=PosixPath, required=True, help=argparse.SUPPRESS)
|
||||
r.add_argument("--output-modules", type=PosixPath, required=True, help=argparse.SUPPRESS)
|
||||
r.add_argument("--buildroot", type=PosixPath, required=True, help=argparse.SUPPRESS)
|
||||
r.add_argument("--sitelib", type=BuildrootPath, required=True, help=argparse.SUPPRESS)
|
||||
r.add_argument("--sitearch", type=BuildrootPath, required=True, help=argparse.SUPPRESS)
|
||||
r.add_argument("--python-version", type=str, required=True, help=argparse.SUPPRESS)
|
||||
r.add_argument("--pyproject-record", type=PosixPath, required=True, help=argparse.SUPPRESS)
|
||||
r.add_argument("--prefix", type=PosixPath, required=True, help=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
"varargs", nargs="+", metavar="MODULE_GLOB",
|
||||
help="Shell-like glob matching top-level module names to save into %%{pyproject_files}",
|
||||
)
|
||||
return parser
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user