Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(6)

Unified Diff: Lib/distutils/command/build_ext.py

Issue 3871: cross and native build of python for mingw32 with distutils
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/distutils/ccompiler.py ('k') | Lib/distutils/command/install.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/distutils/command/build_ext.py Thu Dec 27 23:52:36 2012 +0200
+++ b/Lib/distutils/command/build_ext.py Thu Dec 27 17:35:12 2012 -0500
@@ -22,7 +22,8 @@
from site import USER_BASE
HAS_USER_SITE = True
-if os.name == 'nt':
+# GCC(mingw): os.name is "nt" but build system is posix
+if os.name == 'nt' and sys.version.find('GCC') < 0:
from distutils.msvccompiler import get_build_version
MSVC_VERSION = int(get_build_version())
@@ -190,7 +191,8 @@
# 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':
+ # GCC(mingw): os.name is "nt" but build system is posix
+ if os.name == 'nt' and sys.version.find('GCC') < 0:
# 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.
@@ -237,7 +239,8 @@
# for extensions under Cygwin and AtheOS Python's library directory must be
# appended to library_dirs
- if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos':
+ if (sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos'
+ or (sys.platform == 'win32' and sys.version.find('GCC') >= 0)):
if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
# building third party extensions
self.library_dirs.append(os.path.join(sys.prefix, "lib",
@@ -703,6 +706,35 @@
# 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.
+
+ # FIXME: What is purpose of code below ?
+ # The posix build system khow requred libraries to build a module.
+ # The libraries are stored in config(Makefile) variables BLDLIBRARY,
+ # MODLIBS and SHLIBS. Note that some variables may contain linker
+ # flags.
+ # NOTE: For now we will check only GCC(mingw) compiler as is clear
+ # that we build for windows platfrom.
+ # The code for GCC(mingw) is not correct but this is distutils
+ # limitation - we has to pass variables to the linker as is
+ # instead only library names.
+ if self.compiler.compiler_type == 'mingw32':
+ from distutils import sysconfig
+
+ template = "python%s"
+ if self.debug:
+ template = template + '_d'
+ extra = [(template % (sysconfig.get_config_var('VERSION')))]
+ for lib in sysconfig.get_config_var('BLDLIBRARY').split():
+ if lib.startswith('-l'):
+ extra.append(lib[2:])
+ for lib in sysconfig.get_config_var('MODLIBS').split():
+ if lib.startswith('-l'):
+ extra.append(lib[2:])
+ for lib in 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):
@@ -729,7 +761,8 @@
# don't extend ext.libraries, it may be shared with other
# extensions, it is a reference to the original list
return ext.libraries + [pythonlib]
- elif sys.platform[:6] == "cygwin":
+ # NOTE : cygwin use posix build rules ;)
+ elif sys.platform[:6] == "cygwin" and False:
template = "python%d.%d"
pythonlib = (template %
(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
« no previous file with comments | « Lib/distutils/ccompiler.py ('k') | Lib/distutils/command/install.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+