@@ -181,7 +181,7 @@ def finalize_options(self):
181
181
# for extensions under windows use different directories
182
182
# for Release and Debug builds.
183
183
# also Python's library directory must be appended to library_dirs
184
- if os .name == 'nt' :
184
+ if os .name == 'nt' and not self . plat_name . startswith (( 'mingw' )) :
185
185
# the 'libs' directory is for binary installs - we assume that
186
186
# must be the *native* platform. But we don't really support
187
187
# cross-compiling via a binary install anyway, so we let it go.
@@ -682,6 +682,20 @@ def get_libraries(self, ext):
682
682
# pyconfig.h that MSVC groks. The other Windows compilers all seem
683
683
# to need it mentioned explicitly, though, so that's what we do.
684
684
# Append '_d' to the python import library on debug builds.
685
+
686
+ # Use self.plat_name as it works even in case of
687
+ # cross-compilation (at least for mingw build).
688
+ if self .plat_name .startswith ('mingw' ):
689
+ from distutils import sysconfig
690
+ extra = []
691
+ for lib in (
692
+ sysconfig .get_config_var ('BLDLIBRARY' ).split ()
693
+ + sysconfig .get_config_var ('SHLIBS' ).split ()
694
+ ):
695
+ if lib .startswith ('-l' ):
696
+ extra .append (lib [2 :])
697
+ return ext .libraries + extra
698
+
685
699
if sys .platform == "win32" :
686
700
from distutils .msvccompiler import MSVCCompiler
687
701
if not isinstance (self .compiler , MSVCCompiler ):
0 commit comments