Skip to content

Ensure invoked Sphinx matches importable one #6965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 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 @@ -1665,6 +1666,8 @@ def add_features(sender, **kwargs):
_('Limit the amount of concurrent builds'),
),
(
FORCE_SPHINX_FROM_VENV,
_('Force to use Sphinx from the current virtual environment'),
LIST_PACKAGES_INSTALLED_ENV,
_(
'List packages installed in the environment ("pip list" or "conda list") '
Expand Down