From 795aa9ac92b4b747977d2b3a481fcfdb757a030c Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Fri, 22 Sep 2023 19:21:01 +0200 Subject: [PATCH] pyproject.toml support without setup.py Fixes: #85 --- NEWS | 8 +++++++ README.md | 44 +++++++++++++++++++++++++------------- build_manpages/__init__.py | 3 +++ 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index c33fdac..cbac978 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,14 @@ WARNING: We'll drop the Python 2.7 support in v5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +News in v4.5 + +* We newly provide `build_manpages.build_py` and `build_manpages.install` + command classes that are re-usable from `pyproject.toml`. No need to + provide `setup.py` because of `argparse-manpage`. Solved issue#85. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + News in v4.4 * The `prog=` specifier (in setup.py/setup.cfg/pyproject.toml) is now diff --git a/README.md b/README.md index 7b6d85c..e6193f0 100644 --- a/README.md +++ b/README.md @@ -47,18 +47,19 @@ Alternatively those options above can be combined with variable. -## Use with setup.py +## Use with pyproject.toml -First, you need to declare that `setup.py` uses an external package in your -`pyproject.toml` file: +First, you need to declare in `pyproject.toml` that argparse-manpage is needed +at build-time and use the setuptools.builds_meta` backend: ```toml [build-system] requires = ["argparse-manpage[setuptools]"] +build-backend = "setuptools.build_meta" ``` -Alternatively you can place the `build_manpages` (sub)directory from this -project somewhere onto `PYTHONPATH` so you can use it in `setup.py`. For +Alternatively, you can place the `build_manpages` (sub)directory from this +project somewhere onto `PYTHONPATH` so you can use it at build time. For example: ```bash @@ -66,6 +67,28 @@ git submodule add --name build_manpages https://github.com/praiskup/build_manpag git submodule update --init ``` +Then in `pyproject.toml` (re)define `cmdclass` commands: + +```toml +[tool.setuptools.cmdclass] +build_py = "build_manpages.build_py" +install = "build_manpages.install" +build_manpages = "build_manpages.build_manpages" +``` + +And specify the list of built manual pages: + +```toml +[tool.build_manpages] +manpages = [ + "man/foo.1:object=parser:pyfile=bin/foo.py", + "man/bar.1:function=get_parser:pyfile=bin/bar", + "man/baz.1:function=get_parser:pyfile=bin/bar:prog=baz", +] +``` + +## Use with setup.py + In your `setup.py` use pattern like: ```python @@ -95,16 +118,7 @@ manpages = man/baz.1:function=get_parser:pyfile=bin/bar:prog=baz ``` -Or in `pyproject.toml` (requires setuptools >= 62.2.0): - -```toml -[tool.build_manpages] -manpages = [ - "man/foo.1:object=parser:pyfile=bin/foo.py", - "man/bar.1:function=get_parser:pyfile=bin/bar", - "man/baz.1:function=get_parser:pyfile=bin/bar:prog=baz", -] -``` +## List of manual pages The format of those lines is a colon separated list of arguments/options. The first argument determines the filename of the generated manual page. Then diff --git a/build_manpages/__init__.py b/build_manpages/__init__.py index caeb501..7a6a906 100644 --- a/build_manpages/__init__.py +++ b/build_manpages/__init__.py @@ -4,3 +4,6 @@ from argparse_manpage import __version__ from .build_manpages import build_manpages, get_build_py_cmd, get_install_cmd + +install = get_install_cmd() +build_py = get_build_py_cmd()