Skip to content

Commit bf95b31

Browse files
Fall back to Makefile if sysconfig fails.
1 parent 8e4e52e commit bf95b31

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Tools/freeze/test/freeze.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,22 @@ def get_makefile_var(builddir, name, *, fail=True):
9898
def get_config_var(build, name, *, fail=True):
9999
if os.path.isfile(build):
100100
python = build
101+
builddir = os.path.dirname(build)
101102
else:
102103
builddir = build
103104
python = os.path.join(builddir, 'python')
104105
if not os.path.isfile(python):
105106
return get_makefile_var(builddir, 'CONFIG_ARGS', fail=fail)
106107

107-
text = _run_cmd(
108-
[python, '-c',
109-
'import sysconfig', 'print(sysconfig.get_config_var("CONFIG_ARGS"))'],
110-
showcmd=False,
111-
)
112-
return text
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)
113117

114118

115119
def get_configure_args(build, *, fail=True):

0 commit comments

Comments
 (0)