|
21 | 21 | from ..sysconfig import get_config_h_filename
|
22 | 22 | from ..dep_util import newer_group
|
23 | 23 | from ..extension import Extension
|
24 |
| -from ..util import get_platform |
| 24 | +from ..util import get_platform, is_mingw |
25 | 25 | from distutils import log
|
26 | 26 | from . import py37compat
|
27 | 27 |
|
@@ -190,7 +190,7 @@ def finalize_options(self): # noqa: C901
|
190 | 190 | # for extensions under windows use different directories
|
191 | 191 | # for Release and Debug builds.
|
192 | 192 | # also Python's library directory must be appended to library_dirs
|
193 |
| - if os.name == 'nt': |
| 193 | + if os.name == 'nt' and not is_mingw(): |
194 | 194 | # the 'libs' directory is for binary installs - we assume that
|
195 | 195 | # must be the *native* platform. But we don't really support
|
196 | 196 | # cross-compiling via a binary install anyway, so we let it go.
|
@@ -218,14 +218,18 @@ def finalize_options(self): # noqa: C901
|
218 | 218 | new_lib = os.path.join(new_lib, suffix)
|
219 | 219 | self.library_dirs.append(new_lib)
|
220 | 220 |
|
221 |
| - # For extensions under Cygwin, Python's library directory must be |
| 221 | + # For extensions under Cygwin and MinGW, Python's library directory must be |
222 | 222 | # appended to library_dirs
|
223 |
| - if sys.platform[:6] == 'cygwin': |
| 223 | + if sys.platform[:6] == 'cygwin' or is_mingw(): |
224 | 224 | if not sysconfig.python_build:
|
| 225 | + config_dir_name = os.path.basename(sysconfig.get_config_var('LIBPL')) |
225 | 226 | # building third party extensions
|
226 | 227 | self.library_dirs.append(
|
227 | 228 | os.path.join(
|
228 |
| - sys.prefix, "lib", "python" + get_python_version(), "config" |
| 229 | + sys.prefix, |
| 230 | + "lib", |
| 231 | + "python" + get_python_version(), |
| 232 | + config_dir_name, |
229 | 233 | )
|
230 | 234 | )
|
231 | 235 | else:
|
@@ -741,7 +745,7 @@ def get_libraries(self, ext): # noqa: C901
|
741 | 745 | # pyconfig.h that MSVC groks. The other Windows compilers all seem
|
742 | 746 | # to need it mentioned explicitly, though, so that's what we do.
|
743 | 747 | # Append '_d' to the python import library on debug builds.
|
744 |
| - if sys.platform == "win32": |
| 748 | + if sys.platform == "win32" and not is_mingw(): |
745 | 749 | from .._msvccompiler import MSVCCompiler
|
746 | 750 |
|
747 | 751 | if not isinstance(self.compiler, MSVCCompiler):
|
@@ -771,7 +775,7 @@ def get_libraries(self, ext): # noqa: C901
|
771 | 775 | # A native build on an Android device or on Cygwin
|
772 | 776 | if hasattr(sys, 'getandroidapilevel'):
|
773 | 777 | link_libpython = True
|
774 |
| - elif sys.platform == 'cygwin': |
| 778 | + elif sys.platform == 'cygwin' or is_mingw(): |
775 | 779 | link_libpython = True
|
776 | 780 | elif '_PYTHON_HOST_PLATFORM' in os.environ:
|
777 | 781 | # We are cross-compiling for one of the relevant platforms
|
|
0 commit comments