diff --git a/astropy/setup_helpers.py b/astropy/setup_helpers.py index 55676896be4..c12acf31869 100644 --- a/astropy/setup_helpers.py +++ b/astropy/setup_helpers.py @@ -35,6 +35,13 @@ HAVE_CYTHON = False +try: + import sphinx + HAVE_SPHINX = True +except ImportError: + HAVE_SPHINX = False + + class AstropyBuild(DistutilsBuild): """ A custom 'build' command that allows for adding extra build @@ -192,7 +199,7 @@ def run(self): AstropyInstall.add_install_option(*option) -try: +if HAVE_SPHINX: from sphinx.setup_command import BuildDoc class AstropyBuildSphinx(BuildDoc): @@ -325,9 +332,6 @@ def run(self): AstropyBuildSphinx.__name__ = 'build_sphinx' -except ImportError: - AstropyBuildSphinx = None - def get_distutils_display_options(): """ Returns a set of all the distutils display options in their long and