Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3bfdb27

Browse files
committed
Also check luatex version using the general executable checker.
1 parent 41eac98 commit 3bfdb27

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

lib/matplotlib/__init__.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ def wrapper(*args, **kwargs):
427427

428428
@functools.lru_cache()
429429
def get_executable_info(name):
430-
"""Get the version of some executables that Matplotlib depends on.
430+
"""
431+
Get the version of some executables that Matplotlib depends on.
431432
432433
.. warning:
433434
The list of executables that this function supports is set according to
@@ -437,8 +438,8 @@ def get_executable_info(name):
437438
----------
438439
name : str
439440
The executable to query. The following values are currently supported:
440-
"dvipng", "gs", "inkscape", "pdftops", "tex". This list is subject to
441-
change without notice.
441+
"dvipng", "gs", "inkscape", "luatex", "pdftops", "tex". This list is
442+
subject to change without notice.
442443
443444
Returns
444445
-------
@@ -484,6 +485,9 @@ def impl(args, regex, min_ver=None):
484485
None)
485486
elif name == "inkscape":
486487
info = impl(["inkscape", "-V"], "^Inkscape ([^ ]*)")
488+
elif name == "luatex":
489+
info = impl(["luatex", "--version"],
490+
r"^This is LuaTeX, Version (?:beta-)?(\d+\.\d+\.\d+)")
487491
elif name == "pdftops":
488492
info = impl(["pdftops", "-v"], "^pdftops version (.*)")
489493
if info and not ("3.0" <= info.version
@@ -502,7 +506,8 @@ def impl(args, regex, min_ver=None):
502506

503507

504508
def get_all_executable_infos():
505-
"""Query all executables that Matplotlib may need.
509+
"""
510+
Query all executables that Matplotlib may need.
506511
507512
.. warning:
508513
The list of executables that this function queries is set according to
@@ -515,7 +520,8 @@ def get_all_executable_infos():
515520
to change without notice.
516521
"""
517522
return {name: get_executable_info(name)
518-
for name in ["dvipng", "gs", "inkscape", "pdftops", "tex"]}
523+
for name in ["dvipng", "gs", "inkscape", "luatex", "pdftops",
524+
"tex"]}
519525

520526

521527
@cbook.deprecated("3.0")

lib/matplotlib/backends/backend_pgf.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@
3030
###############################################################################
3131

3232

33-
_luatex_version_re = re.compile(
34-
r'This is LuaTeX, Version (?:beta-)?([0-9]+)\.([0-9]+)\.([0-9]+)'
35-
)
36-
37-
3833
@cbook.deprecated("3.0")
3934
def get_texcommand():
4035
"""Get chosen TeX system from rc."""
@@ -43,18 +38,6 @@ def get_texcommand():
4338
return texsystem if texsystem in texsystem_options else "xelatex"
4439

4540

46-
def _get_lualatex_version():
47-
"""Get version of luatex"""
48-
output = subprocess.check_output(['lualatex', '--version'])
49-
return _parse_lualatex_version(output.decode())
50-
51-
52-
def _parse_lualatex_version(output):
53-
'''parse the lualatex version from the output of `lualatex --version`'''
54-
match = _luatex_version_re.match(output)
55-
return tuple(map(int, match.groups()))
56-
57-
5841
def get_fontspec():
5942
"""Build fontspec preamble from rc."""
6043
latex_fontspec = []
@@ -1166,8 +1149,8 @@ def _build_newpage_command(self, width, height):
11661149
so we need to check the lualatex version and use `\pagewidth` if
11671150
the version is 0.85 or newer
11681151
'''
1169-
texcommand = get_texcommand()
1170-
if texcommand == 'lualatex' and _get_lualatex_version() >= (0, 85, 0):
1152+
if (get_texcommand() == 'lualatex'
1153+
and get_executable_info('luatex') >= '0.85'):
11711154
cmd = r'\page'
11721155
else:
11731156
cmd = r'\pdfpage'

0 commit comments

Comments
 (0)