@@ -45,17 +45,34 @@ def is_functional(self):
45
45
sage: latex().is_functional() # optional: latex
46
46
FeatureTestResult('latex', True)
47
47
"""
48
- from sage .misc .latex import _run_latex_ , _latex_file_
48
+ lines = []
49
+ lines .append (r"\documentclass{article}" )
50
+ lines .append (r"\begin{document}" )
51
+ lines .append (r"$\alpha+2$" )
52
+ lines .append (r"\end{document}" )
53
+ content = '\n ' .join (lines )
54
+
55
+ # create a simple tex file with the content
49
56
from sage .misc .temporary_file import tmp_filename
50
- try :
51
- f = tmp_filename (ext = '.tex' )
52
- O = open (f , 'w' )
53
- O .write (_latex_file_ ('2+3' ))
54
- O .close ()
55
- _run_latex_ (f )
57
+ base_filename_tex = tmp_filename (ext = '.tex' )
58
+ with open (base_filename_tex , 'w' ) as f :
59
+ f .write (content )
60
+ import os
61
+ base , filename_tex = os .path .split (base_filename_tex )
62
+
63
+ # running latex
64
+ from subprocess import run
65
+ cmd = ['latex' , '-interaction=nonstopmode' , filename_tex ]
66
+ cmd = ' ' .join (cmd )
67
+ result = run (cmd , shell = True , cwd = base , capture_output = True , text = True )
68
+
69
+ # return
70
+ if result .returncode == 0 :
56
71
return FeatureTestResult (self , True )
57
- except Exception :
58
- return FeatureTestResult (self , False , reason = "Running latex on a sample file raised an exception" )
72
+ else :
73
+ return FeatureTestResult (self , False , reason = "Running latex on "
74
+ "a sample file returned non-zero "
75
+ "exit status {}" .format (result .returncode ))
59
76
60
77
class pdflatex (Executable ):
61
78
r"""
0 commit comments