Registry / devops / hatch-fancy-pypi-readme

hatch-fancy-pypi-readme

JSON →
library25.1.0pypypiunverified

Hatch Fancy PyPI README is a Hatch plugin that enables dynamic and enhanced README generation for your Python packages. It allows you to combine multiple files, use Jinja templating, and perform other transformations to create a rich PyPI README. The current version is 25.1.0, and it is actively maintained as part of the Hatch project, with frequent updates.

pip install hatch-fancy-pypi-readme hatch
INSTALL
IMPORT
SIG · HATCH-FANCY-PYPI-R
H
hatch-fancy-pypi-readme
devopspythonv25.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

This quickstart demonstrates how to use `hatch-fancy-pypi-readme` to combine `README.md` and `CHANGELOG.md` into a single, templated PyPI README. First, ensure `hatch` is installed. Then, create the specified `pyproject.toml`, `README.md`, and `CHANGELOG.md` files within your project directory. Finally, run `hatch build` to generate your package distributions with the fancy README.

# 1. Create a project directory, e.g., 'my_fancy_package' # 2. Inside 'my_fancy_package', create these files: # pyproject.toml # -------------------------------------------------- # [build-system] # requires = ["hatchling>=1.18.0", "hatch-fancy-pypi-readme==25.1.0"] # build-backend = "hatchling.build" # # [project] # name = "my-fancy-package" # version = "0.1.0" # description = "A package with a fancy README" # authors = [{ name = "Agent", email = "agent@example.com" }] # readme = { file = "README.md", content-type = "text/markdown", checker = "fancy" } # # [tool.hatch.build.targets.sdist.hooks.fancy-pypi-readme] # files = ["README.md", "CHANGELOG.md"] # template = "# {{ project.name }} - v{{ project.version }}\n\n" \ # "## Main README\n{{ files['README.md'] }}\n\n" \ # "## Changelog\n{{ files['CHANGELOG.md'] }}" # -------------------------------------------------- # README.md # -------------------------------------------------- # This is the primary README content for my package. # It will be combined with other files by hatch-fancy-pypi-readme. # -------------------------------------------------- # CHANGELOG.md # -------------------------------------------------- # ### 0.1.0 # - Initial release with fancy README generation. # - Added support for combining README and CHANGELOG. # -------------------------------------------------- # 3. Navigate to the 'my_fancy_package' directory in your terminal. # 4. Run the build command: # hatch build # After building, you will find the generated sdist and wheel files # in the 'dist/' directory, with the README correctly templated.
hatch --version
Debug
Known issues
breakingThe configuration for `hatch-fancy-pypi-readme` underwent a breaking change in version `21.0.0`. Older configurations using `[tool.hatch.build.hooks.fancy-readme]` are no longer supported.
fix
Migrate your `pyproject.toml` to use the `project.readme` table with `checker = "fancy"` and subsequent configuration under `[tool.hatch.build.targets.sdist.hooks.fancy-pypi-readme]`, as shown in the quickstart example.
affects: <21.0.0
gotchaImproper `pyproject.toml` configuration, especially around the `project.readme` table and the `[tool.hatch.build.targets.sdist.hooks.fancy-pypi-readme]` section, is a common source of errors. Ensure syntax is correct and all required fields are present.
fix
Carefully review the official documentation and examples for correct `pyproject.toml` structure. Pay close attention to the `checker = "fancy"` setting and the nested `tool.hatch` sections.
affects: All
gotchaErrors in Jinja templates (e.g., syntax errors, referencing non-existent variables) or listing non-existent files in the `files` configuration will cause the build process to fail. Debugging templating issues can sometimes be challenging.
fix
Thoroughly test your Jinja templates with sample data. Ensure all files referenced in `files` or within the template actually exist at build time. Use simpler templates initially and progressively add complexity.
affects: All
Errors
Common errors & fixes
unknown metadata hook
This error occurs when Hatch cannot find or load the 'fancy-pypi-readme' plugin, often due to it not being installed in the Hatch environment or a misconfiguration in `pyproject.toml`.
fix
Ensure `hatch-fancy-pypi-readme` is installed in the same environment where the `hatch` CLI command resides. Verify your `pyproject.toml` has a `[tool.hatch.metadata.hooks.fancy-pypi-readme]` section and that the main `[project]` table does *not* contain a `readme` key that conflicts with the plugin's configuration.
hatch-fancy-pypi-readme cannot find fragment files
This error indicates that the plugin, during the README generation process, is unable to locate the files specified in the `fragments` section of your `pyproject.toml` configuration, often due to incorrect relative paths or issues with the working directory, especially in CI/CD environments like GitHub Actions.
fix
Review the paths specified for your fragments in `pyproject.toml`. Ensure they are correct relative to your project root. In CI/CD, confirm that the action or workflow is running from the expected working directory, or adjust paths to be absolute if necessary.
ModuleNotFoundError: No module named 'hatch_fancy_pypi_readme'
This error means the Python interpreter cannot find the `hatch_fancy_pypi_readme` package when Hatch attempts to load it, most commonly because the plugin has not been installed, or it's installed in a different Python environment than Hatch.
fix
Install `hatch-fancy-pypi-readme` using pip in the same virtual environment where Hatch is installed: `pip install hatch-fancy-pypi-readme`.
Error: `content-type` must be either 'text/markdown' or 'text/x-rst'
This validation error occurs when the `content-type` specified in the `[tool.hatch.metadata.hooks.fancy-pypi-readme]` section of `pyproject.toml` is not one of the allowed values.
fix
Set the `content-type` in your `pyproject.toml` to either `'text/markdown'` or `'text/x-rst'`, as these are the only formats currently supported by PyPI. For example: `content-type = "text/markdown"`.
Upgrade
Version history
25.1.0latest on PyPI · released May 1, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
18
Resources
hatch-fancy-pypi-readme — pip install hatch-fancy-pypi-readme · libregistry