Package: click-man
click-manCreateman pagesforclickapplication as easy as this:python3setup.py--command-packages=click_man.commandsman_pages→ Checkout thedebian packaging exampleWhat it doesclick-manwill generate one man page per command of your click CLI application specified inconsole_scriptsin yoursetup.py.Installationpip3installclick-manclick-manis also available for Python 2:pipinstallclick-manUsage RecipesThe following sections describe different usage example forclick-man.Use with a previously installed packageclick-manprovides its own command line tool which can be passed the name of
an installed script:click-mancommandnamewherecommandnameis the name of an installedconsole_scriptentry point.To specify a target directory for the man pages, use the--targetoption:click-man--targetpath/to/man/pagescommandnameUse with setuptoolsclick-manprovides a sane setuptools command extension which can be used like the following:python3setup.py--command-packages=click_man.commandsman_pagesor specify the man pages target directory:python3setup.py--command-packages=click_man.commandsman_pages--targetpath/to/man/pagesAutomatic man page installation with setuptools and pipThis approach of installing man pages is problematic for various reasons:(1) Man pages are a UNIX thingPython in general and with that pip and setuptools are aimed to be platform independent.
Man pages arenot: 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*.debor*.rpmpackages.(2) Man pages are not compatable with Python virtualenvsEven 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 flyFirst, 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:If we generate and install them during installation of the package pip does not know about the man pages and thus cannot uninstall it.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/manfor non-UNIX-like Operating Systems or from within virtualenvs.Debian packagesThedebhelperpackages provides a very convenient script calleddh_installman.
It checks for thedebian/(pkg_name.)manpagesfile 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 bydh_installmanto generate our man pages in advance, like this:override_dh_installman:python3setup.py--command-packages=click_man.commandsman_pages--targetdebian/tmp/manpagesdh_installman-O--buildsystem=pybuildNow we are able to build are debian package with the tool of your choice, e.g.:debuild -us -ucCheckout a working example here:repo debian package