Search code examples
pythonpipread-the-docs

Readthedocs build: cmake/swig are not available


In order to build in readthedocs, I need to install some requirements. One of these pip requirements needs cmake and swig to build.

Is it still possible to use readthedocs in this scenario?


Solution

  • Seems there is a filed issue about this already: https://github.com/rtfd/readthedocs.org/issues/2094

    It contains a workaround:

    For anyone else running into this it seems you can also hack around it using the 'READTHEDOCS' env var to conditionally modify install_requires in your setup.py.

    This points to:

    When RTD builds your project, it sets the READTHEDOCS environment variable to the string True. So within your Sphinx conf.py file, you can vary the behavior based on this. For example:

    import os
    on_rtd = os.environ.get('READTHEDOCS') == 'True'
    if on_rtd:
        html_theme = 'default'
    else:
        html_theme = 'nature'
    

    OTOH, the last comment claims it should work fine with the current RTD version.