Saul Shanabrook

Flit & Read the Docs


This post is about the happy partnership between two wonderful technologies Flit, which gives you an alternative to writing a for your Python package, and Read the Docs which allows you to host your Sphinx documentation for free!

TLDR is put this in your readthedocs.yml:

version: 2

  version: 3.7
    - method: pip
      path: .
        - doc
        - test

And then your wonderful pyproject.toml you created with flit will be used to install your Python package and your dependencies before building the docs on RTD. It will install the doc and test requirements in your tool.flit.metadata.requires-extra as well as your default requires.

This is all set up and working on the metadsl project if you are looking for an example. The pyproject.toml looks like this, at the current moment:

requires = ["flit"]
build-backend = "flit.buildapi"

module = "metadsl"
author = "Saul Shanabrook"
author-email = ""
home-page = ""
requires = [
requires-python = ">=3.7"
classifiers = [
    "Intended Audience :: Developers",
    "License :: OSI Approved :: BSD License",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.7",
    "Topic :: Software Development :: Libraries :: Python Modules"

test = [
doc = [
dev = [

The slightly longer explanation is that, by default, RTD won't pick up on the pyproject.toml file like it would the But, luckily the version of pip does support these files now, so we just have to tell RTD to do a manual pip install.

It's also pretty slick how pip passes the extra requirements to the build system, which in this case is flit, and flit know how that maps to the requires-extra you provided.

If you have previously setup your project on RTD, you should wipe the environment so that it will know to rebuild properly.