Skip to main content

click-man

Build Status PyPI Package version

Create man pages for click application as easy as this:

click-man foo

where foo is the name of your script, as defined in console_scripts.

→ Checkout the debian packaging example

What it does

click-man will generate one man page per command of your click CLI application specified in console_scripts in your setup.py / setup.cfg / pyproject.toml.

Installation

pip3 install click-man

click-man is also available for Python 2:

pip install click-man

Usage Recipes

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

Use with a previously installed package

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

click-man commandname

where commandname is the name of an installed console_script entry point.

To specify a target directory for the man pages, use the --target option:

click-man --target path/to/man/pages commandname

Automatic man page installation with setuptools and pip

This approach of installing man pages is problematic for various reasons:

(1) 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

Even on systems that support man pages, Python packages can be installed in virtualenvs via pip and setuptools, which do not make commands available globally. In fact, one of the "features" of a virtualenv is the ability to install a package without affecting the main system. As it is imposable to ensure a man page is only generated when not installing into a virtualenv, auto-generated man pages would pollute the main system and not stay contained in the virtualenv. Additionally, as a user could install multiple different 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

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.

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:

override_dh_installman:
	click-man <executable> --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

Metadata

Release files for click-man 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for click-man 0.5.0
File Size Uploaded
click_man-0.5.0.tar.gz 20.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for click-man 0.5.0
File Interpreter ABI Platform
click_man-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.3 kB

Release files / click_man-0.5.0.tar.gz

Download URL click_man-0.5.0.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2c2b3016c533dd315fa45ef9ab9bfa5bfd71017ea6d5bbcd454c179aee6b2343
BLAKE2b-256 checksum
How to use checksums
bc88bdbaf663876d0f095adb01542715cfc9b0d70c60e326816f48adcbe98978
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release files / click_man-0.5.0-py3-none-any.whl

Download URL click_man-0.5.0-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d13e4f62691bb2693afd58a9d29f4748ce01eb93220d3b376ef84011fd72504f
BLAKE2b-256 checksum
How to use checksums
4a5effe841db3188774d3edff1f7f208dc606fe56612bd2c452c27c30af8fde3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release history Release notifications | RSS feed

0.5.1

2 release files

This release

0.5.0 This release

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.1

1 release file

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page