summaryrefslogtreecommitdiff
path: root/scipy_distutils/ccompiler.py
diff options
context:
space:
mode:
authorPearu Peterson <pearu.peterson@gmail.com>2004-02-04 14:30:06 +0000
committerPearu Peterson <pearu.peterson@gmail.com>2004-02-04 14:30:06 +0000
commitaa6fd3365a968a4c322dff8850466aabb96a1c53 (patch)
treee13e917d837bbf65b0d720c2e96b6e98f7b729a3 /scipy_distutils/ccompiler.py
parentda3e21058bbbac8c8f53037c8932ca4e05ddb7b1 (diff)
downloadnumpy-aa6fd3365a968a4c322dff8850466aabb96a1c53.tar.gz
Got scipy_core to build on win32 with new build_src hooks
Diffstat (limited to 'scipy_distutils/ccompiler.py')
-rw-r--r--scipy_distutils/ccompiler.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/scipy_distutils/ccompiler.py b/scipy_distutils/ccompiler.py
new file mode 100644
index 000000000..3e11f82b9
--- /dev/null
+++ b/scipy_distutils/ccompiler.py
@@ -0,0 +1,63 @@
+
+import re
+import os
+import sys
+
+from distutils.ccompiler import *
+from distutils import ccompiler
+
+import log
+
+if sys.platform == 'win32':
+ compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler',
+ "Mingw32 port of GNU C Compiler for Win32"\
+ "(for MSC built Python)")
+ if os.environ.get('OSTYPE','')=='msys':
+ # On windows platforms, we want to default to mingw32 (gcc)
+ # because msvc can't build blitz stuff.
+ log.info('Setting mingw32 as default compiler for nt.')
+ ccompiler._default_compilers = (('nt', 'mingw32'),) \
+ + ccompiler._default_compilers
+
+_distutils_new_compiler = new_compiler
+def new_compiler (plat=None,
+ compiler=None,
+ verbose=0,
+ dry_run=0,
+ force=0):
+ # Try first C compilers from scipy_distutils.
+ if plat is None:
+ plat = os.name
+ try:
+ if compiler is None:
+ compiler = get_default_compiler(plat)
+ (module_name, class_name, long_description) = compiler_class[compiler]
+ except KeyError:
+ msg = "don't know how to compile C/C++ code on platform '%s'" % plat
+ if compiler is not None:
+ msg = msg + " with '%s' compiler" % compiler
+ raise DistutilsPlatformError, msg
+
+ module_name = "scipy_distutils." + module_name
+ try:
+ __import__ (module_name)
+ except ImportError, msg:
+ print msg
+ module_name = module_name[6:]
+ try:
+ __import__(module_name)
+ except ImportError:
+ raise DistutilsModuleError, \
+ "can't compile C/C++ code: unable to load module '%s'" % \
+ module_name
+ try:
+ module = sys.modules[module_name]
+ klass = vars(module)[class_name]
+ except KeyError:
+ raise DistutilsModuleError, \
+ ("can't compile C/C++ code: unable to find class '%s' " +
+ "in module '%s'") % (class_name, module_name)
+ print '*'*80
+ print module_name,klass
+ print '*'*80
+ return klass(None, dry_run, force)