updated the test script for kpsewhich functionality
[PyX/mjg.git] / contrib / callingtex.py
blob5bf12ba21124e958f17a9da19fbf417ebce2de0f
1 #!/usr/bin/env python
2 # This file should help users tracking problems with their TeX installation
3 # It spits out a lot of information about the Python installation, the PyX
4 # installation and the environment in which PyX will try to use TeX/LaTeX.
6 import sys, os, subprocess
7 #sys.path.insert(0, "..")
8 #sys.path.insert(0, "../build/lib.linux-x86_64-2.5")
9 import pyx
11 #pyx.text.set(fontmaps="psfonts.map psfonts.cmz")
13 def test_installation():
14 try:
15 from pyx.pykpathsea import _pykpathsea
16 compiled_pykpathsea = True
17 except ImportError:
18 compiled_pykpathsea = False
20 print "Platform is %s" % sys.platform
21 print "Python installation prefix is %s" % sys.prefix
22 print "Python executable is %s" % sys.executable
23 print "PyX comes from %s" % pyx.__file__
24 print "PyX version %s" % pyx.__version__
25 if compiled_pykpathsea:
26 print "PyX pykpathsea compiled from C module"
27 else:
28 print "PyX pykpathsea python module used"
29 print
31 def test_commands():
32 for command in [r"echo $0 \"$*\"",
33 r"echo $SHELL",
34 r"echo $BASH_SUBSHELL",
35 r"echo $-",
36 r"echo $ENV",
37 r"echo $BASH_ENV",
38 r"echo $TEXMFCNF",
39 r"echo $_",
40 r"echo $PATH",
41 r"which kpsewhich",
42 r"which tex",
43 r"which latex",
44 r"file `which kpsewhich`",
45 r"file `which tex`",
46 r"file `which latex`",
48 stdin, stdout, stderr = os.popen3(command)
49 print "\"%22s\" -->" % (command),
50 for line in stdout:
51 print " %s" % line,
52 for x in [stdin, stdout, stderr]:
53 x.close()
54 print
56 def test_fontmaps():
57 allformats = []
58 allnames = {}
59 for formatstr in [
60 "pyx.pykpathsea.kpse_gf_format",
61 "pyx.pykpathsea.kpse_pk_format",
62 # "pyx.pykpathsea.kpse_any_glyph_format", # gives segmentation fault
63 "pyx.pykpathsea.kpse_tfm_format",
64 "pyx.pykpathsea.kpse_afm_format",
65 "pyx.pykpathsea.kpse_base_format",
66 "pyx.pykpathsea.kpse_bib_format",
67 "pyx.pykpathsea.kpse_bst_format",
68 "pyx.pykpathsea.kpse_cnf_format",
69 "pyx.pykpathsea.kpse_db_format",
70 "pyx.pykpathsea.kpse_fmt_format",
71 "pyx.pykpathsea.kpse_fontmap_format",
72 "pyx.pykpathsea.kpse_mem_format",
73 "pyx.pykpathsea.kpse_mf_format",
74 "pyx.pykpathsea.kpse_mfpool_format",
75 "pyx.pykpathsea.kpse_mft_format",
76 "pyx.pykpathsea.kpse_mp_format",
77 "pyx.pykpathsea.kpse_mppool_format",
78 "pyx.pykpathsea.kpse_mpsupport_format",
79 "pyx.pykpathsea.kpse_ocp_format",
80 "pyx.pykpathsea.kpse_ofm_format",
81 "pyx.pykpathsea.kpse_opl_format",
82 "pyx.pykpathsea.kpse_otp_format",
83 "pyx.pykpathsea.kpse_ovf_format",
84 "pyx.pykpathsea.kpse_ovp_format",
85 # "pyx.pykpathsea.kpse_pict_format", # unknown in python module
86 "pyx.pykpathsea.kpse_tex_format",
87 "pyx.pykpathsea.kpse_texdoc_format",
88 "pyx.pykpathsea.kpse_texpool_format",
89 "pyx.pykpathsea.kpse_texsource_format",
90 "pyx.pykpathsea.kpse_tex_ps_header_format",
91 # "pyx.pykpathsea.kpse_troff_font_format", (takes too long)
92 "pyx.pykpathsea.kpse_type1_format",
93 "pyx.pykpathsea.kpse_vf_format",
94 "pyx.pykpathsea.kpse_dvips_config_format",
95 "pyx.pykpathsea.kpse_ist_format",
96 "pyx.pykpathsea.kpse_truetype_format",
97 "pyx.pykpathsea.kpse_type42_format",
98 "pyx.pykpathsea.kpse_web2c_format",
99 "pyx.pykpathsea.kpse_program_text_format",
100 "pyx.pykpathsea.kpse_program_binary_format",
101 "pyx.pykpathsea.kpse_miscfonts_format",
102 "pyx.pykpathsea.kpse_web_format",
103 "pyx.pykpathsea.kpse_cweb_format",
104 "pyx.pykpathsea.kpse_enc_format",
105 "pyx.pykpathsea.kpse_cmap_format",
106 "pyx.pykpathsea.kpse_subfont_definition_format",
107 "pyx.pykpathsea.kpse_opentype_format",
108 "pyx.pykpathsea.kpse_pdftex_config_format",
109 "pyx.pykpathsea.kpse_lig_format",
110 "pyx.pykpathsea.kpse_texmfscripts_format",
111 "pyx.pykpathsea.kpse_lua_format",
112 "pyx.pykpathsea.kpse_font_feature_format",
113 "pyx.pykpathsea.kpse_cid_maps_format",
114 "pyx.pykpathsea.kpse_mlbib_format",
115 "pyx.pykpathsea.kpse_mlbst_format"]:
116 try:
117 allformats.append(eval(formatstr))
118 allnames[eval(formatstr)] = formatstr
119 except AttributeError:
120 continue
122 if pyx.__version__ in ["0.10"]:
123 fontmaps = pyx.text.defaulttexrunner.fontmaps.split()
124 else:
125 fontmaps = []
126 fontmaps += pyx.config.getlist("text", "pdffontmaps", ["pdftex.map"])
127 fontmaps += pyx.config.getlist("text", "psfontmaps", ["psfonts.map"])
128 for fontmap in fontmaps:
129 found = 0
130 for form in allformats:
131 mappath = pyx.pykpathsea.find_file(fontmap, form)
132 if mappath:
133 found = 1
134 print "\"%s\" found at \"%s\" as format \"%s\"" % (fontmap, mappath, allnames[form])
135 if not found:
136 print "\"%s\" not found" % fontmap
137 print
139 test_installation()
140 test_commands()
141 test_fontmaps()