diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/distutils/ccompiler.py | 9 | ||||
-rw-r--r-- | numpy/distutils/conv_template.py | 40 | ||||
-rw-r--r-- | numpy/distutils/core.py | 61 | ||||
-rw-r--r-- | numpy/distutils/exec_command.py | 52 | ||||
-rw-r--r-- | numpy/distutils/from_template.py | 12 | ||||
-rw-r--r-- | numpy/distutils/intelccompiler.py | 2 | ||||
-rw-r--r-- | numpy/distutils/misc_util.py | 16 | ||||
-rw-r--r-- | numpy/distutils/system_info.py | 2 |
8 files changed, 81 insertions, 113 deletions
diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py index b3c131316..bf077bacc 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py @@ -259,6 +259,8 @@ def CCompiler_get_version(self, force=0, ok_status=[0]): version_cmd = self.version_cmd except AttributeError: return None + if not version_cmd or not version_cmd[0]: + return None cmd = ' '.join(version_cmd) try: matcher = self.version_match @@ -278,9 +280,7 @@ def CCompiler_get_version(self, force=0, ok_status=[0]): version = None if status in ok_status: version = matcher(output) - if not version: - log.warn("Couldn't match compiler version for %r" % (output,)) - else: + if version: version = LooseVersion(version) self.version = version return version @@ -341,7 +341,8 @@ def new_compiler (plat=None, try: __import__ (module_name) except ImportError, msg: - print msg,'in numpy.distutils, trying from distutils..' + log.info('%s in numpy.distutils; trying from distutils', + str(msg)) module_name = module_name[6:] try: __import__(module_name) diff --git a/numpy/distutils/conv_template.py b/numpy/distutils/conv_template.py index 37baf47b7..591ae54ad 100644 --- a/numpy/distutils/conv_template.py +++ b/numpy/distutils/conv_template.py @@ -18,14 +18,9 @@ __all__ = ['process_str', 'process_file'] -import string,os,sys -if sys.version[:3]>='2.3': - import re -else: - import pre as re - False = 0 - True = 1 - +import os +import sys +import re def parse_structure(astr): spanlist = [] @@ -66,7 +61,8 @@ def conv(astr): # with 'a,b,c,a,b,c,a,b,c,a,b,c' astr = parenrep.sub(paren_repl,astr) # replaces occurences of xxx*3 with xxx, xxx, xxx - astr = ','.join([plainrep.sub(paren_repl,x.strip()) for x in astr.split(',')]) + astr = ','.join([plainrep.sub(paren_repl,x.strip()) + for x in astr.split(',')]) return astr def unique_key(adict): @@ -85,40 +81,38 @@ def unique_key(adict): done = True return newkey -def namerepl(match): - global _names, _thissub - name = match.group(1) - return _names[name][_thissub] - def expand_sub(substr, namestr, line): - global _names, _thissub # find all named replacements reps = named_re.findall(namestr) - _names = {} - _names.update(_special_names) + names = {} + names.update(_special_names) numsubs = None for rep in reps: name = rep[0].strip() thelist = conv(rep[1]) - _names[name] = thelist + names[name] = thelist # make lists out of string entries in name dictionary - for name in _names.keys(): - entry = _names[name] + for name in names.keys(): + entry = names[name] entrylist = entry.split(',') - _names[name] = entrylist + names[name] = entrylist num = len(entrylist) if numsubs is None: numsubs = num - elif (numsubs != num): + elif numsubs != num: print namestr print substr raise ValueError, "Mismatch in number to replace" # now replace all keys for each of the lists mystr = '' + thissub = [None] + def namerepl(match): + name = match.group(1) + return names[name][thissub[0]] for k in range(numsubs): - _thissub = k + thissub[0] = k mystr += ("#line %d\n%s\n\n" % (line, template_re.sub(namerepl, substr))) return mystr diff --git a/numpy/distutils/core.py b/numpy/distutils/core.py index 5e21fefe7..589e97bc0 100644 --- a/numpy/distutils/core.py +++ b/numpy/distutils/core.py @@ -16,20 +16,14 @@ else: from distutils.core import setup as old_setup have_setuptools = False +import warnings +import distutils.core +import distutils.dist + from numpy.distutils.extension import Extension -from numpy.distutils.command import config -from numpy.distutils.command import build -from numpy.distutils.command import build_py -from numpy.distutils.command import config_compiler -from numpy.distutils.command import build_ext -from numpy.distutils.command import build_clib -from numpy.distutils.command import build_src -from numpy.distutils.command import build_scripts -from numpy.distutils.command import sdist -from numpy.distutils.command import install_data -from numpy.distutils.command import install_headers -from numpy.distutils.command import install -from numpy.distutils.command import bdist_rpm +from numpy.distutils.command import config, config_compiler, \ + build, build_py, build_ext, build_clib, build_src, build_scripts, \ + sdist, install_data, install_headers, install, bdist_rpm from numpy.distutils.misc_util import get_data_files, is_sequence, is_string numpy_cmdclass = {'build': build.build, @@ -61,20 +55,15 @@ def _dict_append(d, **kws): continue dv = d[k] if isinstance(dv, tuple): - dv += tuple(v) - continue - if isinstance(dv, list): - dv += list(v) - continue - if isinstance(dv, dict): + d[k] = dv + tuple(v) + elif isinstance(dv, list): + d[k] = dv + list(v) + elif isinstance(dv, dict): _dict_append(dv, **v) - continue - if isinstance(dv, str): - assert isinstance(v,str),`type(v)` - d[k] = v - continue - raise TypeError,`type(dv)` - return + elif is_string(dv): + d[k] = dv + v + else: + raise TypeError, repr(type(dv)) def _command_line_ok(_cache=[]): """ Return True if command line does not contain any @@ -102,6 +91,21 @@ def _exit_interactive_session(_cache=[]): raw_input('Press ENTER to close the interactive session..') print '='*72 +def get_distribution(always=False): + dist = distutils.core._setup_distribution + # XXX Hack to get numpy installable with easy_install. + # The problem is easy_install runs it's own setup(), which + # sets up distutils.core._setup_distribution. However, + # when our setup() runs, that gets overwritten and lost. + # We can't use isinstance, as the DistributionWithoutHelpCommands + # class is local to a function in setuptools.command.easy_install + if dist is not None and \ + repr(dist).find('DistributionWithoutHelpCommands') != -1: + dist = None + if always and dist is None: + dist = distutils.dist.Distribution() + return dist + def setup(**attr): if len(sys.argv)<=1 and not attr.get('script_args',[]): @@ -124,7 +128,6 @@ def setup(**attr): # or help request in command in the line. configuration = new_attr.pop('configuration') - import distutils.core old_dist = distutils.core._setup_distribution old_stop = distutils.core._setup_stop_after distutils.core._setup_distribution = None @@ -173,7 +176,6 @@ def setup(**attr): return old_setup(**new_attr) def _check_append_library(libraries, item): - import warnings for libitem in libraries: if is_sequence(libitem): if is_sequence(item): @@ -198,10 +200,8 @@ def _check_append_library(libraries, item): if item==libitem: return libraries.append(item) - return def _check_append_ext_library(libraries, (lib_name,build_info)): - import warnings for item in libraries: if is_sequence(item): if item[0]==lib_name: @@ -215,4 +215,3 @@ def _check_append_ext_library(libraries, (lib_name,build_info)): " no build_info" % (lib_name,)) break libraries.append((lib_name,build_info)) - return diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py index 43ec4bf4e..e00753b9a 100644 --- a/numpy/distutils/exec_command.py +++ b/numpy/distutils/exec_command.py @@ -123,59 +123,47 @@ def test_splitcmdline(): ############################################################ def find_executable(exe, path=None): - """ Return full path of a executable. + """Return full path of a executable. + + Symbolic links are not followed. """ log.debug('find_executable(%r)' % exe) orig_exe = exe + if path is None: path = os.environ.get('PATH',os.defpath) if os.name=='posix' and sys.version[:3]>'2.1': realpath = os.path.realpath else: realpath = lambda a:a - if exe[0]=='"': + + if exe.startswith('"'): exe = exe[1:-1] - suffices = [''] + + suffixes = [''] if os.name in ['nt','dos','os2']: fn,ext = os.path.splitext(exe) - extra_suffices = ['.exe','.com','.bat'] - if ext.lower() not in extra_suffices: - suffices = extra_suffices + extra_suffixes = ['.exe','.com','.bat'] + if ext.lower() not in extra_suffixes: + suffixes = extra_suffixes + if os.path.isabs(exe): paths = [''] else: - paths = map(os.path.abspath, path.split(os.pathsep)) - if 0 and os.name == 'nt': - new_paths = [] - cygwin_paths = [] - for path in paths: - d,p = os.path.splitdrive(path) - if p.lower().find('cygwin') >= 0: - cygwin_paths.append(path) - else: - new_paths.append(path) - paths = new_paths + cygwin_paths + paths = [ os.path.abspath(p) for p in path.split(os.pathsep) ] + for path in paths: - fn = os.path.join(path,exe) - for s in suffices: + fn = os.path.join(path, exe) + for s in suffixes: f_ext = fn+s if not os.path.islink(f_ext): - # see comment below. f_ext = realpath(f_ext) - if os.path.isfile(f_ext) and os.access(f_ext,os.X_OK): + if os.path.isfile(f_ext) and os.access(f_ext, os.X_OK): log.debug('Found executable %s' % f_ext) return f_ext - if os.path.islink(exe): - # Don't follow symbolic links. E.g. when using colorgcc then - # gcc -> /usr/bin/colorgcc - # g77 -> /usr/bin/colorgcc - pass - else: - exe = realpath(exe) - if not os.path.isfile(exe) or os.access(exe,os.X_OK): - log.warn('Could not locate executable %s' % orig_exe) - return orig_exe - return exe + + log.warn('Could not locate executable %s' % orig_exe) + return None ############################################################ diff --git a/numpy/distutils/from_template.py b/numpy/distutils/from_template.py index 93bbbc82d..6cfc88ddb 100644 --- a/numpy/distutils/from_template.py +++ b/numpy/distutils/from_template.py @@ -48,15 +48,9 @@ process_file(filename) __all__ = ['process_str','process_file'] -import string,os,sys -if sys.version[:3]>='2.3': - import re -else: - import pre as re - False = 0 - True = 1 -if sys.version[:5]=='2.2.1': - import re +import os +import sys +import re routine_start_re = re.compile(r'(\n|\A)(( (\$|\*))|)\s*(subroutine|function)\b',re.I) routine_end_re = re.compile(r'\n\s*end\s*(subroutine|function)\b.*(\n|\Z)',re.I) diff --git a/numpy/distutils/intelccompiler.py b/numpy/distutils/intelccompiler.py index f7908bbe9..ff95ca9e5 100644 --- a/numpy/distutils/intelccompiler.py +++ b/numpy/distutils/intelccompiler.py @@ -26,5 +26,5 @@ class IntelItaniumCCompiler(IntelCCompiler): # On Itanium, the Intel Compiler used to be called ecc, let's search for # it (now it's also icc, so ecc is last in the search). for cc_exe in map(find_executable,['icc','ecc']): - if os.path.isfile(cc_exe): + if cc_exe: break diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index 11992374a..488e0fc8e 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -538,6 +538,8 @@ class Configuration(object): self.local_path = get_path_from_frame(caller_frame, top_path) # local_path -- directory of a file (usually setup.py) that # defines a configuration() function. + # local_path -- directory of a file (usually setup.py) that + # defines a configuration() function. if top_path is None: top_path = self.local_path if package_path is None: @@ -638,18 +640,8 @@ class Configuration(object): raise ValueError,'Unknown option: '+key def get_distribution(self): - import distutils.core - dist = distutils.core._setup_distribution - # XXX Hack to get numpy installable with easy_install. - # The problem is easy_install runs it's own setup(), which - # sets up distutils.core._setup_distribution. However, - # when our setup() runs, that gets overwritten and lost. - # We can't use isinstance, as the DistributionWithoutHelpCommands - # class is local to a function in setuptools.command.easy_install - if dist is not None and \ - repr(dist).find('DistributionWithoutHelpCommands') != -1: - return None - return dist + from numpy.distutils.core import get_distribution + return get_distribution() def _wildcard_get_subpackage(self, subpackage_name, parent_name, diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index bf2001cf7..a3a037e2a 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -1639,7 +1639,7 @@ class _pkg_config_info(system_info): def calc_info(self): config_exe = find_executable(self.get_config_exe()) - if not os.path.isfile(config_exe): + if not config_exe: log.warn('File not found: %s. Cannot determine %s info.' \ % (config_exe, self.section)) return |