From 12befcedbd0f2146b2e7cc74ddff140a7ceabce8 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 11 Dec 2024 14:43:53 +0000 Subject: [PATCH] README: Update packaging overview Signed-off-by: Stephen Finucane --- README.md | 78 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 2f4bda8..cffb2d6 100644 --- a/README.md +++ b/README.md @@ -22,14 +22,13 @@ where `foo` is the name of your script, as defined in [`console_scripts`](https: pip install click-man ``` -## Usage Recipes +## Usage The following sections describe different usage example for *click-man*. -### Use with a previously installed package +### CLI -**click-man** provides its own command line tool which can be passed the name of -an installed script: +**click-man** provides its own command line tool which can be passed the name of an installed script: ```bash click-man commandname @@ -43,17 +42,57 @@ To specify a target directory for the man pages, use the `--target` option: click-man --target path/to/man/pages commandname ``` +You can use the `manpath` command or `MANPATH` environment variable to identify where man pages can be placed. + ### Automatic man page installation with setuptools and pip -This approach of installing man pages is problematic for various reasons: +While earlier version of click-man provided a distutils hook that could be used to automatically install man pages, +this approach had a number of caveats as outlined [below][issues-with-automatic-man-page-installation]. +distutils was removed from Python stdlib in Python 3.12 and the distutils hook was removed from **click-man** in v0.5.0. + +### Debian packages + +The `debhelper` packages provides a very convenient script called `dh_installman`. +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: + +``` +debian/tmp/manpages/* +``` + +We override the rule provided by `dh_installman` to generate our man pages in advance, like this: + +```Makefile +override_dh_installman: + click-man --target debian/tmp/manpages + dh_installman -O--buildsystem=pybuild +``` + +Now we are able to build a Debian package with the tool of our choice, e.g.: + +```bash +debuild -us -uc +``` + +Checkout a working example here: [repo debian package](https://github.com/click-contrib/click-man/tree/master/examples/debian_pkg) + +### Other distro packages -#### (1) Man pages are a UNIX thing +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: + +* For upstream maintainers: generate man pages as part of a build release process and include them in version control or your generated sdists +* 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 + +If you are packaging utilities, we would welcome PRs documenting best practices for those using **click-man** to document their utilities. + +## Issues with automatic man page installation + +### Man pages are a UNIX thing Python in general and with that pip and setuptools are aimed to be platform independent. Man pages are **not**: they are a UNIX thing which means setuptools does not provide a sane solution to generate and install man pages. We should consider using automatic man page installation only with vendor specific packaging, e.g. for `*.deb` or `*.rpm` packages. -#### (2) Man pages are not compatible with Python virtualenvs +### Man pages are not compatible with Python virtualenvs Even on systems that support man pages, Python packages can be installed in 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 system, there is no guarantee that a globally installed man page will document the version and behavior available in any given virtualenv. -#### (3) We want to generate man pages on the fly +### We want to generate man pages on the fly First, we do not want to commit man pages to our source control. 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: 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. 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. - -### Debian packages - -The `debhelper` packages provides a very convenient script called `dh_installman`. -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: - -``` -debian/tmp/manpages/* -``` - -We override the rule provided by `dh_installman` to generate our man pages in advance, like this: - -```Makefile -override_dh_installman: - click-man --target debian/tmp/manpages - dh_installman -O--buildsystem=pybuild -``` - -Now we are able to build a debian package with the tool of our choice, e.g.: - -```debuild -us -uc``` - -Checkout a working example here: [repo debian package](https://github.com/click-contrib/click-man/tree/master/examples/debian_pkg)