summaryrefslogtreecommitdiff
path: root/command/config.py
diff options
context:
space:
mode:
authorcookedm <cookedm@localhost>2007-05-21 13:15:45 +0000
committercookedm <cookedm@localhost>2007-05-21 13:15:45 +0000
commit6ac33ee4e12b78b164a05046f7e029681f0e09a3 (patch)
treed5a4b6f27ff9e3d596bafdb4c93953d5431d0a40 /command/config.py
parentb93a94b5e15d229e253353289c571c7a3142a642 (diff)
downloadnumpy-6ac33ee4e12b78b164a05046f7e029681f0e09a3.tar.gz
[distutils-revamp] Merged revisions 3769-3794 via svnmerge from
http://svn.scipy.org/svn/numpy/trunk/numpy/distutils ........ r3775 | pearu | 2007-05-18 10:32:33 -0400 (Fri, 18 May 2007) | 1 line build_src: introduced --swig and other related options (as in std distutils build_ext command), use --f2py-opts instead of --f2pyflags, improved error messages. ........ r3776 | pearu | 2007-05-18 12:41:44 -0400 (Fri, 18 May 2007) | 1 line Extension modules and libraries are built with suitable compilers/linkers. Improved failure handling. ........ r3779 | pearu | 2007-05-18 13:33:15 -0400 (Fri, 18 May 2007) | 1 line Fixed warnings on language changes. ........ r3780 | pearu | 2007-05-18 16:17:48 -0400 (Fri, 18 May 2007) | 1 line unify config_fc, build_clib, build_ext commands --fcompiler options so that --fcompiler can be specified only once in a command line ........ r3781 | pearu | 2007-05-18 16:41:10 -0400 (Fri, 18 May 2007) | 1 line added config to --fcompiler option unification method. introduced config_cc for unifying --compiler options. ........ r3782 | pearu | 2007-05-18 16:49:09 -0400 (Fri, 18 May 2007) | 1 line Added --help-fcompiler option to build_ext command. ........ r3783 | pearu | 2007-05-18 17:00:17 -0400 (Fri, 18 May 2007) | 1 line show less messages in --help-fcompiler ........ r3784 | pearu | 2007-05-18 17:25:23 -0400 (Fri, 18 May 2007) | 1 line Added --fcompiler,--help-fcompiler options to build command parallel to --compiler,--help-compiler options. ........ r3785 | pearu | 2007-05-18 17:33:07 -0400 (Fri, 18 May 2007) | 1 line Add descriptions to config_fc and config_cc commands. ........ r3786 | pearu | 2007-05-19 05:54:00 -0400 (Sat, 19 May 2007) | 1 line Fix for win32 platform. ........ r3787 | pearu | 2007-05-19 06:23:16 -0400 (Sat, 19 May 2007) | 1 line Fix fcompiler/compiler unification warning. ........ r3788 | pearu | 2007-05-19 11:20:48 -0400 (Sat, 19 May 2007) | 1 line Fix atlas version detection when using MSVC compiler ........ r3789 | pearu | 2007-05-19 11:21:41 -0400 (Sat, 19 May 2007) | 1 line Fix typo. ........ r3790 | pearu | 2007-05-19 11:24:20 -0400 (Sat, 19 May 2007) | 1 line More typo fixes. ........ r3791 | pearu | 2007-05-19 13:01:39 -0400 (Sat, 19 May 2007) | 1 line win32: fix install when build has been carried out earlier. ........ r3792 | pearu | 2007-05-19 15:44:42 -0400 (Sat, 19 May 2007) | 1 line Clean up and completed (hopefully) MSVC support. ........ r3794 | cookedm | 2007-05-21 09:01:20 -0400 (Mon, 21 May 2007) | 1 line minor cleanups in numpy.distutils (style mostly) ........
Diffstat (limited to 'command/config.py')
-rw-r--r--command/config.py86
1 files changed, 56 insertions, 30 deletions
diff --git a/command/config.py b/command/config.py
index 2a015e400..f4e96664c 100644
--- a/command/config.py
+++ b/command/config.py
@@ -3,56 +3,41 @@
# compilers (they must define linker_exe first).
# Pearu Peterson
-import os, signal, copy
+import os, signal
from distutils.command.config import config as old_config
from distutils.command.config import LANG_EXT
from distutils import log
+from distutils.file_util import copy_file
from numpy.distutils.exec_command import exec_command
-from numpy.distutils.fcompiler import FCompiler, new_fcompiler
LANG_EXT['f77'] = '.f'
LANG_EXT['f90'] = '.f90'
class config(old_config):
old_config.user_options += [
- ('fcompiler=', None,
- "specify the Fortran compiler type"),
+ ('fcompiler=', None, "specify the Fortran compiler type"),
]
def initialize_options(self):
self.fcompiler = None
old_config.initialize_options(self)
- def finalize_options(self):
- old_config.finalize_options(self)
- f = self.distribution.get_command_obj('config_fc')
- self.set_undefined_options('config_fc',
- ('fcompiler', 'fcompiler'))
- self._fcompiler = None
-
- def run(self):
- self._check_compiler()
-
- def _check_compiler(self):
+ def _check_compiler (self):
old_config._check_compiler(self)
-
- def get_fcompiler(self):
- if self._fcompiler is None:
- fc = self.fcompiler.fortran()
- fc.force = 1
- fc.dry_run = self.dry_run
- fc.customize(self.distribution)
- fc.customize_cmd(self)
- fc.show_customization()
- self._fcompiler = fc
- return self._fcompiler
-
- def _wrap_method(self, mth, lang, args):
+ from numpy.distutils.fcompiler import FCompiler, new_fcompiler
+ if not isinstance(self.fcompiler, FCompiler):
+ self.fcompiler = new_fcompiler(compiler=self.fcompiler,
+ dry_run=self.dry_run, force=1)
+ self.fcompiler.customize(self.distribution)
+ self.fcompiler.customize_cmd(self)
+ self.fcompiler.show_customization()
+
+ def _wrap_method(self,mth,lang,args):
from distutils.ccompiler import CompileError
from distutils.errors import DistutilsExecError
save_compiler = self.compiler
- if lang in ('f77', 'f90'):
- self.compiler = self.get_fcompiler()
+ if lang in ['f77','f90']:
+ self.compiler = self.fcompiler
try:
ret = mth(*((self,)+args))
except (DistutilsExecError,CompileError),msg:
@@ -68,6 +53,47 @@ class config(old_config):
def _link (self, body,
headers, include_dirs,
libraries, library_dirs, lang):
+ if self.compiler.compiler_type=='msvc':
+ libraries = (libraries or [])[:]
+ library_dirs = (library_dirs or [])[:]
+ if lang in ['f77','f90']:
+ lang = 'c' # always use system linker when using MSVC compiler
+ if self.fcompiler:
+ for d in self.fcompiler.library_dirs or []:
+ # correct path when compiling in Cygwin but with
+ # normal Win Python
+ if d.startswith('/usr/lib'):
+ s,o = exec_command(['cygpath', '-w', d],
+ use_tee=False)
+ if not s: d = o
+ library_dirs.append(d)
+ for libname in self.fcompiler.libraries or []:
+ if libname not in libraries:
+ libraries.append(libname)
+ for libname in libraries:
+ if libname.startswith('msvc'): continue
+ fileexists = False
+ for libdir in library_dirs or []:
+ libfile = os.path.join(libdir,'%s.lib' % (libname))
+ if os.path.isfile(libfile):
+ fileexists = True
+ break
+ if fileexists: continue
+ # make g77-compiled static libs available to MSVC
+ fileexists = False
+ for libdir in library_dirs:
+ libfile = os.path.join(libdir,'lib%s.a' % (libname))
+ if os.path.isfile(libfile):
+ # copy libname.a file to name.lib so that MSVC linker
+ # can find it
+ libfile2 = os.path.join(libdir,'%s.lib' % (libname))
+ copy_file(libfile, libfile2)
+ self.temp_files.append(libfile2)
+ fileexists = True
+ break
+ if fileexists: continue
+ log.warn('could not find library %r in directories %s' \
+ % (libname, library_dirs))
return self._wrap_method(old_config._link,lang,
(body, headers, include_dirs,
libraries, library_dirs, lang))