Skip to content

Commit ff9b6d1

Browse files
committed
In _get_python_inc_posix, only return an extant path from the sysconfig. Fixes pypa/distutils#178.
1 parent 3e9d47e commit ff9b6d1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

distutils/sysconfig.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,20 @@ def get_python_inc(plat_specific=0, prefix=None):
130130
return getter(resolved_prefix, prefix, plat_specific)
131131

132132

133+
@pass_none
134+
def _extant(path):
135+
"""
136+
Replace path with None if it doesn't exist.
137+
"""
138+
return path if os.path.exists(path) else None
139+
140+
133141
def _get_python_inc_posix(prefix, spec_prefix, plat_specific):
134142
if IS_PYPY and sys.version_info < (3, 8):
135143
return os.path.join(prefix, 'include')
136144
return (
137145
_get_python_inc_posix_python(plat_specific)
138-
or _get_python_inc_from_config(plat_specific, spec_prefix)
146+
or _extant(_get_python_inc_from_config(plat_specific, spec_prefix))
139147
or _get_python_inc_posix_prefix(prefix)
140148
)
141149

0 commit comments

Comments
 (0)