Files
MINGW-packages/mingw-w64-python2/0410-MINGW-build-extensions-with-GCC.patch

58 lines
2.6 KiB
Diff

diff -Naur a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
--- a/Lib/distutils/command/build_ext.py 2014-02-18 09:32:05.382200000 +0400
+++ b/Lib/distutils/command/build_ext.py 2014-02-18 09:32:25.303400000 +0400
@@ -179,7 +179,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.
@@ -697,6 +697,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 -Naur a/Lib/distutils/util.py b/Lib/distutils/util.py
--- a/Lib/distutils/util.py 2013-11-10 11:36:40.000000000 +0400
+++ b/Lib/distutils/util.py 2014-02-18 09:32:25.319000000 +0400
@@ -38,6 +38,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 = string.find(sys.version, prefix)
diff -Naur a/Lib/sysconfig.py b/Lib/sysconfig.py
--- a/Lib/sysconfig.py 2013-11-10 11:36:40.000000000 +0400
+++ b/Lib/sysconfig.py 2014-02-18 09:32:25.319000000 +0400
@@ -542,6 +542,8 @@
"""
import re
if os.name == 'nt':
+ if 'GCC' in sys.version:
+ return 'mingw'
# sniff sys.version for architecture.
prefix = " bit ("
i = sys.version.find(prefix)