[Numpy-svn] r4415 - branches/numpy.scons/numpy/distutils/scons/core
numpy-svn at scipy.org
numpy-svn at scipy.org
Thu Nov 8 03:54:09 EST 2007
Author: cdavid
Date: 2007-11-08 02:54:02 -0600 (Thu, 08 Nov 2007)
New Revision: 4415
Modified:
branches/numpy.scons/numpy/distutils/scons/core/extension_scons.py
Log:
Use SharedLibrary builer with mingw instead of LoadableModule because the latter is buggy with current scons
Modified: branches/numpy.scons/numpy/distutils/scons/core/extension_scons.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/core/extension_scons.py 2007-11-08 08:52:27 UTC (rev 4414)
+++ branches/numpy.scons/numpy/distutils/scons/core/extension_scons.py 2007-11-08 08:54:02 UTC (rev 4415)
@@ -5,12 +5,34 @@
import sys
from copy import deepcopy
+from distutils.unixccompiler import UnixCCompiler
+from numpy.distutils.misc_util import msvc_runtime_library
+
from extension import get_pythonlib_dir, get_python_inc
def built_with_mstools(env):
"""Return True if built with MS tools (compiler + linker)."""
- return env.has_key('MSVS')
+ # Handle case where MSVS is found, but mingw is used
+ return env.has_key('MSVS') and not built_with_mingw
+def built_with_mingw(env):
+ """Return true if built with mingw compiler."""
+ return env['cc_opt'] == 'mingw'
+
+def get_pythonlib_name(debug = 0):
+ """Return the name of python library (necessary to link on NT with
+ mingw."""
+ # Yeah, distutils burried the link option on NT deep down in
+ # Extension module, we cannot reuse it !
+ if debug == 1:
+ template = 'python%d%d_d'
+ else:
+ template = 'python%d%d'
+
+ return template % (sys.hexversion >> 24,
+ (sys.hexversion >> 16) & 0xff)
+
+
def PythonExtension(env, target, source, *args, **kw):
# XXX Check args and kw
# XXX: Some things should not be set here...
@@ -24,20 +46,58 @@
else:
CPPPATH = []
+ if env.has_key('LIBPATH'):
+ LIBPATH = deepcopy(env['LIBPATH'])
+ else:
+ LIBPATH = []
+
+ if env.has_key('LIBS'):
+ LIBS = deepcopy(env['LIBS'])
+ else:
+ LIBS = []
+
CPPPATH.append(get_python_inc())
if sys.platform == 'win32':
if built_with_mstools(env):
- # XXX: We add the path where to find python2.5.lib (or any other
+ # XXX: We add the path where to find python lib (or any other
# version, of course). This seems to be necessary for MS compilers.
- env.AppendUnique(LIBPATH = get_pythonlib_dir())
+ #env.AppendUnique(LIBPATH = get_pythonlib_dir())
+ LIBPATH.append(get_pythonlib_dir())
+ elif built_with_mingw(env):
+ # XXX: this part should be moved elsewhere (mingw abstraction
+ # for python)
+
+ # This is copied from mingw32ccompiler.py in numpy.distutils
+ # (not supported by distutils.)
+
+ # Include the appropiate MSVC runtime library if Python was
+ # built with MSVC >= 7.0 (MinGW standard is msvcrt)
+ py_runtime_library = msvc_runtime_library()
+ LIBPATH.append(get_pythonlib_dir())
+ LIBS.extend([get_pythonlib_name(), py_runtime_library])
+
elif sys.platform == "darwin":
# XXX: When those should be used ? (which version of Mac OS X ?)
LINKFLAGS += ' -undefined dynamic_lookup '
# Use LoadableModule because of Mac OS X
- wrap = env.LoadableModule(target, source, SHLIBPREFIX = '',
- LDMODULESUFFIX = '$PYEXTSUFFIX',
- SHLIBSUFFIX = '$PYEXTSUFFIX',
- LINKFLAGS = LINKFLAGS,
- CPPPATH = CPPPATH, *args, **kw)
+ # ... but scons has a bug (#issue 1669) with mingw and Loadable
+ # Module, so use SharedLibrary with mingw.
+ if built_with_mingw(env):
+ wrap = env.SharedLibrary(target, source, SHLIBPREFIX = '',
+ #LDMODULESUFFIX = '$PYEXTSUFFIX',
+ SHLIBSUFFIX = '$PYEXTSUFFIX',
+ LINKFLAGS = LINKFLAGS,
+ LIBS = LIBS,
+ LIBPATH = LIBPATH,
+ CPPPATH = CPPPATH,
+ *args, **kw)
+ else:
+ wrap = env.LoadableModule(target, source, SHLIBPREFIX = '',
+ LDMODULESUFFIX = '$PYEXTSUFFIX',
+ SHLIBSUFFIX = '$PYEXTSUFFIX',
+ LINKFLAGS = LINKFLAGS,
+ LIBS = LIBS,
+ LIBPATH = LIBPATH,
+ CPPPATH = CPPPATH, *args, **kw)
return wrap
More information about the Numpy-svn
mailing list