Missing conf file for sphinx command

Kumari Sweta picture Kumari Sweta · Sep 28, 2015 · Viewed 9.3k times · Source

I am running into problem when I am running tox command to generate Sphinx documentation for my Python project. Here is the error:

docs runtests: PYTHONHASHSEED='1181019260'
docs runtests: commands[0] | sphinx-build -W -b html -c ./conf.py -d /Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/tmp/doctrees . /Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/tmp/html
Error: Config directory doesn't contain a conf.py file.
ERROR: InvocationError: '/Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/bin/sphinx-build -W -b html -c ./conf.py -d /Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/tmp/doctrees . /Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/tmp/html'
_________________________________________________ summary __________________________________________________
  py27: commands succeeded
  lint: commands succeeded
ERROR:   docs: commands failed

It is basically complaining about the conf.py, but this configuration file exists in the same directory where tox.ini exists. I am new to tox and sphinx and not sure why it is complaining about. Here is the content of the tox.ini.

[tox]
envlist = py27,lint,docs

[testenv]
commands =
    python setup.py nosetests --with-coverage --cover-package=limekiln --cover-erase --cover-html
    python setup.py sdist
deps =
    setuptools>=17.1

[testenv:docs]
basepython=python
changedir=docs
deps=sphinx
commands=
    sphinx-build -W -b html -c ./conf.py -d {envtmpdir}/doctrees .  {envtmpdir}/html

[testenv:lint]
commands=flake8 --max-line-length 99 limekiln
basepython=python2.7
deps=
    flake8
    flake8-print

Here is my conf.py file.

import sys, os

sys.path.insert(0, os.path.abspath('extensions'))

extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo',
                    'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig',
                                  'epub2', 'mobi', 'autoimage', 'code_example', 'sphinx.ext.autodoc']

todo_include_todos = True
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
exclude_patterns = []
add_function_parentheses = True
#add_module_names = True
#modindex_common_prefix = []

project = u'Limekiln'
copyright = u'2015'

version = '1.0'
release = '1.0'

And here is the directory structure of my project.

Project-root-directory
├── conf.py
├── module directory
│   ├── module sub-directory1
│   ├── module sub-directory2
├── requirements.txt
├── setup.py
└── tox.ini

Answer

freestyler picture freestyler · Sep 28, 2015

Change

commands=
sphinx-build -W -b html -c ./conf.py -d {envtmpdir}/doctrees .  {envtmpdir}/html

to

commands=
sphinx-build -W -b html -c ./ -d {envtmpdir}/doctrees .  {envtmpdir}/html

From sphinx-build help:

-c <path>           path where configuration file (conf.py) is located