@@ -116,12 +116,11 @@ def get_python_inc(plat_specific=0, prefix=None):
116116 If 'prefix' is supplied, use it instead of sys.base_prefix or
117117 sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
118118 """
119- default_prefix = prefix is None
120- if default_prefix :
121- prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
119+ default_prefix = BASE_EXEC_PREFIX if plat_specific else BASE_PREFIX
120+ resolved_prefix = prefix if prefix is not None else default_prefix
122121 if os .name == "posix" :
123122 if IS_PYPY and sys .version_info < (3 , 8 ):
124- return os .path .join (prefix , 'include' )
123+ return os .path .join (resolved_prefix , 'include' )
125124 if python_build :
126125 # Assume the executable is in the build directory. The
127126 # pyconfig.h file should be in the same directory. Since
@@ -133,7 +132,7 @@ def get_python_inc(plat_specific=0, prefix=None):
133132 else :
134133 incdir = os .path .join (get_config_var ('srcdir' ), 'Include' )
135134 return os .path .normpath (incdir )
136- if default_prefix :
135+ if prefix :
137136 # If no prefix was explicitly specified, use the include
138137 # directory from the config vars. This is useful when
139138 # cross-compiling, since the config vars may come the host
@@ -144,17 +143,17 @@ def get_python_inc(plat_specific=0, prefix=None):
144143 else :
145144 include_py = get_config_var ('INCLUDEPY' )
146145 if include_py is not None :
147- return include_py
146+ return include_py
148147 implementation = 'pypy' if IS_PYPY else 'python'
149148 python_dir = implementation + get_python_version () + build_flags
150- return os .path .join (prefix , "include" , python_dir )
149+ return os .path .join (resolved_prefix , "include" , python_dir )
151150 elif os .name == "nt" :
152151 if python_build :
153152 # Include both the include and PC dir to ensure we can find
154153 # pyconfig.h
155- return (os .path .join (prefix , "include" ) + os .path .pathsep +
156- os .path .join (prefix , "PC" ))
157- return os .path .join (prefix , "include" )
154+ return (os .path .join (resolved_prefix , "include" ) + os .path .pathsep +
155+ os .path .join (resolved_prefix , "PC" ))
156+ return os .path .join (resolved_prefix , "include" )
158157 else :
159158 raise DistutilsPlatformError (
160159 "I don't know where Python installs its C header files "
0 commit comments