Skip to content

Commit

Permalink
pyproject.toml support without setup.py
Browse files Browse the repository at this point in the history
Fixes: #85
  • Loading branch information
praiskup committed Sep 22, 2023
1 parent 6847721 commit 795aa9a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
8 changes: 8 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 29 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,48 @@ 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
git submodule add --name build_manpages https://github.com/praiskup/build_manpages
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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions build_manpages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 795aa9a

Please sign in to comment.