@@ -186,7 +186,7 @@ def finalize_options(self):
186
186
# for extensions under windows use different directories
187
187
# for Release and Debug builds.
188
188
# also Python's library directory must be appended to library_dirs
189
- if os .name == 'nt' :
189
+ if os .name == 'nt' and not self . plat_name . startswith (( 'mingw' )) :
190
190
# the 'libs' directory is for binary installs - we assume that
191
191
# must be the *native* platform. But we don't really support
192
192
# cross-compiling via a binary install anyway, so we let it go.
@@ -712,6 +712,20 @@ def get_libraries(self, ext):
712
712
# pyconfig.h that MSVC groks. The other Windows compilers all seem
713
713
# to need it mentioned explicitly, though, so that's what we do.
714
714
# Append '_d' to the python import library on debug builds.
715
+
716
+ # Use self.plat_name as it works even in case of
717
+ # cross-compilation (at least for mingw build).
718
+ if self .plat_name .startswith ('mingw' ):
719
+ from distutils import sysconfig
720
+ extra = []
721
+ for lib in (
722
+ sysconfig .get_config_var ('BLDLIBRARY' ).split ()
723
+ + sysconfig .get_config_var ('SHLIBS' ).split ()
724
+ ):
725
+ if lib .startswith ('-l' ):
726
+ extra .append (lib [2 :])
727
+ return ext .libraries + extra
728
+
715
729
if sys .platform == "win32" :
716
730
from distutils ._msvccompiler import MSVCCompiler
717
731
if not isinstance (self .compiler , MSVCCompiler ):
0 commit comments