Following system colour scheme Selected dark colour scheme Selected light colour scheme

Python Enhancement Proposals

PEP 676 – PEP Infrastructure Process

Adam Turner <python at>
Mariatta <mariatta at>
Barry Warsaw <barry at>
Discourse thread
23-Sep-2021, 30-Nov-2021
Discourse message

Table of Contents


This PEP addresses the infrastructure around rendering PEP files from reStructuredText files to HTML webpages. We aim to specify a self-contained and maintainable solution for PEP readers, authors, and editors.


As of November 2021, Python Enhancement Proposals (PEPs) are rendered in a multi-system, multi-stage process. A continuous integration (CI) task runs a docutils script to render all PEP files individually. The CI task then uploads a tar archive to a server, where it is retrieved and rendered into the website periodically.

This places a constraint on the website to handle raw HTML uploads and handle PEP rendering, and makes the appropriate place to raise issues unclear in some cases [1].

This PEP provides a specification for self-contained rendering of PEPs. This would:

  • reduce the amount of distributed configuration for supporting PEPs
  • enable quality-of-life improvements for those who read, write, and review PEPs
  • solve a number of outstanding issues, and lay the path for improvements
  • save volunteer maintainers’ time

We propose that PEPs are accessed through at the top-level (for example, and that all custom tooling to support rendering PEPs is hosted in the python/peps repository.


Simplifying and Centralising Infrastructure

As of November 2021, to locally render a PEP file, a PEP author or editor needs to create a full local instance of the website and run a number of disparate scripts, following documentation that lives outside of the python/peps repository.

By contrast, the proposed implementation provides a single Makefile and a Python script to render all PEP files, with options to target a web-server or the local filesystem.

Using a single repository to host all tooling will clarify where to raise issues, reducing volunteer time spent in triage.

Simplified and centralised tooling may also reduce the barrier to entry to further improvements, as the scope of the PEP rendering infrastructure is well defined.

Quality-of-Life Improvements and Resolving Issues

There are several requests for additional features in reading PEPs, such as:

  • syntax highlighting [2]
  • use of .. code-block:: directives [2]
  • support for SVG images [3]
  • typographic quotation marks [4]
  • additional footer information [5]
  • intersphinx functionality [6]
  • dark mode theme [7]

These are “easy wins” from this proposal, and would serve to improve the quality-of-life for consumers of PEPs (including reviewers and writers).

For example, the current (as of November 2021) system runs periodically on a schedule. This means that updates to PEPs cannot be circulated immediately, reducing productivity. The reference implementation renders and publishes all PEPs on every commit to the repository, solving the issue by design.

The reference implementation fixes several issues [8]. For example:

  • list styles are currently not respected by’s stylesheets
  • support for updating images in PEPs is challenging in

Third-party providers such as Read the Docs or Netlify can enhance this experience with features such as automatic rendering of pull requests.


The proposed specification for rendering the PEP files to HTML is as per the reference implementation.

The rendered PEPs MUST be available at These SHOULD be hosted as static files, and MAY be behind a content delivery network (CDN).

A service to render previews of pull requests SHOULD be provided. This service MAY be integrated with the hosting and deployment solution.

The following redirect rules MUST be created for the domain:

The following nginx configuration would achieve this:

location ~ ^/dev/peps/?(.*)$ {
    return 308$1/;

location ~ ^/peps/(.*)\.html$ {
    return 308$1/;

location ^/(dev/)?peps(/.*)?$ {
    return 308;

Redirects MUST be implemented to preserve URL fragments for backward compatibility purposes.

Backwards Compatibility

Due to server-side redirects to the new canonical URLs, links in previously published materials referring to the old URL schemes will be guaranteed to work. All PEPs will continue to render correctly, and a custom stylesheet in the reference implementation improves presentation for some elements (most notably code blocks and block quotes). Therefore, this PEP presents no backwards compatibility issues.

Security Implications

The main website will no longer process raw HTML uploads, closing a potential threat vector. PEP rendering and deployment processes will use modern, well-maintained code and secure automated platforms, further reducing the potential attack surface. Therefore, we see no negative security impact.

How to Teach This

The new canonical URLs will be publicised in the documentation. However, this is mainly a backend infrastructure change, and there should be minimal end-user impact. PEP 1 and PEP 12 will be updated as needed.

Reference Implementation

The proposed implementation has been merged into the python/peps repository in a series of pull requests [9]. It uses the Sphinx documentation system with a custom theme (supporting light and dark colour schemes) and extensions.

This already automatically renders all PEPs on every commit, and publishes them to The high level documentation for the system covers how to render PEPs locally and the implementation of the system.

Rejected Ideas

It would likely be possible to amend the current (as of November 2021) rendering process to include a subset of the quality-of-life improvements and issue mitigations mentioned above. However, we do not believe that this would solve the distributed tooling issue.

It would be possible to use the output from the proposed rendering system and import it into We would argue that this would be the worst of both worlds, as a great deal of complexity is added whilst none is removed.


  • Hugo van Kemenade
  • Pablo Galindo Salgado
  • Éric Araujo
  • Mariatta
  • C.A.M. Gerlach



Last modified: 2023-09-09 17:39:29 GMT