Skip to content

Commit

Permalink
Merge pull request #6965 from eric-wieser/patch-1
Browse files Browse the repository at this point in the history
Ensure invoked Sphinx matches importable one
  • Loading branch information
stsewd committed May 4, 2020
2 parents ecab363 + c25a21b commit d7e86b3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
18 changes: 14 additions & 4 deletions readthedocs/doc_builder/backends/sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ def build(self):
self.clean()
project = self.project
build_command = [
'python',
self.python_env.venv_bin(filename='sphinx-build'),
*self.get_sphinx_cmd(),
'-T',
]
if self._force:
Expand All @@ -259,6 +258,18 @@ def build(self):
)
return cmd_ret.successful

def get_sphinx_cmd(self):
if self.project.has_feature(Feature.FORCE_SPHINX_FROM_VENV):
return (
self.python_env.venv_bin(filename='python'),
'-m',
'sphinx',
)
return (
'python',
self.python_env.venv_bin(filename='sphinx-build'),
)

def venv_sphinx_supports_latexmk(self):
"""
Check if ``sphinx`` from the user's venv supports ``latexmk``.
Expand Down Expand Up @@ -434,8 +445,7 @@ def build(self):

# Default to this so we can return it always.
self.run(
'python',
self.python_env.venv_bin(filename='sphinx-build'),
*self.get_sphinx_cmd(),
'-b',
'latex',
'-D',
Expand Down
5 changes: 5 additions & 0 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,7 @@ def add_features(sender, **kwargs):
CACHED_ENVIRONMENT = 'cached_environment'
CELERY_ROUTER = 'celery_router'
LIMIT_CONCURRENT_BUILDS = 'limit_concurrent_builds'
FORCE_SPHINX_FROM_VENV = 'force_sphinx_from_venv'
LIST_PACKAGES_INSTALLED_ENV = 'list_packages_installed_env'
VCS_REMOTE_LISTING = 'vcs_remote_listing'

Expand Down Expand Up @@ -1664,6 +1665,10 @@ def add_features(sender, **kwargs):
LIMIT_CONCURRENT_BUILDS,
_('Limit the amount of concurrent builds'),
),
(
FORCE_SPHINX_FROM_VENV,
_('Force to use Sphinx from the current virtual environment'),
),
(
LIST_PACKAGES_INSTALLED_ENV,
_(
Expand Down

0 comments on commit d7e86b3

Please sign in to comment.