Skip to content

Commit c9ab81b

Browse files
committed
Fix sphinx detection
Readthedocs has changed how it invokes sphinx. See readthedocs/readthedocs.org#7846
1 parent 0ec2b1d commit c9ab81b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

doc/conf.py

+6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@
1717
# add these directories to sys.path here. If the directory is relative to the
1818
# documentation root, use os.path.abspath to make it absolute, like shown here.
1919
#
20+
import builtins
2021
import configparser
2122
import importlib
2223
from pathlib import Path
2324
import pkg_resources
2425
import sys
2526

27+
# Make it possible for our code to tell that it is running under Sphinx.
28+
# See https://stackoverflow.com/a/65147676/167694
29+
builtins.__sphinx_build__ = True
30+
31+
2632
sys.path.insert(0, str(Path(__file__).parents[1]))
2733

2834

gwcelery/util/sphinx.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
"""Detect if we are running under Sphinx."""
2-
import os
3-
import sys
4-
52
__all__ = ('SPHINX',)
63

7-
SPHINX = (os.path.basename(sys.argv[0]) == 'sphinx-build'
8-
or 'build_sphinx' in sys.argv)
4+
5+
try:
6+
# This global builtin variable is set in doc/conf.py.
7+
# See https://stackoverflow.com/a/65147676/167694
8+
SPHINX = __sphinx_build__
9+
except NameError:
10+
SPHINX = False

0 commit comments

Comments
 (0)