Skip to main content

Hatch Argparse Manpage

Package PyPI - Python Version PyPI - Version
Meta Hatch project Ruff GitButler Checked with mypy License: GPL v3 GitHub Sponsors

This provides a build hook plugin for Hatch to automatically generate a manual page from an ArgumentParser object, using argparse-manpage by Pavel Raiskup.

Important: an unavoidable aspect of argparse-manpage is that module imports are unavailable at build time in your argparse script.

Table of Contents

Explanation

This plugin is not an official project of argparse-manpage. Instead, it acts as a wrapper around it, making it available to Hatch users. As such, if argparse-manpage changes in ways incompatible with this plugin, this plugin may not function as expected.

This plugin is tested against argparse-manpage versions 4.5–4.8. Python 3.15 requires argparse-manpage 4.8 or newer.

Configuration

The build hook plugin name is argparse-manpage.

Calling the plugin

Modify pyproject.toml to include the plugin as a build dependency:

[build-system]
requires = ["hatchling", "hatch-argparse-manpage"]
build-backend = "hatchling.build"

Generating the manual page

This plugin will do nothing unless the build target is sdist or wheel.

This plugin requires the directories storing the generated man pages are within the project's base directory, and are not equal to the project's base directory.

For example, for a project named myproject, and a src layout src/myproject, an acceptable directory in which to store a man page would be man.

Using the configuration option [tool.hatch.build.hooks.argparse-manpage], specify the man pages using the format defined by argparse-manpage.

For example:

[tool.hatch.build.hooks.argparse-manpage]
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",
]

Extra options

Skip Platforms

This plugin makes little sense on some platforms, e.g. Windows. To skip running this plugin on specific platforms use values from sys.platform in the configuration option skip-platforms, e.g.:

[tool.hatch.build.hooks.argparse-manpage]
skip-platforms = ["win32", "cygwin"]

Project URLs

If a URL is not specified in the man page's build configuration, this plugin extracts it from the [project.urls] section of the project's pyproject.toml:

  1. If a homepage URL is specified, then it is used.
  2. If not, if only one URL is specified, it is used.

Argparse-manpage uses a project URL to generate a man section that explains where to download the program the page is being built for.

To suppress this behavior, set include-url to false (the default value is true):

[tool.hatch.build.hooks.argparse-manpage]
include-url = false
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",
]

Argparse-manpage invocation

This plugin defaults to calling argparse-manpage's Python code directly. If this generates an exception, this plugin will attempt to call argparse-manpage as a command line program. To force the use of argparse-manpage as a command line program, set force-command-line to true (the default value is false):

[tool.hatch.build.hooks.argparse-manpage]
force-command-line = true
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",
]

Cleaning output files

The plugin includes logic to remove the files it outputs using hatch's clean hook. As well as individual files, any output directories created will also be removed, as long as these directories do not contain files created by something other than this plugin.

Running tests

To run the full test suite, i.e. all supported Python and argparse-manpage versions, run:

hatch test -a

History

The code to parse the pyproject.toml config in this plugin overlaps with the code in argparse-manpage, but differs in that it is rewritten to conform to contemporary Python stylistic conventions, as well as the specific needs of this plugin.

GNU gettext users may be interested in hatch-gettext.

License

hatch-argparse-manpage is distributed under the terms of the GPL-3.0-or-later license.

Metadata

Release files for hatch-argparse-manpage 1.0.3

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

Source distribution (sdist)

Source distribution for hatch-argparse-manpage 1.0.3
File Size Uploaded Provenance Actions
hatch_argparse_manpage-1.0.3.tar.gz 31.3 kB Without provenance Details for hatch_argparse_manpage-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hatch-argparse-manpage 1.0.3
File Interpreter ABI Platform Actions
hatch_argparse_manpage-1.0.3-py3-none-any.whl Python 3 none any Details for hatch_argparse_manpage-1.0.3-py3-none-any.whl

Total release size: 54.2 kB

Release files / hatch_argparse_manpage-1.0.3.tar.gz

Download URL hatch_argparse_manpage-1.0.3.tar.gz
Size 31.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8d77ff8991e80195858561e885a2f5783c884542930986f10829dd23bd342a80
BLAKE2b-256 checksum
How to use checksums
9419ae4fd17c1106ea03e02fd54c4e8cb81535a49c6425b206aee1130804b3ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.2 {"ci":null,"cpu":"x86_64","distro":{"id":"resolute","libc":{"lib":"glibc","version":"2.43"},"name":"Ubuntu","version":"26.04"},"implementation":{"name":"CPython","version":"3.14.4"},"installer":{"name":"hatch","version":"1.18.2"},"openssl_version":"OpenSSL 3.5.5 27 Jan 2026","python":"3.14.4","system":{"name":"Linux","release":"6.6.114.1-microsoft-standard-WSL2"}} HTTPX2/2.16.2

Release files / hatch_argparse_manpage-1.0.3-py3-none-any.whl

Download URL hatch_argparse_manpage-1.0.3-py3-none-any.whl
Size 23.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8414b46eaa98255ace578f0b08bf24cdfd3ffef76633804c25af8bcef18eca83
BLAKE2b-256 checksum
How to use checksums
7e81a332f0f8405535ad346fd179a87f5857b3450695d546655b099b3530d228
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.2 {"ci":null,"cpu":"x86_64","distro":{"id":"resolute","libc":{"lib":"glibc","version":"2.43"},"name":"Ubuntu","version":"26.04"},"implementation":{"name":"CPython","version":"3.14.4"},"installer":{"name":"hatch","version":"1.18.2"},"openssl_version":"OpenSSL 3.5.5 27 Jan 2026","python":"3.14.4","system":{"name":"Linux","release":"6.6.114.1-microsoft-standard-WSL2"}} HTTPX2/2.16.2

Security for hatch-argparse-manpage 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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