Skip to content

Commit f4215c5

Browse files
authored
Build: remove pdflatex support (#9967)
* Build: remove `pdflatex` support `pdflatex` is only called for project using `Sphinx<=1.6.1` --which we haven't had anyone in the last 6 months. Closes #9886 * Docs: remove mentions to `pdflatex` * Test: remove `import sys` command from build commands * Test: match `cat` on mocks
1 parent 21a4033 commit f4215c5

File tree

3 files changed

+3
-104
lines changed

3 files changed

+3
-104
lines changed

docs/user/guides/pdf-non-ascii-languages.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ Sphinx PDFs with Unicode
33

44
Sphinx offers different `LaTeX engines`_ that have better support for Unicode characters
55
and non-European languages like Japanese or Chinese.
6-
By default Sphinx uses ``pdflatex``,
7-
which does not have good support for Unicode characters and may make the PDF builder fail.
86

97
.. _LaTeX engines: http://www.sphinx-doc.org/en/master/usage/configuration.html#confval-latex_engine
108

@@ -17,7 +15,7 @@ to modify Sphinx and Read the Docs behavior to make your documentation to build
1715

1816
For docs that are not written in Chinese or Japanese,
1917
and if your build fails from a Unicode error,
20-
then try ``xelatex`` as the ``latex_engine`` instead of the default ``pdflatex`` in your ``conf.py``:
18+
then try ``xelatex`` as the ``latex_engine`` in your ``conf.py``:
2119

2220
.. code-block:: python
2321

readthedocs/doc_builder/backends/sphinx.py

+1-91
Original file line numberDiff line numberDiff line change
@@ -336,38 +336,6 @@ def sphinx_parallel_arg(self):
336336
return ['-j', 'auto']
337337
return []
338338

339-
def venv_sphinx_supports_latexmk(self):
340-
"""
341-
Check if ``sphinx`` from the user's venv supports ``latexmk``.
342-
343-
If the version of ``sphinx`` is greater or equal to 1.6.1 it returns
344-
``True`` and ``False`` otherwise.
345-
346-
See: https://www.sphinx-doc.org/en/master/changes.html#release-1-6-1-released-may-16-2017
347-
"""
348-
349-
command = [
350-
self.python_env.venv_bin(filename='python'),
351-
'-c',
352-
(
353-
'"'
354-
'import sys; '
355-
'import sphinx; '
356-
'sys.exit(0 if sphinx.version_info >= (1, 6, 1) else 1)'
357-
'"'
358-
),
359-
]
360-
361-
cmd_ret = self.run(
362-
*command,
363-
bin_path=self.python_env.venv_bin(),
364-
cwd=self.project_path,
365-
escape_command=False, # used on DockerBuildCommand
366-
shell=True, # used on BuildCommand
367-
record=False,
368-
)
369-
return cmd_ret.exit_code == 0
370-
371339

372340
class HtmlBuilder(BaseSphinx):
373341
relative_output_dir = "_readthedocs/html"
@@ -548,12 +516,7 @@ def build(self):
548516
raise BuildUserError("No TeX files were found.")
549517

550518
# Run LaTeX -> PDF conversions
551-
# Build PDF with ``latexmk`` if Sphinx supports it, otherwise fallback
552-
# to ``pdflatex`` to support old versions
553-
if self.venv_sphinx_supports_latexmk():
554-
success = self._build_latexmk(self.project_path)
555-
else:
556-
success = self._build_pdflatex(tex_files)
519+
success = self._build_latexmk(self.project_path)
557520

558521
self._post_build()
559522
return success
@@ -625,59 +588,6 @@ def _build_latexmk(self, cwd):
625588

626589
return cmd_ret.successful
627590

628-
def _build_pdflatex(self, tex_files):
629-
pdflatex_cmds = [
630-
['pdflatex', '-interaction=nonstopmode', tex_file]
631-
for tex_file in tex_files
632-
] # yapf: disable
633-
makeindex_cmds = [
634-
[
635-
"makeindex",
636-
"-s",
637-
"python.ist",
638-
"{}.idx".format(
639-
os.path.splitext(
640-
os.path.relpath(tex_file, self.absolute_output_dir)
641-
)[0],
642-
),
643-
]
644-
for tex_file in tex_files
645-
] # yapf: disable
646-
647-
if self.build_env.command_class == DockerBuildCommand:
648-
latex_class = DockerLatexBuildCommand
649-
else:
650-
latex_class = LatexBuildCommand
651-
pdf_commands = []
652-
for cmd in pdflatex_cmds:
653-
cmd_ret = self.build_env.run_command_class(
654-
cls=latex_class,
655-
cmd=cmd,
656-
cwd=self.absolute_output_dir,
657-
warn_only=True,
658-
)
659-
pdf_commands.append(cmd_ret)
660-
for cmd in makeindex_cmds:
661-
cmd_ret = self.build_env.run_command_class(
662-
cls=latex_class,
663-
cmd=cmd,
664-
cwd=self.absolute_output_dir,
665-
warn_only=True,
666-
)
667-
pdf_commands.append(cmd_ret)
668-
for cmd in pdflatex_cmds:
669-
cmd_ret = self.build_env.run_command_class(
670-
cls=latex_class,
671-
cmd=cmd,
672-
cwd=self.absolute_output_dir,
673-
warn_only=True,
674-
)
675-
pdf_match = PDF_RE.search(cmd_ret.output)
676-
if pdf_match:
677-
self.pdf_file_name = pdf_match.group(1).strip()
678-
pdf_commands.append(cmd_ret)
679-
return all(cmd.successful for cmd in pdf_commands)
680-
681591
def _post_build(self):
682592
"""Internal post build to cleanup PDF output directory and leave only one .pdf file."""
683593

readthedocs/projects/tests/test_build_tasks.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -719,18 +719,9 @@ def test_build_commands_executed(
719719
cwd=mock.ANY,
720720
bin_path=mock.ANY,
721721
),
722+
mock.call("cat", "latexmkrc", cwd=mock.ANY),
722723
# NOTE: pdf `mv` commands and others are not here because the
723724
# PDF resulting file is not found in the process (`_post_build`)
724-
mock.call(
725-
mock.ANY,
726-
"-c",
727-
'"import sys; import sphinx; sys.exit(0 if sphinx.version_info >= (1, 6, 1) else 1)"',
728-
bin_path=mock.ANY,
729-
cwd=mock.ANY,
730-
escape_command=False,
731-
shell=True,
732-
record=False,
733-
),
734725
mock.call(
735726
mock.ANY,
736727
"-m",

0 commit comments

Comments
 (0)