Skip to content

Commit 12befce

Browse files
committed
README: Update packaging overview
Signed-off-by: Stephen Finucane <[email protected]>
1 parent 93488b9 commit 12befce

File tree

1 file changed

+47
-31
lines changed

1 file changed

+47
-31
lines changed

README.md

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ where `foo` is the name of your script, as defined in [`console_scripts`](https:
2222
pip install click-man
2323
```
2424

25-
## Usage Recipes
25+
## Usage
2626

2727
The following sections describe different usage example for *click-man*.
2828

29-
### Use with a previously installed package
29+
### CLI
3030

31-
**click-man** provides its own command line tool which can be passed the name of
32-
an installed script:
31+
**click-man** provides its own command line tool which can be passed the name of an installed script:
3332

3433
```bash
3534
click-man commandname
@@ -43,17 +42,57 @@ To specify a target directory for the man pages, use the `--target` option:
4342
click-man --target path/to/man/pages commandname
4443
```
4544

45+
You can use the `manpath` command or `MANPATH` environment variable to identify where man pages can be placed.
46+
4647
### Automatic man page installation with setuptools and pip
4748

48-
This approach of installing man pages is problematic for various reasons:
49+
While earlier version of click-man provided a distutils hook that could be used to automatically install man pages,
50+
this approach had a number of caveats as outlined [below][issues-with-automatic-man-page-installation].
51+
distutils was removed from Python stdlib in Python 3.12 and the distutils hook was removed from **click-man** in v0.5.0.
52+
53+
### Debian packages
54+
55+
The `debhelper` packages provides a very convenient script called `dh_installman`.
56+
It checks for the `debian/(pkg_name.)manpages` file and it's content which is basically a line by line list of man pages or globs:
57+
58+
```
59+
debian/tmp/manpages/*
60+
```
61+
62+
We override the rule provided by `dh_installman` to generate our man pages in advance, like this:
63+
64+
```Makefile
65+
override_dh_installman:
66+
click-man <executable> --target debian/tmp/manpages
67+
dh_installman -O--buildsystem=pybuild
68+
```
69+
70+
Now we are able to build a Debian package with the tool of our choice, e.g.:
71+
72+
```bash
73+
debuild -us -uc
74+
```
75+
76+
Checkout a working example here: [repo debian package](https://github.com/click-contrib/click-man/tree/master/examples/debian_pkg)
77+
78+
### Other distro packages
4979

50-
#### (1) Man pages are a UNIX thing
80+
To include man pages in packages for other package managers like `dnf`, `zypper`, or `pacman`, you will likely need to do one of the following:
81+
82+
* For upstream maintainers: generate man pages as part of a build release process and include them in version control or your generated sdists
83+
* For packagers: generate man pages as part of the package build process and include these in the RPMs or tarballs, along with the relevant stanzas in the package definition
84+
85+
If you are packaging utilities, we would welcome PRs documenting best practices for those using **click-man** to document their utilities.
86+
87+
## Issues with automatic man page installation
88+
89+
### Man pages are a UNIX thing
5190

5291
Python in general and with that pip and setuptools are aimed to be platform independent.
5392
Man pages are **not**: they are a UNIX thing which means setuptools does not provide a sane solution to generate and install man pages.
5493
We should consider using automatic man page installation only with vendor specific packaging, e.g. for `*.deb` or `*.rpm` packages.
5594

56-
#### (2) Man pages are not compatible with Python virtualenvs
95+
### Man pages are not compatible with Python virtualenvs
5796

5897
Even on systems that support man pages, Python packages can be installed in
5998
virtualenvs via pip and setuptools, which do not make commands available
@@ -66,7 +105,7 @@ versions of the same package into multiple different virtualenvs on the same
66105
system, there is no guarantee that a globally installed man page will document
67106
the version and behavior available in any given virtualenv.
68107

69-
#### (3) We want to generate man pages on the fly
108+
### We want to generate man pages on the fly
70109

71110
First, we do not want to commit man pages to our source control.
72111
We want to generate them on the fly, either during build or installation time.
@@ -75,26 +114,3 @@ With setuptools and pip we face two problems:
75114

76115
1. If we generate and install them during installation of the package pip does not know about the man pages and thus cannot uninstall it.
77116
2. If we generate them in our build process and add them to your distribution we do not have a way to prevent installation to */usr/share/man* for non-UNIX-like Operating Systems or from within virtualenvs.
78-
79-
### Debian packages
80-
81-
The `debhelper` packages provides a very convenient script called `dh_installman`.
82-
It checks for the `debian/(pkg_name.)manpages` file and it's content which is basically a line by line list of man pages or globs:
83-
84-
```
85-
debian/tmp/manpages/*
86-
```
87-
88-
We override the rule provided by `dh_installman` to generate our man pages in advance, like this:
89-
90-
```Makefile
91-
override_dh_installman:
92-
click-man <executable> --target debian/tmp/manpages
93-
dh_installman -O--buildsystem=pybuild
94-
```
95-
96-
Now we are able to build a debian package with the tool of our choice, e.g.:
97-
98-
```debuild -us -uc```
99-
100-
Checkout a working example here: [repo debian package](https://github.com/click-contrib/click-man/tree/master/examples/debian_pkg)

0 commit comments

Comments
 (0)