Files
MINGW-packages/mingw-w64-python3/0410-MINGW-build-extensions-with-GCC.patch
2014-10-11 14:46:25 +01:00

58 lines
2.6 KiB
Diff

diff -urN a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
--- a/Lib/distutils/command/build_ext.py 2014-10-11 14:20:28.478362800 +0100
+++ b/Lib/distutils/command/build_ext.py 2014-10-11 14:20:30.943503700 +0100
@@ -181,7 +181,7 @@
# for extensions under windows use different directories
# for Release and Debug builds.
# also Python's library directory must be appended to library_dirs
- if os.name == 'nt':
+ if os.name == 'nt' and not self.plat_name.startswith(('mingw')):
# the 'libs' directory is for binary installs - we assume that
# must be the *native* platform. But we don't really support
# cross-compiling via a binary install anyway, so we let it go.
@@ -682,6 +682,20 @@
# pyconfig.h that MSVC groks. The other Windows compilers all seem
# to need it mentioned explicitly, though, so that's what we do.
# Append '_d' to the python import library on debug builds.
+
+ # Use self.plat_name as it works even in case of
+ # cross-compilation (at least for mingw build).
+ if self.plat_name.startswith('mingw'):
+ from distutils import sysconfig
+ extra = []
+ for lib in (
+ sysconfig.get_config_var('BLDLIBRARY').split()
+ + sysconfig.get_config_var('SHLIBS').split()
+ ):
+ if lib.startswith('-l'):
+ extra.append(lib[2:])
+ return ext.libraries + extra
+
if sys.platform == "win32":
from distutils.msvccompiler import MSVCCompiler
if not isinstance(self.compiler, MSVCCompiler):
diff -urN a/Lib/distutils/util.py b/Lib/distutils/util.py
--- a/Lib/distutils/util.py 2014-10-11 14:20:28.476362600 +0100
+++ b/Lib/distutils/util.py 2014-10-11 14:20:30.945503900 +0100
@@ -40,6 +40,8 @@
For other non-POSIX platforms, currently just returns 'sys.platform'.
"""
if os.name == 'nt':
+ if 'GCC' in sys.version:
+ return 'mingw'
# sniff sys.version for architecture.
prefix = " bit ("
i = sys.version.find(prefix)
diff -urN a/Lib/sysconfig.py b/Lib/sysconfig.py
--- a/Lib/sysconfig.py 2014-10-11 14:20:28.531365800 +0100
+++ b/Lib/sysconfig.py 2014-10-11 14:20:30.946503900 +0100
@@ -629,6 +629,8 @@
For other non-POSIX platforms, currently just returns 'sys.platform'.
"""
if os.name == 'nt':
+ if 'GCC' in sys.version:
+ return 'mingw'
# sniff sys.version for architecture.
prefix = " bit ("
i = sys.version.find(prefix)