@@ -22,7 +22,7 @@ class UnsupportedError(Exception):
22
22
"""The operation isn't supported."""
23
23
24
24
25
- def _run_cmd (cmd , cwd = None , verbose = True , showcmd = True ):
25
+ def _run_cmd (cmd , cwd = None , verbose = True , showcmd = True , showerr = True ):
26
26
if showcmd :
27
27
print (f'# { " " .join (shlex .quote (a ) for a in cmd )} ' )
28
28
proc = subprocess .run (
@@ -32,7 +32,8 @@ def _run_cmd(cmd, cwd=None, verbose=True, showcmd=True):
32
32
text = True ,
33
33
)
34
34
if proc .returncode != 0 :
35
- print (proc .stderr , file = sys .stderr )
35
+ if showerr :
36
+ print (proc .stderr , file = sys .stderr )
36
37
proc .check_returncode ()
37
38
return proc .stdout
38
39
@@ -102,18 +103,19 @@ def get_config_var(build, name, *, fail=True):
102
103
else :
103
104
builddir = build
104
105
python = os .path .join (builddir , 'python' )
105
- if not os .path .isfile (python ):
106
- return get_makefile_var (builddir , 'CONFIG_ARGS' , fail = fail )
107
106
108
- try :
109
- text = _run_cmd (
110
- [python , '-c' ,
111
- 'import sysconfig' , 'print(sysconfig.get_config_var("CONFIG_ARGS"))' ],
112
- showcmd = False ,
113
- )
114
- return text
115
- except subprocess .CalledProcessError :
116
- return get_makefile_var (builddir , 'CONFIG_ARGS' , fail = fail )
107
+ if os .path .isfile (python ):
108
+ try :
109
+ text = _run_cmd (
110
+ [python , '-c' ,
111
+ f'import sysconfig; print(sysconfig.get_config_var("{ name } "))' ],
112
+ showcmd = False ,
113
+ showerr = False ,
114
+ )
115
+ return text
116
+ except subprocess .CalledProcessError :
117
+ pass
118
+ return get_makefile_var (builddir , name , fail = fail )
117
119
118
120
119
121
def get_configure_args (build , * , fail = True ):
0 commit comments