File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change 10
10
import platform
11
11
import logging
12
12
import tempfile
13
+ import shutil
13
14
import subprocess
14
15
import warnings
15
16
@@ -46,21 +47,34 @@ def find_xml_generator(name="castxml"):
46
47
pygccxml does currently only support castxml as c++ parser.
47
48
48
49
"""
50
+
51
+ if sys .version_info >= (3 , 3 ):
52
+ path = _find_xml_generator_for_python_greater_equals_33 (name )
53
+ else :
54
+ path = _find_xml_generator_for_legacy_python (name )
55
+
56
+ if path == "" :
57
+ raise (Exception ("No c++ parser found. Please install castxml." ))
58
+ else :
59
+ return path .rstrip (), name
60
+
61
+
62
+ def _find_xml_generator_for_python_greater_equals_33 (name ):
63
+ return shutil .which (name )
64
+
65
+
66
+ def _find_xml_generator_for_legacy_python (name ):
49
67
if platform .system () == "Windows" :
50
68
command = "where"
51
69
else :
52
70
command = "which"
53
-
54
71
p = subprocess .Popen ([command , name ], stdout = subprocess .PIPE ,
55
72
stderr = subprocess .PIPE )
56
73
path = p .stdout .read ().decode ("utf-8" )
57
74
p .wait ()
58
75
p .stdout .close ()
59
76
p .stderr .close ()
60
- if path == "" :
61
- raise (Exception ("No c++ parser found. Please install castxml." ))
62
- else :
63
- return path .rstrip (), name
77
+ return path .rstrip ()
64
78
65
79
66
80
def _create_logger_ (name ):
You can’t perform that action at this time.
0 commit comments