1
1
import sys
2
2
import subprocess
3
- import glob
4
3
import os
4
+ import platform
5
+ from pathlib import Path
5
6
6
- from .tinytex_download import download_tinytex
7
+ from .tinytex_download import download_tinytex # noqa
7
8
8
9
# Global cache
9
10
__tinytex_path = getattr (os .environ , "PYTINYTEX_TINYTEX" , None )
@@ -28,6 +29,13 @@ def get_tinytex_path(base="."):
28
29
raise RuntimeError ("TinyTeX doesn't seem to be installed. You can install TinyTeX with pytinytex.download_tinytex()." )
29
30
return __tinytex_path
30
31
32
+ def get_pdf_latex_engine ():
33
+ if platform .system () == "Windows" :
34
+ return os .path .join (get_tinytex_path (), "pdflatex.exe" )
35
+ else :
36
+ return os .path .join (get_tinytex_path (), "pdflatex" )
37
+
38
+
31
39
def ensure_tinytex_installed (path = "." ):
32
40
global __tinytex_path
33
41
error_path = None
@@ -39,15 +47,15 @@ def ensure_tinytex_installed(path="."):
39
47
error_path = path
40
48
__tinytex_path = _resolve_path (path )
41
49
return True
42
- except RuntimeError as e :
50
+ except RuntimeError :
43
51
__tinytex_path = None
44
52
raise RuntimeError ("Unable to resolve TinyTeX path. Got as far as {}" .format (error_path ))
45
53
return False
46
54
47
55
def _resolve_path (path = "." ):
48
56
while True :
49
57
if _check_file (path , "tlmgr" ):
50
- return path
58
+ return str ( Path ( path ). resolve ())
51
59
new_path = ""
52
60
list_dir = os .listdir (path )
53
61
if "bin" in list_dir :
@@ -107,7 +115,7 @@ def _run_tlmgr_command(args, path, machine_readable=True):
107
115
env = new_env ,
108
116
creationflags = creation_flag )
109
117
# something else than 'None' indicates that the process already terminated
110
- if not ( p .returncode is None ) :
118
+ if p .returncode is not None :
111
119
raise RuntimeError (
112
120
'TLMGR died with exitcode "%s" before receiving input: %s' % (p .returncode ,
113
121
p .stderr .read ())
0 commit comments