diff options
Diffstat (limited to 'numpy/distutils')
52 files changed, 642 insertions, 642 deletions
diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py index 48f6f09b6..8484685c0 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py @@ -56,7 +56,7 @@ def CCompiler_spawn(self, cmd, display=None): if is_sequence(display): display = ' '.join(list(display)) log.info(display) - s,o = exec_command(cmd) + s, o = exec_command(cmd) if s: if is_sequence(cmd): cmd = ' '.join(list(cmd)) @@ -114,7 +114,7 @@ def CCompiler_object_filenames(self, source_filenames, strip_dir=0, output_dir=' raise UnknownFileError("unknown file type '%s' (from '%s')" % (ext, src_name)) if strip_dir: base = os.path.basename(base) - obj_name = os.path.join(output_dir,base + self.obj_extension) + obj_name = os.path.join(output_dir, base + self.obj_extension) obj_names.append(obj_name) return obj_names @@ -170,8 +170,8 @@ def CCompiler_compile(self, sources, output_dir=None, macros=None, from numpy.distutils.fcompiler import FCompiler if isinstance(self, FCompiler): display = [] - for fc in ['f77','f90','fix']: - fcomp = getattr(self,'compiler_'+fc) + for fc in ['f77', 'f90', 'fix']: + fcomp = getattr(self, 'compiler_'+fc) if fcomp is None: continue display.append("Fortran %s compiler: %s" % (fc, ' '.join(fcomp))) @@ -236,7 +236,7 @@ def CCompiler_customize_cmd(self, cmd, ignore=()): if allow('include_dirs'): self.set_include_dirs(cmd.include_dirs) if allow('define'): - for (name,value) in cmd.define: + for (name, value) in cmd.define: self.define_macro(name, value) if allow('undef'): for macro in cmd.undef: @@ -256,16 +256,16 @@ def _compiler_to_string(compiler): props = [] mx = 0 keys = list(compiler.executables.keys()) - for key in ['version','libraries','library_dirs', - 'object_switch','compile_switch', - 'include_dirs','define','undef','rpath','link_objects']: + for key in ['version', 'libraries', 'library_dirs', + 'object_switch', 'compile_switch', + 'include_dirs', 'define', 'undef', 'rpath', 'link_objects']: if key not in keys: keys.append(key) for key in keys: - if hasattr(compiler,key): + if hasattr(compiler, key): v = getattr(compiler, key) - mx = max(mx,len(key)) - props.append((key,repr(v))) + mx = max(mx, len(key)) + props.append((key, repr(v))) lines = [] format = '%-' + repr(mx+1) + 's = %s' for prop in props: @@ -290,13 +290,13 @@ def CCompiler_show_customization(self): """ if 0: - for attrname in ['include_dirs','define','undef', - 'libraries','library_dirs', - 'rpath','link_objects']: - attr = getattr(self,attrname,None) + for attrname in ['include_dirs', 'define', 'undef', + 'libraries', 'library_dirs', + 'rpath', 'link_objects']: + attr = getattr(self, attrname, None) if not attr: continue - log.info("compiler '%s' is set to %s" % (attrname,attr)) + log.info("compiler '%s' is set to %s" % (attrname, attr)) try: self.get_version() except: @@ -351,16 +351,16 @@ def CCompiler_customize(self, dist, need_cxx=0): except (AttributeError, ValueError): pass - if hasattr(self,'compiler') and 'cc' in self.compiler[0]: + if hasattr(self, 'compiler') and 'cc' in self.compiler[0]: if not self.compiler_cxx: if self.compiler[0].startswith('gcc'): a, b = 'gcc', 'g++' else: a, b = 'cc', 'c++' - self.compiler_cxx = [self.compiler[0].replace(a,b)]\ + self.compiler_cxx = [self.compiler[0].replace(a, b)]\ + self.compiler[1:] else: - if hasattr(self,'compiler'): + if hasattr(self, 'compiler'): log.warn("#### %s #######" % (self.compiler,)) log.warn('Missing compiler_cxx fix for '+self.__class__.__name__) return @@ -396,7 +396,7 @@ def simple_version_match(pat=r'[-.\d]+', ignore='', start=''): def matcher(self, version_string): # version string may appear in the second line, so getting rid # of new lines: - version_string = version_string.replace('\n',' ') + version_string = version_string.replace('\n', ' ') pos = 0 if start: m = re.match(start, version_string) @@ -434,7 +434,7 @@ def CCompiler_get_version(self, force=False, ok_status=[0]): Version string, in the format of `distutils.version.LooseVersion`. """ - if not force and hasattr(self,'version'): + if not force and hasattr(self, 'version'): return self.version self.find_executables() try: @@ -457,7 +457,7 @@ def CCompiler_get_version(self, force=False, ok_status=[0]): version = m.group('version') return version - status, output = exec_command(version_cmd,use_tee=0) + status, output = exec_command(version_cmd, use_tee=0) version = None if status in ok_status: @@ -496,18 +496,18 @@ def CCompiler_cxx_compiler(self): replace_method(CCompiler, 'cxx_compiler', CCompiler_cxx_compiler) -compiler_class['intel'] = ('intelccompiler','IntelCCompiler', +compiler_class['intel'] = ('intelccompiler', 'IntelCCompiler', "Intel C Compiler for 32-bit applications") -compiler_class['intele'] = ('intelccompiler','IntelItaniumCCompiler', +compiler_class['intele'] = ('intelccompiler', 'IntelItaniumCCompiler', "Intel C Itanium Compiler for Itanium-based applications") -compiler_class['intelem'] = ('intelccompiler','IntelEM64TCCompiler', +compiler_class['intelem'] = ('intelccompiler', 'IntelEM64TCCompiler', "Intel C Compiler for 64-bit applications") -compiler_class['pathcc'] = ('pathccompiler','PathScaleCCompiler', +compiler_class['pathcc'] = ('pathccompiler', 'PathScaleCCompiler', "PathScale Compiler for SiCortex-based applications") -ccompiler._default_compilers += (('linux.*','intel'), - ('linux.*','intele'), - ('linux.*','intelem'), - ('linux.*','pathcc')) +ccompiler._default_compilers += (('linux.*', 'intel'), + ('linux.*', 'intele'), + ('linux.*', 'intelem'), + ('linux.*', 'pathcc')) if sys.platform == 'win32': compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler', diff --git a/numpy/distutils/command/__init__.py b/numpy/distutils/command/__init__.py index 94a7185bb..76a260072 100644 --- a/numpy/distutils/command/__init__.py +++ b/numpy/distutils/command/__init__.py @@ -24,7 +24,7 @@ distutils_all = [ #'build_py', 'bdist_wininst', ] -__import__('distutils.command',globals(),locals(),distutils_all) +__import__('distutils.command', globals(), locals(), distutils_all) __all__ = ['build', 'config_compiler', diff --git a/numpy/distutils/command/bdist_rpm.py b/numpy/distutils/command/bdist_rpm.py index e24072ff4..3e52a503b 100644 --- a/numpy/distutils/command/bdist_rpm.py +++ b/numpy/distutils/command/bdist_rpm.py @@ -19,6 +19,6 @@ class bdist_rpm(old_bdist_rpm): return spec_file new_spec_file = [] for line in spec_file: - line = line.replace('setup.py',setup_py) + line = line.replace('setup.py', setup_py) new_spec_file.append(line) return new_spec_file diff --git a/numpy/distutils/command/build.py b/numpy/distutils/command/build.py index 0577738bf..b6912be15 100644 --- a/numpy/distutils/command/build.py +++ b/numpy/distutils/command/build.py @@ -19,7 +19,7 @@ class build(old_build): ] help_options = old_build.help_options + [ - ('help-fcompiler',None, "list available Fortran compilers", + ('help-fcompiler', None, "list available Fortran compilers", show_fortran_compilers), ] diff --git a/numpy/distutils/command/build_clib.py b/numpy/distutils/command/build_clib.py index ab40a71ea..84ca87250 100644 --- a/numpy/distutils/command/build_clib.py +++ b/numpy/distutils/command/build_clib.py @@ -42,13 +42,13 @@ class build_clib(old_build_clib): def have_f_sources(self): for (lib_name, build_info) in self.libraries: - if has_f_sources(build_info.get('sources',[])): + if has_f_sources(build_info.get('sources', [])): return True return False def have_cxx_sources(self): for (lib_name, build_info) in self.libraries: - if has_cxx_sources(build_info.get('sources',[])): + if has_cxx_sources(build_info.get('sources', [])): return True return False @@ -63,7 +63,7 @@ class build_clib(old_build_clib): self.run_command('build_src') for (lib_name, build_info) in self.libraries: - l = build_info.get('language',None) + l = build_info.get('language', None) if l and l not in languages: languages.append(l) from distutils.ccompiler import new_compiler @@ -136,7 +136,7 @@ class build_clib(old_build_clib): c_sources, cxx_sources, f_sources, fmodule_sources \ = filter_sources(sources) requiref90 = not not fmodule_sources or \ - build_info.get('language','c')=='f90' + build_info.get('language', 'c')=='f90' # save source type information so that build_ext can use it. source_languages = [] @@ -148,14 +148,14 @@ class build_clib(old_build_clib): lib_file = compiler.library_filename(lib_name, output_dir=self.build_clib) - depends = sources + build_info.get('depends',[]) + depends = sources + build_info.get('depends', []) if not (self.force or newer_group(depends, lib_file, 'newer')): log.debug("skipping '%s' library (up-to-date)", lib_name) return else: log.info("building '%s' library", lib_name) - config_fc = build_info.get('config_fc',{}) + config_fc = build_info.get('config_fc', {}) if fcompiler is not None and config_fc: log.info('using additional config_fc from setup script '\ 'for fortran compiler: %s' \ @@ -229,7 +229,7 @@ class build_clib(old_build_clib): if fcompiler.module_dir_switch is None: existing_modules = glob('*.mod') extra_postargs += fcompiler.module_options(\ - module_dirs,module_build_dir) + module_dirs, module_build_dir) if fmodule_sources: log.info("compiling Fortran 90 module sources") @@ -276,9 +276,9 @@ class build_clib(old_build_clib): debug=self.debug) # fix library dependencies - clib_libraries = build_info.get('libraries',[]) + clib_libraries = build_info.get('libraries', []) for lname, binfo in libraries: if lname in clib_libraries: - clib_libraries.extend(binfo[1].get('libraries',[])) + clib_libraries.extend(binfo[1].get('libraries', [])) if clib_libraries: build_info['libraries'] = clib_libraries diff --git a/numpy/distutils/command/build_ext.py b/numpy/distutils/command/build_ext.py index 97bfa1613..b48e4227a 100644 --- a/numpy/distutils/command/build_ext.py +++ b/numpy/distutils/command/build_ext.py @@ -37,7 +37,7 @@ class build_ext (old_build_ext): ] help_options = old_build_ext.help_options + [ - ('help-fcompiler',None, "list available Fortran compilers", + ('help-fcompiler', None, "list available Fortran compilers", show_fortran_compilers), ] @@ -99,14 +99,14 @@ class build_ext (old_build_ext): # Create mapping of libraries built by build_clib: clibs = {} if build_clib is not None: - for libname,build_info in build_clib.libraries or []: + for libname, build_info in build_clib.libraries or []: if libname in clibs and clibs[libname] != build_info: log.warn('library %r defined more than once,'\ ' overwriting build_info\n%s... \nwith\n%s...' \ % (libname, repr(clibs[libname])[:300], repr(build_info)[:300])) clibs[libname] = build_info # .. and distribution libraries: - for libname,build_info in self.distribution.libraries or []: + for libname, build_info in self.distribution.libraries or []: if libname in clibs: # build_clib libraries have a precedence before distribution ones continue @@ -123,13 +123,13 @@ class build_ext (old_build_ext): for libname in ext.libraries: if libname in clibs: binfo = clibs[libname] - c_libs += binfo.get('libraries',[]) - c_lib_dirs += binfo.get('library_dirs',[]) - for m in binfo.get('macros',[]): + c_libs += binfo.get('libraries', []) + c_lib_dirs += binfo.get('library_dirs', []) + for m in binfo.get('macros', []): if m not in macros: macros.append(m) - for l in clibs.get(libname,{}).get('source_languages',[]): + for l in clibs.get(libname, {}).get('source_languages', []): ext_languages.add(l) if c_libs: new_c_libs = ext.libraries + c_libs @@ -161,7 +161,7 @@ class build_ext (old_build_ext): ext_language = 'c' # default if l and l != ext_language and ext.language: log.warn('resetting extension %r language from %r to %r.' % - (ext.name,l,ext_language)) + (ext.name, l, ext_language)) ext.language = ext_language # global language all_languages.update(ext_languages) @@ -177,7 +177,7 @@ class build_ext (old_build_ext): dry_run=self.dry_run, force=self.force) compiler = self._cxx_compiler - compiler.customize(self.distribution,need_cxx=need_cxx_compiler) + compiler.customize(self.distribution, need_cxx=need_cxx_compiler) compiler.customize_cmd(self) compiler.show_customization() self._cxx_compiler = compiler.cxx_compiler() @@ -297,8 +297,8 @@ class build_ext (old_build_ext): else: # in case ext.language is c++, for instance fcompiler = self._f90_compiler or self._f77_compiler if fcompiler is not None: - fcompiler.extra_f77_compile_args = (ext.extra_f77_compile_args or []) if hasattr(ext,'extra_f77_compile_args') else [] - fcompiler.extra_f90_compile_args = (ext.extra_f90_compile_args or []) if hasattr(ext,'extra_f90_compile_args') else [] + fcompiler.extra_f77_compile_args = (ext.extra_f77_compile_args or []) if hasattr(ext, 'extra_f77_compile_args') else [] + fcompiler.extra_f90_compile_args = (ext.extra_f90_compile_args or []) if hasattr(ext, 'extra_f90_compile_args') else [] cxx_compiler = self._cxx_compiler # check for the availability of required compilers @@ -308,7 +308,7 @@ class build_ext (old_build_ext): if (f_sources or fmodule_sources) and fcompiler is None: raise DistutilsError("extension %r has Fortran sources " \ "but no Fortran compiler found" % (ext.name)) - if ext.language in ['f77','f90'] and fcompiler is None: + if ext.language in ['f77', 'f90'] and fcompiler is None: self.warn("extension %r has Fortran libraries " \ "but no Fortran linker found, using default linker" % (ext.name)) if ext.language=='c++' and cxx_compiler is None: @@ -347,14 +347,14 @@ class build_ext (old_build_ext): log.info("compiling Fortran 90 module sources") module_dirs = ext.module_dirs[:] module_build_dir = os.path.join( - self.build_temp,os.path.dirname( + self.build_temp, os.path.dirname( self.get_ext_filename(fullname))) self.mkpath(module_build_dir) if fcompiler.module_dir_switch is None: existing_modules = glob('*.mod') extra_postargs += fcompiler.module_options( - module_dirs,module_build_dir) + module_dirs, module_build_dir) f_objects += fcompiler.compile(fmodule_sources, output_dir=self.build_temp, macros=macros, @@ -402,7 +402,7 @@ class build_ext (old_build_ext): # not using fcompiler linker self._libs_with_msvc_and_fortran(fcompiler, libraries, library_dirs) - elif ext.language in ['f77','f90'] and fcompiler is not None: + elif ext.language in ['f77', 'f90'] and fcompiler is not None: linker = fcompiler.link_shared_object if ext.language=='c++' and cxx_compiler is not None: linker = cxx_compiler.link_shared_object @@ -437,7 +437,7 @@ class build_ext (old_build_ext): if libname.startswith('msvc'): continue fileexists = False for libdir in c_library_dirs or []: - libfile = os.path.join(libdir,'%s.lib' % (libname)) + libfile = os.path.join(libdir, '%s.lib' % (libname)) if os.path.isfile(libfile): fileexists = True break @@ -445,7 +445,7 @@ class build_ext (old_build_ext): # make g77-compiled static libs available to MSVC fileexists = False for libdir in c_library_dirs: - libfile = os.path.join(libdir,'lib%s.a' % (libname)) + 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 @@ -465,7 +465,7 @@ class build_ext (old_build_ext): # correct path when compiling in Cygwin but with normal Win # Python if dir.startswith('/usr/lib'): - s,o = exec_command(['cygpath', '-w', dir], use_tee=False) + s, o = exec_command(['cygpath', '-w', dir], use_tee=False) if not s: dir = o f_lib_dirs.append(dir) diff --git a/numpy/distutils/command/build_py.py b/numpy/distutils/command/build_py.py index c25fa227d..54dcde435 100644 --- a/numpy/distutils/command/build_py.py +++ b/numpy/distutils/command/build_py.py @@ -16,7 +16,7 @@ class build_py(old_build_py): # Find build_src generated *.py files. build_src = self.get_finalized_command('build_src') - modules += build_src.py_modules_dict.get(package,[]) + modules += build_src.py_modules_dict.get(package, []) return modules diff --git a/numpy/distutils/command/build_src.py b/numpy/distutils/command/build_src.py index 2a33e5175..7463a0e17 100644 --- a/numpy/distutils/command/build_src.py +++ b/numpy/distutils/command/build_src.py @@ -66,7 +66,7 @@ class build_src(build_ext.build_ext): "directory alongside your pure Python modules"), ] - boolean_options = ['force','inplace'] + boolean_options = ['force', 'inplace'] help_options = [] @@ -136,14 +136,14 @@ class build_src(build_ext.build_ext): self.inplace = build_ext.inplace if self.swig_cpp is None: self.swig_cpp = build_ext.swig_cpp - for c in ['swig','swig_opt']: - o = '--'+c.replace('_','-') - v = getattr(build_ext,c,None) + for c in ['swig', 'swig_opt']: + o = '--'+c.replace('_', '-') + v = getattr(build_ext, c, None) if v: - if getattr(self,c): + if getattr(self, c): log.warn('both build_src and build_ext define %s option' % (o)) else: - log.info('using "%s=%s" option from build_ext command' % (o,v)) + log.info('using "%s=%s" option from build_ext command' % (o, v)) setattr(self, c, v) def run(self): @@ -179,14 +179,14 @@ class build_src(build_ext.build_ext): from numpy.distutils.misc_util import get_data_files new_data_files = [] for data in self.data_files: - if isinstance(data,str): + if isinstance(data, str): new_data_files.append(data) - elif isinstance(data,tuple): - d,files = data + elif isinstance(data, tuple): + d, files = data if self.inplace: build_dir = self.get_package_dir('.'.join(d.split(os.sep))) else: - build_dir = os.path.join(self.build_src,d) + build_dir = os.path.join(self.build_src, d) funcs = [f for f in files if hasattr(f, '__call__')] files = [f for f in files if not hasattr(f, '__call__')] for f in funcs: @@ -195,13 +195,13 @@ class build_src(build_ext.build_ext): else: s = f() if s is not None: - if isinstance(s,list): + if isinstance(s, list): files.extend(s) - elif isinstance(s,str): + elif isinstance(s, str): files.append(s) else: raise TypeError(repr(s)) - filenames = get_data_files((d,files)) + filenames = get_data_files((d, files)) new_data_files.append((d, filenames)) else: raise TypeError(repr(data)) @@ -289,7 +289,7 @@ class build_src(build_ext.build_ext): self.py_modules[:] = new_py_modules def build_library_sources(self, lib_name, build_info): - sources = list(build_info.get('sources',[])) + sources = list(build_info.get('sources', [])) if not sources: return @@ -396,10 +396,10 @@ class build_src(build_ext.build_ext): return new_sources def filter_py_files(self, sources): - return self.filter_files(sources,['.py']) + return self.filter_files(sources, ['.py']) def filter_h_files(self, sources): - return self.filter_files(sources,['.h','.hpp','.inc']) + return self.filter_files(sources, ['.h', '.hpp', '.inc']) def filter_files(self, sources, exts = []): new_sources = [] @@ -428,7 +428,7 @@ class build_src(build_ext.build_ext): else: target_dir = appendpath(self.build_src, os.path.dirname(base)) self.mkpath(target_dir) - target_file = os.path.join(target_dir,os.path.basename(base)) + target_file = os.path.join(target_dir, os.path.basename(base)) if (self.force or newer_group([source] + depends, target_file)): if _f_pyf_ext_match(base): log.info("from_template:> %s" % (target_file)) @@ -436,7 +436,7 @@ class build_src(build_ext.build_ext): else: log.info("conv_template:> %s" % (target_file)) outstr = process_c_file(source) - fid = open(target_file,'w') + fid = open(target_file, 'w') fid.write(outstr) fid.close() if _header_ext_match(target_file): @@ -515,20 +515,20 @@ class build_src(build_ext.build_ext): raise DistutilsSetupError('mismatch of extension names: %s ' 'provides %r but expected %r' % ( source, name, ext_name)) - target_file = os.path.join(target_dir,name+'module.c') + target_file = os.path.join(target_dir, name+'module.c') else: log.debug(' source %s does not exist: skipping f2py\'ing.' \ % (source)) name = ext_name skip_f2py = 1 - target_file = os.path.join(target_dir,name+'module.c') + target_file = os.path.join(target_dir, name+'module.c') if not os.path.isfile(target_file): log.warn(' target %s does not exist:\n '\ 'Assuming %smodule.c was generated with '\ '"build_src --inplace" command.' \ % (target_file, name)) target_dir = os.path.dirname(base) - target_file = os.path.join(target_dir,name+'module.c') + target_file = os.path.join(target_dir, name+'module.c') if not os.path.isfile(target_file): raise DistutilsSetupError("%r missing" % (target_file,)) log.info(' Yes! Using %r as up-to-date target.' \ @@ -551,9 +551,9 @@ class build_src(build_ext.build_ext): f2py_options = extension.f2py_options + self.f2py_opts if self.distribution.libraries: - for name,build_info in self.distribution.libraries: + for name, build_info in self.distribution.libraries: if name in extension.libraries: - f2py_options.extend(build_info.get('f2py_options',[])) + f2py_options.extend(build_info.get('f2py_options', [])) log.info("f2py options: %s" % (f2py_options)) @@ -566,12 +566,12 @@ class build_src(build_ext.build_ext): target_file = f2py_targets[source] target_dir = os.path.dirname(target_file) or '.' depends = [source] + extension.depends - if (self.force or newer_group(depends, target_file,'newer')) \ + if (self.force or newer_group(depends, target_file, 'newer')) \ and not skip_f2py: log.info("f2py: %s" % (source)) import numpy.f2py numpy.f2py.run_main(f2py_options - + ['--build-dir',target_dir,source]) + + ['--build-dir', target_dir, source]) else: log.debug(" skipping '%s' f2py interface (up-to-date)" % (source)) else: @@ -581,7 +581,7 @@ class build_src(build_ext.build_ext): else: name = extension.name target_dir = os.path.join(*([self.build_src]\ +name.split('.')[:-1])) - target_file = os.path.join(target_dir,ext_name + 'module.c') + target_file = os.path.join(target_dir, ext_name + 'module.c') new_sources.append(target_file) depends = f_sources + extension.depends if (self.force or newer_group(depends, target_file, 'newer')) \ @@ -590,8 +590,8 @@ class build_src(build_ext.build_ext): self.mkpath(target_dir) import numpy.f2py numpy.f2py.run_main(f2py_options + ['--lower', - '--build-dir',target_dir]+\ - ['-m',ext_name]+f_sources) + '--build-dir', target_dir]+\ + ['-m', ext_name]+f_sources) else: log.debug(" skipping f2py fortran files for '%s' (up-to-date)"\ % (target_file)) @@ -599,8 +599,8 @@ class build_src(build_ext.build_ext): if not os.path.isfile(target_file): raise DistutilsError("f2py target file %r not generated" % (target_file,)) - target_c = os.path.join(self.build_src,'fortranobject.c') - target_h = os.path.join(self.build_src,'fortranobject.h') + target_c = os.path.join(self.build_src, 'fortranobject.c') + target_h = os.path.join(self.build_src, 'fortranobject.h') log.info(" adding '%s' to sources." % (target_c)) new_sources.append(target_c) if self.build_src not in extension.include_dirs: @@ -611,20 +611,20 @@ class build_src(build_ext.build_ext): if not skip_f2py: import numpy.f2py d = os.path.dirname(numpy.f2py.__file__) - source_c = os.path.join(d,'src','fortranobject.c') - source_h = os.path.join(d,'src','fortranobject.h') - if newer(source_c,target_c) or newer(source_h,target_h): + source_c = os.path.join(d, 'src', 'fortranobject.c') + source_h = os.path.join(d, 'src', 'fortranobject.h') + if newer(source_c, target_c) or newer(source_h, target_h): self.mkpath(os.path.dirname(target_c)) - self.copy_file(source_c,target_c) - self.copy_file(source_h,target_h) + self.copy_file(source_c, target_c) + self.copy_file(source_h, target_h) else: if not os.path.isfile(target_c): raise DistutilsSetupError("f2py target_c file %r not found" % (target_c,)) if not os.path.isfile(target_h): raise DistutilsSetupError("f2py target_h file %r not found" % (target_h,)) - for name_ext in ['-f2pywrappers.f','-f2pywrappers2.f90']: - filename = os.path.join(target_dir,ext_name + name_ext) + for name_ext in ['-f2pywrappers.f', '-f2pywrappers2.f90']: + filename = os.path.join(target_dir, ext_name + name_ext) if os.path.isfile(filename): log.info(" adding '%s' to sources." % (filename)) f_sources.append(filename) @@ -689,7 +689,7 @@ class build_src(build_ext.build_ext): log.warn('assuming that %r has c++ swig target' % (source)) if is_cpp: target_ext = '.cpp' - target_file = os.path.join(target_dir,'%s_wrap%s' \ + target_file = os.path.join(target_dir, '%s_wrap%s' \ % (name, target_ext)) else: log.warn(' source %s does not exist: skipping swig\'ing.' \ @@ -745,17 +745,17 @@ class build_src(build_ext.build_ext): return new_sources + py_files -_f_pyf_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f|pyf)\Z',re.I).match -_header_ext_match = re.compile(r'.*[.](inc|h|hpp)\Z',re.I).match +_f_pyf_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f|pyf)\Z', re.I).match +_header_ext_match = re.compile(r'.*[.](inc|h|hpp)\Z', re.I).match #### SWIG related auxiliary functions #### _swig_module_name_match = re.compile(r'\s*%module\s*(.*\(\s*package\s*=\s*"(?P<package>[\w_]+)".*\)|)\s*(?P<name>[\w_]+)', re.I).match -_has_c_header = re.compile(r'-[*]-\s*c\s*-[*]-',re.I).search -_has_cpp_header = re.compile(r'-[*]-\s*c[+][+]\s*-[*]-',re.I).search +_has_c_header = re.compile(r'-[*]-\s*c\s*-[*]-', re.I).search +_has_cpp_header = re.compile(r'-[*]-\s*c[+][+]\s*-[*]-', re.I).search def get_swig_target(source): - f = open(source,'r') + f = open(source, 'r') result = None line = f.readline() if _has_cpp_header(line): @@ -766,7 +766,7 @@ def get_swig_target(source): return result def get_swig_modulename(source): - f = open(source,'r') + f = open(source, 'r') name = None for line in f: m = _swig_module_name_match(line) @@ -776,9 +776,9 @@ def get_swig_modulename(source): f.close() return name -def _find_swig_target(target_dir,name): - for ext in ['.cpp','.c']: - target = os.path.join(target_dir,'%s_wrap%s' % (name, ext)) +def _find_swig_target(target_dir, name): + for ext in ['.cpp', '.c']: + target = os.path.join(target_dir, '%s_wrap%s' % (name, ext)) if os.path.isfile(target): break return target @@ -788,7 +788,7 @@ def _find_swig_target(target_dir,name): _f2py_module_name_match = re.compile(r'\s*python\s*module\s*(?P<name>[\w_]+)', re.I).match _f2py_user_module_name_match = re.compile(r'\s*python\s*module\s*(?P<name>[\w_]*?'\ - '__user__[\w_]*)',re.I).match + '__user__[\w_]*)', re.I).match def get_f2py_modulename(source): name = None diff --git a/numpy/distutils/command/config.py b/numpy/distutils/command/config.py index 3434dffee..5d363eb4e 100644 --- a/numpy/distutils/command/config.py +++ b/numpy/distutils/command/config.py @@ -80,15 +80,15 @@ class was %s self.fcompiler.customize_cmd(self) self.fcompiler.show_customization() - def _wrap_method(self,mth,lang,args): + 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']: + if lang in ['f77', 'f90']: self.compiler = self.fcompiler try: ret = mth(*((self,)+args)) - except (DistutilsExecError,CompileError): + except (DistutilsExecError, CompileError): msg = str(get_exception()) self.compiler = save_compiler raise CompileError @@ -96,7 +96,7 @@ class was %s return ret def _compile (self, body, headers, include_dirs, lang): - return self._wrap_method(old_config._compile,lang, + return self._wrap_method(old_config._compile, lang, (body, headers, include_dirs, lang)) def _link (self, body, @@ -105,14 +105,14 @@ class was %s if self.compiler.compiler_type=='msvc': libraries = (libraries or [])[:] library_dirs = (library_dirs or [])[:] - if lang in ['f77','f90']: + 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], + s, o = exec_command(['cygpath', '-w', d], use_tee=False) if not s: d = o library_dirs.append(d) @@ -123,7 +123,7 @@ class was %s if libname.startswith('msvc'): continue fileexists = False for libdir in library_dirs or []: - libfile = os.path.join(libdir,'%s.lib' % (libname)) + libfile = os.path.join(libdir, '%s.lib' % (libname)) if os.path.isfile(libfile): fileexists = True break @@ -131,11 +131,11 @@ class was %s # make g77-compiled static libs available to MSVC fileexists = False for libdir in library_dirs: - libfile = os.path.join(libdir,'lib%s.a' % (libname)) + 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)) + libfile2 = os.path.join(libdir, '%s.lib' % (libname)) copy_file(libfile, libfile2) self.temp_files.append(libfile2) fileexists = True @@ -145,7 +145,7 @@ class was %s % (libname, library_dirs)) elif self.compiler.compiler_type == 'mingw32': generate_manifest(self) - return self._wrap_method(old_config._link,lang, + return self._wrap_method(old_config._link, lang, (body, headers, include_dirs, libraries, library_dirs, lang)) diff --git a/numpy/distutils/command/config_compiler.py b/numpy/distutils/command/config_compiler.py index bf776dd02..5e638fecc 100644 --- a/numpy/distutils/command/config_compiler.py +++ b/numpy/distutils/command/config_compiler.py @@ -24,24 +24,24 @@ class config_fc(Command): description = "specify Fortran 77/Fortran 90 compiler information" user_options = [ - ('fcompiler=',None,"specify Fortran compiler type"), + ('fcompiler=', None, "specify Fortran compiler type"), ('f77exec=', None, "specify F77 compiler command"), ('f90exec=', None, "specify F90 compiler command"), - ('f77flags=',None,"specify F77 compiler flags"), - ('f90flags=',None,"specify F90 compiler flags"), - ('opt=',None,"specify optimization flags"), - ('arch=',None,"specify architecture specific optimization flags"), - ('debug','g',"compile with debugging information"), - ('noopt',None,"compile without optimization"), - ('noarch',None,"compile without arch-dependent optimization"), + ('f77flags=', None, "specify F77 compiler flags"), + ('f90flags=', None, "specify F90 compiler flags"), + ('opt=', None, "specify optimization flags"), + ('arch=', None, "specify architecture specific optimization flags"), + ('debug', 'g', "compile with debugging information"), + ('noopt', None, "compile without optimization"), + ('noarch', None, "compile without arch-dependent optimization"), ] help_options = [ - ('help-fcompiler',None, "list available Fortran compilers", + ('help-fcompiler', None, "list available Fortran compilers", show_fortran_compilers), ] - boolean_options = ['debug','noopt','noarch'] + boolean_options = ['debug', 'noopt', 'noarch'] def initialize_options(self): self.fcompiler = None @@ -65,7 +65,7 @@ class config_fc(Command): for a in ['fcompiler']: l = [] for c in cmd_list: - v = getattr(c,a) + v = getattr(c, a) if v is not None: if not isinstance(v, str): v = v.compiler_type if v not in l: l.append(v) @@ -76,7 +76,7 @@ class config_fc(Command): ', using first in list as default' % (a, l)) if v1: for c in cmd_list: - if getattr(c,a) is None: setattr(c, a, v1) + if getattr(c, a) is None: setattr(c, a, v1) def run(self): # Do nothing. @@ -90,7 +90,7 @@ class config_cc(Command): description = "specify C/C++ compiler information" user_options = [ - ('compiler=',None,"specify C/C++ compiler type"), + ('compiler=', None, "specify C/C++ compiler type"), ] def initialize_options(self): @@ -106,7 +106,7 @@ class config_cc(Command): for a in ['compiler']: l = [] for c in cmd_list: - v = getattr(c,a) + v = getattr(c, a) if v is not None: if not isinstance(v, str): v = v.compiler_type if v not in l: l.append(v) @@ -117,7 +117,7 @@ class config_cc(Command): ', using first in list as default' % (a, l)) if v1: for c in cmd_list: - if getattr(c,a) is None: setattr(c, a, v1) + if getattr(c, a) is None: setattr(c, a, v1) return def run(self): diff --git a/numpy/distutils/command/install.py b/numpy/distutils/command/install.py index 9dd8dede9..2da21542f 100644 --- a/numpy/distutils/command/install.py +++ b/numpy/distutils/command/install.py @@ -41,7 +41,7 @@ class install(old_install): # work. # caller = sys._getframe(3) - caller_module = caller.f_globals.get('__name__','') + caller_module = caller.f_globals.get('__name__', '') caller_name = caller.f_code.co_name if caller_module != 'distutils.dist' or caller_name!='run_commands': @@ -61,7 +61,7 @@ class install(old_install): # bdist_rpm fails when INSTALLED_FILES contains # paths with spaces. Such paths must be enclosed # with double-quotes. - f = open(self.record,'r') + f = open(self.record, 'r') lines = [] need_rewrite = False for l in f: diff --git a/numpy/distutils/command/install_headers.py b/numpy/distutils/command/install_headers.py index 84eb5f6da..f3f58aa28 100644 --- a/numpy/distutils/command/install_headers.py +++ b/numpy/distutils/command/install_headers.py @@ -12,7 +12,7 @@ class install_headers (old_install_headers): prefix = os.path.dirname(self.install_dir) for header in headers: - if isinstance(header,tuple): + if isinstance(header, tuple): # Kind of a hack, but I don't know where else to change this... if header[0] == 'numpy.core': header = ('numpy', header[1]) diff --git a/numpy/distutils/command/sdist.py b/numpy/distutils/command/sdist.py index 7d8cc7826..bfaab1c8f 100644 --- a/numpy/distutils/command/sdist.py +++ b/numpy/distutils/command/sdist.py @@ -22,7 +22,7 @@ class sdist(old_sdist): if dist.has_headers(): headers = [] for h in dist.headers: - if isinstance(h,str): headers.append(h) + if isinstance(h, str): headers.append(h) else: headers.append(h[1]) self.filelist.extend(headers) diff --git a/numpy/distutils/conv_template.py b/numpy/distutils/conv_template.py index 3f2e1297d..a67fe4e51 100644 --- a/numpy/distutils/conv_template.py +++ b/numpy/distutils/conv_template.py @@ -124,10 +124,10 @@ def parse_structure(astr, level): start = astr.find(loopbeg, ind) if start == -1: break - start2 = astr.find("*/",start) - start2 = astr.find("\n",start2) - fini1 = astr.find(loopend,start2) - fini2 = astr.find("\n",fini1) + start2 = astr.find("*/", start) + start2 = astr.find("\n", start2) + fini1 = astr.find(loopend, start2) + fini2 = astr.find("\n", fini1) line += astr.count("\n", ind, start2+1) spanlist.append((start, start2+1, fini1, fini2+1, line)) line += astr.count("\n", start2+1, fini2) @@ -150,7 +150,7 @@ def parse_values(astr): # split at ',' and a list of values returned. astr = parenrep.sub(paren_repl, astr) # replaces occurences of xxx*3 with xxx, xxx, xxx - astr = ','.join([plainrep.sub(paren_repl,x.strip()) + astr = ','.join([plainrep.sub(paren_repl, x.strip()) for x in astr.split(',')]) return astr.split(',') @@ -188,7 +188,7 @@ def parse_loop_header(loophead) : elif nsub != size : msg = "Mismatch in number of values:\n%s = %s" % (name, vals) raise ValueError(msg) - names.append((name,vals)) + names.append((name, vals)) # Find any exclude variables @@ -208,7 +208,7 @@ def parse_loop_header(loophead) : raise ValueError("No substitution variables found") for i in range(nsub) : tmp = {} - for name,vals in names : + for name, vals in names : tmp[name] = vals[i] dlist.append(tmp) return dlist @@ -276,9 +276,9 @@ def resolve_includes(source): if m: fn = m.group('name') if not os.path.isabs(fn): - fn = os.path.join(d,fn) + fn = os.path.join(d, fn) if os.path.isfile(fn): - print('Including file',fn) + print('Including file', fn) lines.extend(resolve_includes(fn)) else: lines.append(line) @@ -289,7 +289,7 @@ def resolve_includes(source): def process_file(source): lines = resolve_includes(source) - sourcefile = os.path.normcase(source).replace("\\","\\\\") + sourcefile = os.path.normcase(source).replace("\\", "\\\\") try: code = process_str(''.join(lines)) except ValueError: @@ -323,10 +323,10 @@ if __name__ == "__main__": fid = sys.stdin outfile = sys.stdout else: - fid = open(file,'r') + fid = open(file, 'r') (base, ext) = os.path.splitext(file) newname = base - outfile = open(newname,'w') + outfile = open(newname, 'w') allstr = fid.read() try: diff --git a/numpy/distutils/core.py b/numpy/distutils/core.py index 3b5ae5630..3f0fd464a 100644 --- a/numpy/distutils/core.py +++ b/numpy/distutils/core.py @@ -55,7 +55,7 @@ if have_setuptools: numpy_cmdclass['egg_info'] = egg_info.egg_info def _dict_append(d, **kws): - for k,v in kws.items(): + for k, v in kws.items(): if k not in d: d[k] = v continue @@ -133,13 +133,13 @@ def setup(**attr): # create setup dictionary and append to new_attr config = configuration() - if hasattr(config,'todict'): + if hasattr(config, 'todict'): config = config.todict() _dict_append(new_attr, **config) # Move extension source libraries to libraries libraries = [] - for ext in new_attr.get('ext_modules',[]): + for ext in new_attr.get('ext_modules', []): new_libraries = [] for item in ext.libraries: if is_sequence(item): @@ -207,4 +207,4 @@ def _check_append_ext_library(libraries, lib_name, build_info): warnings.warn("[4] libraries list contains %r with" " no build_info" % (lib_name,)) break - libraries.append((lib_name,build_info)) + libraries.append((lib_name, build_info)) diff --git a/numpy/distutils/cpuinfo.py b/numpy/distutils/cpuinfo.py index 64ad055d3..020f2c02f 100644 --- a/numpy/distutils/cpuinfo.py +++ b/numpy/distutils/cpuinfo.py @@ -72,16 +72,16 @@ class CPUInfoBase(object): the availability of various CPU features. """ - def _try_call(self,func): + def _try_call(self, func): try: return func() except: pass - def __getattr__(self,name): + def __getattr__(self, name): if not name.startswith('_'): - if hasattr(self,'_'+name): - attr = getattr(self,'_'+name) + if hasattr(self, '_'+name): + attr = getattr(self, '_'+name) if isinstance(attr, types.MethodType): return lambda func=self._try_call,attr=attr : func(attr) else: @@ -144,10 +144,10 @@ class LinuxCPUInfo(CPUInfoBase): return self._is_AMD() and self.info[0]['model'] == '3' def _is_AthlonK6(self): - return re.match(r'.*?AMD-K6',self.info[0]['model name']) is not None + return re.match(r'.*?AMD-K6', self.info[0]['model name']) is not None def _is_AthlonK7(self): - return re.match(r'.*?AMD-K7',self.info[0]['model name']) is not None + return re.match(r'.*?AMD-K7', self.info[0]['model name']) is not None def _is_AthlonMP(self): return re.match(r'.*?Athlon\(tm\) MP\b', @@ -246,7 +246,7 @@ class LinuxCPUInfo(CPUInfoBase): and (self.info[0]['cpu family'] == '6' \ or self.info[0]['cpu family'] == '15' ) \ and (self.has_sse3() and not self.has_ssse3())\ - and re.match(r'.*?\blm\b',self.info[0]['flags']) is not None + and re.match(r'.*?\blm\b', self.info[0]['flags']) is not None def _is_Core2(self): return self.is_64bit() and self.is_Intel() and \ @@ -259,7 +259,7 @@ class LinuxCPUInfo(CPUInfoBase): def _is_XEON(self): return re.match(r'.*?XEON\b', - self.info[0]['model name'],re.IGNORECASE) is not None + self.info[0]['model name'], re.IGNORECASE) is not None _is_Xeon = _is_XEON @@ -278,25 +278,25 @@ class LinuxCPUInfo(CPUInfoBase): return self.info[0]['f00f_bug']=='yes' def _has_mmx(self): - return re.match(r'.*?\bmmx\b',self.info[0]['flags']) is not None + return re.match(r'.*?\bmmx\b', self.info[0]['flags']) is not None def _has_sse(self): - return re.match(r'.*?\bsse\b',self.info[0]['flags']) is not None + return re.match(r'.*?\bsse\b', self.info[0]['flags']) is not None def _has_sse2(self): - return re.match(r'.*?\bsse2\b',self.info[0]['flags']) is not None + return re.match(r'.*?\bsse2\b', self.info[0]['flags']) is not None def _has_sse3(self): - return re.match(r'.*?\bpni\b',self.info[0]['flags']) is not None + return re.match(r'.*?\bpni\b', self.info[0]['flags']) is not None def _has_ssse3(self): - return re.match(r'.*?\bssse3\b',self.info[0]['flags']) is not None + return re.match(r'.*?\bssse3\b', self.info[0]['flags']) is not None def _has_3dnow(self): - return re.match(r'.*?\b3dnow\b',self.info[0]['flags']) is not None + return re.match(r'.*?\b3dnow\b', self.info[0]['flags']) is not None def _has_3dnowext(self): - return re.match(r'.*?\b3dnowext\b',self.info[0]['flags']) is not None + return re.match(r'.*?\b3dnowext\b', self.info[0]['flags']) is not None class IRIXCPUInfo(CPUInfoBase): info = None @@ -305,7 +305,7 @@ class IRIXCPUInfo(CPUInfoBase): if self.info is not None: return info = key_value_from_command('sysconf', sep=' ', - successful_status=(0,1)) + successful_status=(0, 1)) self.__class__.info = info def _not_impl(self): pass @@ -316,7 +316,7 @@ class IRIXCPUInfo(CPUInfoBase): def _getNCPUs(self): return int(self.info.get('NUM_PROCESSORS', 1)) - def __cputype(self,n): + def __cputype(self, n): return self.info.get('PROCESSORS').split()[0].lower() == 'r%s' % (n) def _is_r2000(self): return self.__cputype(2000) def _is_r3000(self): return self.__cputype(3000) @@ -337,7 +337,7 @@ class IRIXCPUInfo(CPUInfoBase): def get_ip(self): try: return self.info.get('MACHINE') except: pass - def __machine(self,n): + def __machine(self, n): return self.info.get('MACHINE').lower() == 'ip%s' % (n) def _is_IP19(self): return self.__machine(19) def _is_IP20(self): return self.__machine(20) @@ -380,7 +380,7 @@ class DarwinCPUInfo(CPUInfoBase): def _is_ppc(self): return self.info['arch']=='ppc' - def __machine(self,n): + def __machine(self, n): return self.info['machine'] == 'ppc%s'%n def _is_ppc601(self): return self.__machine(601) def _is_ppc602(self): return self.__machine(602) @@ -439,35 +439,35 @@ class SunOSCPUInfo(CPUInfoBase): return self.info['arch']=='sun4' def _is_SUNW(self): - return re.match(r'SUNW',self.info['uname_i']) is not None + return re.match(r'SUNW', self.info['uname_i']) is not None def _is_sparcstation5(self): - return re.match(r'.*SPARCstation-5',self.info['uname_i']) is not None + return re.match(r'.*SPARCstation-5', self.info['uname_i']) is not None def _is_ultra1(self): - return re.match(r'.*Ultra-1',self.info['uname_i']) is not None + return re.match(r'.*Ultra-1', self.info['uname_i']) is not None def _is_ultra250(self): - return re.match(r'.*Ultra-250',self.info['uname_i']) is not None + return re.match(r'.*Ultra-250', self.info['uname_i']) is not None def _is_ultra2(self): - return re.match(r'.*Ultra-2',self.info['uname_i']) is not None + return re.match(r'.*Ultra-2', self.info['uname_i']) is not None def _is_ultra30(self): - return re.match(r'.*Ultra-30',self.info['uname_i']) is not None + return re.match(r'.*Ultra-30', self.info['uname_i']) is not None def _is_ultra4(self): - return re.match(r'.*Ultra-4',self.info['uname_i']) is not None + return re.match(r'.*Ultra-4', self.info['uname_i']) is not None def _is_ultra5_10(self): - return re.match(r'.*Ultra-5_10',self.info['uname_i']) is not None + return re.match(r'.*Ultra-5_10', self.info['uname_i']) is not None def _is_ultra5(self): - return re.match(r'.*Ultra-5',self.info['uname_i']) is not None + return re.match(r'.*Ultra-5', self.info['uname_i']) is not None def _is_ultra60(self): - return re.match(r'.*Ultra-60',self.info['uname_i']) is not None + return re.match(r'.*Ultra-60', self.info['uname_i']) is not None def _is_ultra80(self): - return re.match(r'.*Ultra-80',self.info['uname_i']) is not None + return re.match(r'.*Ultra-80', self.info['uname_i']) is not None def _is_ultraenterprice(self): - return re.match(r'.*Ultra-Enterprise',self.info['uname_i']) is not None + return re.match(r'.*Ultra-Enterprise', self.info['uname_i']) is not None def _is_ultraenterprice10k(self): - return re.match(r'.*Ultra-Enterprise-10000',self.info['uname_i']) is not None + return re.match(r'.*Ultra-Enterprise-10000', self.info['uname_i']) is not None def _is_sunfire(self): - return re.match(r'.*Sun-Fire',self.info['uname_i']) is not None + return re.match(r'.*Sun-Fire', self.info['uname_i']) is not None def _is_ultra(self): - return re.match(r'.*Ultra',self.info['uname_i']) is not None + return re.match(r'.*Ultra', self.info['uname_i']) is not None def _is_cpusparcv7(self): return self.info['processor']=='sparcv7' @@ -496,22 +496,22 @@ class Win32CPUInfo(CPUInfoBase): import _winreg as winreg prgx = re.compile(r"family\s+(?P<FML>\d+)\s+model\s+(?P<MDL>\d+)"\ - "\s+stepping\s+(?P<STP>\d+)",re.IGNORECASE) + "\s+stepping\s+(?P<STP>\d+)", re.IGNORECASE) chnd=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, self.pkey) pnum=0 while True: try: - proc=winreg.EnumKey(chnd,pnum) + proc=winreg.EnumKey(chnd, pnum) except winreg.error: break else: pnum+=1 info.append({"Processor":proc}) - phnd=winreg.OpenKey(chnd,proc) + phnd=winreg.OpenKey(chnd, proc) pidx=0 while True: try: - name,value,vtpe=winreg.EnumValue(phnd,pidx) + name, value, vtpe=winreg.EnumValue(phnd, pidx) except winreg.error: break else: @@ -524,7 +524,7 @@ class Win32CPUInfo(CPUInfoBase): info[-1]["Model"]=int(srch.group("MDL")) info[-1]["Stepping"]=int(srch.group("STP")) except: - print(sys.exc_info()[1],'(ignoring)') + print(sys.exc_info()[1], '(ignoring)') self.__class__.info = info def _not_impl(self): pass @@ -542,11 +542,11 @@ class Win32CPUInfo(CPUInfoBase): def _is_AMDK5(self): return self.is_AMD() and self.info[0]['Family']==5 \ - and self.info[0]['Model'] in [0,1,2,3] + and self.info[0]['Model'] in [0, 1, 2, 3] def _is_AMDK6(self): return self.is_AMD() and self.info[0]['Family']==5 \ - and self.info[0]['Model'] in [6,7] + and self.info[0]['Model'] in [6, 7] def _is_AMDK6_2(self): return self.is_AMD() and self.info[0]['Family']==5 \ @@ -596,11 +596,11 @@ class Win32CPUInfo(CPUInfoBase): def _is_PentiumII(self): return self.is_Intel() and self.info[0]['Family']==6 \ - and self.info[0]['Model'] in [3,5,6] + and self.info[0]['Model'] in [3, 5, 6] def _is_PentiumIII(self): return self.is_Intel() and self.info[0]['Family']==6 \ - and self.info[0]['Model'] in [7,8,9,10,11] + and self.info[0]['Model'] in [7, 8, 9, 10, 11] def _is_PentiumIV(self): return self.is_Intel() and self.info[0]['Family']==15 @@ -624,20 +624,20 @@ class Win32CPUInfo(CPUInfoBase): def _has_mmx(self): if self.is_Intel(): return (self.info[0]['Family']==5 and self.info[0]['Model']==4) \ - or (self.info[0]['Family'] in [6,15]) + or (self.info[0]['Family'] in [6, 15]) elif self.is_AMD(): - return self.info[0]['Family'] in [5,6,15] + return self.info[0]['Family'] in [5, 6, 15] else: return False def _has_sse(self): if self.is_Intel(): return (self.info[0]['Family']==6 and \ - self.info[0]['Model'] in [7,8,9,10,11]) \ + self.info[0]['Model'] in [7, 8, 9, 10, 11]) \ or self.info[0]['Family']==15 elif self.is_AMD(): return (self.info[0]['Family']==6 and \ - self.info[0]['Model'] in [6,7,8,10]) \ + self.info[0]['Model'] in [6, 7, 8, 10]) \ or self.info[0]['Family']==15 else: return False @@ -652,10 +652,10 @@ class Win32CPUInfo(CPUInfoBase): return False def _has_3dnow(self): - return self.is_AMD() and self.info[0]['Family'] in [5,6,15] + return self.is_AMD() and self.info[0]['Family'] in [5, 6, 15] def _has_3dnowext(self): - return self.is_AMD() and self.info[0]['Family'] in [6,15] + return self.is_AMD() and self.info[0]['Family'] in [6, 15] if sys.platform.startswith('linux'): # variations: linux2,linux-i386 (any others?) cpuinfo = LinuxCPUInfo diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py index 0af60ec34..648a98efb 100644 --- a/numpy/distutils/exec_command.py +++ b/numpy/distutils/exec_command.py @@ -46,7 +46,7 @@ Known bugs: """ from __future__ import division, absolute_import, print_function -__all__ = ['exec_command','find_executable'] +__all__ = ['exec_command', 'find_executable'] import os import sys @@ -65,10 +65,10 @@ def temp_file_name(): def get_pythonexe(): pythonexe = sys.executable - if os.name in ['nt','dos']: - fdir,fn = os.path.split(pythonexe) - fn = fn.upper().replace('PYTHONW','PYTHON') - pythonexe = os.path.join(fdir,fn) + if os.name in ['nt', 'dos']: + fdir, fn = os.path.split(pythonexe) + fn = fn.upper().replace('PYTHONW', 'PYTHON') + pythonexe = os.path.join(fdir, fn) assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,) return pythonexe @@ -92,7 +92,7 @@ def find_executable(exe, path=None, _cache={}): orig_exe = exe if path is None: - path = os.environ.get('PATH',os.defpath) + path = os.environ.get('PATH', os.defpath) if os.name=='posix': realpath = os.path.realpath else: @@ -102,9 +102,9 @@ def find_executable(exe, path=None, _cache={}): exe = exe[1:-1] suffixes = [''] - if os.name in ['nt','dos','os2']: - fn,ext = os.path.splitext(exe) - extra_suffixes = ['.exe','.com','.bat'] + if os.name in ['nt', 'dos', 'os2']: + fn, ext = os.path.splitext(exe) + extra_suffixes = ['.exe', '.com', '.bat'] if ext.lower() not in extra_suffixes: suffixes = extra_suffixes @@ -138,7 +138,7 @@ def _preserve_environment( names ): def _update_environment( **env ): log.debug('_update_environment(...)') - for name,value in env.items(): + for name, value in env.items(): os.environ[name] = value or '' def _supports_fileno(stream): @@ -248,11 +248,11 @@ def _exec_command_posix( command, if use_tee == 2: filter = r'| tr -cd "\n" | tr "\n" "."; echo' command_posix = '( %s ; echo $? > %s ) 2>&1 | tee %s %s'\ - % (command_str,stsfile,tmpfile,filter) + % (command_str, stsfile, tmpfile, filter) else: stsfile = temp_file_name() command_posix = '( %s ; echo $? > %s ) > %s 2>&1'\ - % (command_str,stsfile,tmpfile) + % (command_str, stsfile, tmpfile) #command_posix = '( %s ) > %s 2>&1' % (command_str,tmpfile) log.debug('Running os.system(%r)' % (command_posix)) @@ -265,13 +265,13 @@ def _exec_command_posix( command, return _exec_command(command, use_shell=use_shell, **env) if stsfile is not None: - f = open_latin1(stsfile,'r') + f = open_latin1(stsfile, 'r') status_text = f.read() status = int(status_text) f.close() os.remove(stsfile) - f = open_latin1(tmpfile,'r') + f = open_latin1(tmpfile, 'r') text = f.read() f.close() os.remove(tmpfile) @@ -291,7 +291,7 @@ def _exec_command_python(command, stsfile = temp_file_name() outfile = temp_file_name() - f = open(cmdfile,'w') + f = open(cmdfile, 'w') f.write('import os\n') f.write('import sys\n') f.write('sys.path.insert(0,%r)\n' % (exec_command_dir)) @@ -310,12 +310,12 @@ def _exec_command_python(command, raise RuntimeError("%r failed" % (cmd,)) os.remove(cmdfile) - f = open_latin1(stsfile,'r') + f = open_latin1(stsfile, 'r') status = int(f.read()) f.close() os.remove(stsfile) - f = open_latin1(outfile,'r') + f = open_latin1(outfile, 'r') text = f.read() f.close() os.remove(outfile) @@ -338,11 +338,11 @@ def _exec_command( command, use_shell=None, use_tee = None, **env ): if use_shell: # We use shell (unless use_shell==0) so that wildcards can be # used. - sh = os.environ.get('SHELL','/bin/sh') + sh = os.environ.get('SHELL', '/bin/sh') if is_sequence(command): - argv = [sh,'-c',' '.join(list(command))] + argv = [sh, '-c', ' '.join(list(command))] else: - argv = [sh,'-c',command] + argv = [sh, '-c', command] else: # On NT, DOS we avoid using command.com as it's exit status is # not related to the exit status of a command. @@ -351,16 +351,16 @@ def _exec_command( command, use_shell=None, use_tee = None, **env ): else: argv = shlex.split(command) - if hasattr(os,'spawnvpe'): + if hasattr(os, 'spawnvpe'): spawn_command = os.spawnvpe else: spawn_command = os.spawnve argv[0] = find_executable(argv[0]) or argv[0] if not os.path.isfile(argv[0]): log.warn('Executable %s does not exist' % (argv[0])) - if os.name in ['nt','dos']: + if os.name in ['nt', 'dos']: # argv[0] might be internal command - argv = [os.environ['COMSPEC'],'/C'] + argv + argv = [os.environ['COMSPEC'], '/C'] + argv using_command = 1 _so_has_fileno = _supports_fileno(sys.stdout) @@ -375,13 +375,13 @@ def _exec_command( command, use_shell=None, use_tee = None, **env ): se_dup = os.dup(se_fileno) outfile = temp_file_name() - fout = open(outfile,'w') + fout = open(outfile, 'w') if using_command: errfile = temp_file_name() - ferr = open(errfile,'w') + ferr = open(errfile, 'w') log.debug('Running %s(%s,%r,%r,os.environ)' \ - % (spawn_command.__name__,os.P_WAIT,argv[0],argv)) + % (spawn_command.__name__, os.P_WAIT, argv[0], argv)) argv0 = argv[0] if not using_command: @@ -390,38 +390,38 @@ def _exec_command( command, use_shell=None, use_tee = None, **env ): so_flush() se_flush() if _so_has_fileno: - os.dup2(fout.fileno(),so_fileno) + os.dup2(fout.fileno(), so_fileno) if _se_has_fileno: if using_command: #XXX: disabled for now as it does not work from cmd under win32. # Tests fail on msys - os.dup2(ferr.fileno(),se_fileno) + os.dup2(ferr.fileno(), se_fileno) else: - os.dup2(fout.fileno(),se_fileno) + os.dup2(fout.fileno(), se_fileno) try: - status = spawn_command(os.P_WAIT,argv0,argv,os.environ) + status = spawn_command(os.P_WAIT, argv0, argv, os.environ) except OSError: errmess = str(get_exception()) status = 999 - sys.stderr.write('%s: %s'%(errmess,argv[0])) + sys.stderr.write('%s: %s'%(errmess, argv[0])) so_flush() se_flush() if _so_has_fileno: - os.dup2(so_dup,so_fileno) + os.dup2(so_dup, so_fileno) if _se_has_fileno: - os.dup2(se_dup,se_fileno) + os.dup2(se_dup, se_fileno) fout.close() - fout = open_latin1(outfile,'r') + fout = open_latin1(outfile, 'r') text = fout.read() fout.close() os.remove(outfile) if using_command: ferr.close() - ferr = open_latin1(errfile,'r') + ferr = open_latin1(errfile, 'r') errmess = ferr.read() ferr.close() os.remove(errfile) @@ -453,120 +453,120 @@ def test_nt(**kws): if using_cygwin_echo: log.warn('Using cygwin echo in win32 environment is not supported') - s,o=exec_command(pythonexe\ + s, o=exec_command(pythonexe\ +' -c "import os;print os.environ.get(\'AAA\',\'\')"') - assert s==0 and o=='',(s,o) + assert s==0 and o=='', (s, o) - s,o=exec_command(pythonexe\ + s, o=exec_command(pythonexe\ +' -c "import os;print os.environ.get(\'AAA\')"', AAA='Tere') - assert s==0 and o=='Tere',(s,o) + assert s==0 and o=='Tere', (s, o) os.environ['BBB'] = 'Hi' - s,o=exec_command(pythonexe\ + s, o=exec_command(pythonexe\ +' -c "import os;print os.environ.get(\'BBB\',\'\')"') - assert s==0 and o=='Hi',(s,o) + assert s==0 and o=='Hi', (s, o) - s,o=exec_command(pythonexe\ + s, o=exec_command(pythonexe\ +' -c "import os;print os.environ.get(\'BBB\',\'\')"', BBB='Hey') - assert s==0 and o=='Hey',(s,o) + assert s==0 and o=='Hey', (s, o) - s,o=exec_command(pythonexe\ + s, o=exec_command(pythonexe\ +' -c "import os;print os.environ.get(\'BBB\',\'\')"') - assert s==0 and o=='Hi',(s,o) + assert s==0 and o=='Hi', (s, o) elif 0: - s,o=exec_command('echo Hello') - assert s==0 and o=='Hello',(s,o) + s, o=exec_command('echo Hello') + assert s==0 and o=='Hello', (s, o) - s,o=exec_command('echo a%AAA%') - assert s==0 and o=='a',(s,o) + s, o=exec_command('echo a%AAA%') + assert s==0 and o=='a', (s, o) - s,o=exec_command('echo a%AAA%',AAA='Tere') - assert s==0 and o=='aTere',(s,o) + s, o=exec_command('echo a%AAA%', AAA='Tere') + assert s==0 and o=='aTere', (s, o) os.environ['BBB'] = 'Hi' - s,o=exec_command('echo a%BBB%') - assert s==0 and o=='aHi',(s,o) + s, o=exec_command('echo a%BBB%') + assert s==0 and o=='aHi', (s, o) - s,o=exec_command('echo a%BBB%',BBB='Hey') - assert s==0 and o=='aHey', (s,o) - s,o=exec_command('echo a%BBB%') - assert s==0 and o=='aHi',(s,o) + s, o=exec_command('echo a%BBB%', BBB='Hey') + assert s==0 and o=='aHey', (s, o) + s, o=exec_command('echo a%BBB%') + assert s==0 and o=='aHi', (s, o) - s,o=exec_command('this_is_not_a_command') - assert s and o!='',(s,o) + s, o=exec_command('this_is_not_a_command') + assert s and o!='', (s, o) - s,o=exec_command('type not_existing_file') - assert s and o!='',(s,o) + s, o=exec_command('type not_existing_file') + assert s and o!='', (s, o) - s,o=exec_command('echo path=%path%') - assert s==0 and o!='',(s,o) + s, o=exec_command('echo path=%path%') + assert s==0 and o!='', (s, o) - s,o=exec_command('%s -c "import sys;sys.stderr.write(sys.platform)"' \ + s, o=exec_command('%s -c "import sys;sys.stderr.write(sys.platform)"' \ % pythonexe) - assert s==0 and o=='win32',(s,o) + assert s==0 and o=='win32', (s, o) - s,o=exec_command('%s -c "raise \'Ignore me.\'"' % pythonexe) - assert s==1 and o,(s,o) + s, o=exec_command('%s -c "raise \'Ignore me.\'"' % pythonexe) + assert s==1 and o, (s, o) - s,o=exec_command('%s -c "import sys;sys.stderr.write(\'0\');sys.stderr.write(\'1\');sys.stderr.write(\'2\')"'\ + s, o=exec_command('%s -c "import sys;sys.stderr.write(\'0\');sys.stderr.write(\'1\');sys.stderr.write(\'2\')"'\ % pythonexe) - assert s==0 and o=='012',(s,o) + assert s==0 and o=='012', (s, o) - s,o=exec_command('%s -c "import sys;sys.exit(15)"' % pythonexe) - assert s==15 and o=='',(s,o) + s, o=exec_command('%s -c "import sys;sys.exit(15)"' % pythonexe) + assert s==15 and o=='', (s, o) - s,o=exec_command('%s -c "print \'Heipa\'"' % pythonexe) - assert s==0 and o=='Heipa',(s,o) + s, o=exec_command('%s -c "print \'Heipa\'"' % pythonexe) + assert s==0 and o=='Heipa', (s, o) print ('ok') def test_posix(**kws): - s,o=exec_command("echo Hello",**kws) - assert s==0 and o=='Hello',(s,o) + s, o=exec_command("echo Hello",**kws) + assert s==0 and o=='Hello', (s, o) - s,o=exec_command('echo $AAA',**kws) - assert s==0 and o=='',(s,o) + s, o=exec_command('echo $AAA',**kws) + assert s==0 and o=='', (s, o) - s,o=exec_command('echo "$AAA"',AAA='Tere',**kws) - assert s==0 and o=='Tere',(s,o) + s, o=exec_command('echo "$AAA"',AAA='Tere',**kws) + assert s==0 and o=='Tere', (s, o) - s,o=exec_command('echo "$AAA"',**kws) - assert s==0 and o=='',(s,o) + s, o=exec_command('echo "$AAA"',**kws) + assert s==0 and o=='', (s, o) os.environ['BBB'] = 'Hi' - s,o=exec_command('echo "$BBB"',**kws) - assert s==0 and o=='Hi',(s,o) + s, o=exec_command('echo "$BBB"',**kws) + assert s==0 and o=='Hi', (s, o) - s,o=exec_command('echo "$BBB"',BBB='Hey',**kws) - assert s==0 and o=='Hey',(s,o) + s, o=exec_command('echo "$BBB"',BBB='Hey',**kws) + assert s==0 and o=='Hey', (s, o) - s,o=exec_command('echo "$BBB"',**kws) - assert s==0 and o=='Hi',(s,o) + s, o=exec_command('echo "$BBB"',**kws) + assert s==0 and o=='Hi', (s, o) - s,o=exec_command('this_is_not_a_command',**kws) - assert s!=0 and o!='',(s,o) + s, o=exec_command('this_is_not_a_command',**kws) + assert s!=0 and o!='', (s, o) - s,o=exec_command('echo path=$PATH',**kws) - assert s==0 and o!='',(s,o) + s, o=exec_command('echo path=$PATH',**kws) + assert s==0 and o!='', (s, o) - s,o=exec_command('python -c "import sys,os;sys.stderr.write(os.name)"',**kws) - assert s==0 and o=='posix',(s,o) + s, o=exec_command('python -c "import sys,os;sys.stderr.write(os.name)"',**kws) + assert s==0 and o=='posix', (s, o) - s,o=exec_command('python -c "raise \'Ignore me.\'"',**kws) - assert s==1 and o,(s,o) + s, o=exec_command('python -c "raise \'Ignore me.\'"',**kws) + assert s==1 and o, (s, o) - s,o=exec_command('python -c "import sys;sys.stderr.write(\'0\');sys.stderr.write(\'1\');sys.stderr.write(\'2\')"',**kws) - assert s==0 and o=='012',(s,o) + s, o=exec_command('python -c "import sys;sys.stderr.write(\'0\');sys.stderr.write(\'1\');sys.stderr.write(\'2\')"',**kws) + assert s==0 and o=='012', (s, o) - s,o=exec_command('python -c "import sys;sys.exit(15)"',**kws) - assert s==15 and o=='',(s,o) + s, o=exec_command('python -c "import sys;sys.exit(15)"',**kws) + assert s==15 and o=='', (s, o) - s,o=exec_command('python -c "print \'Heipa\'"',**kws) - assert s==0 and o=='Heipa',(s,o) + s, o=exec_command('python -c "print \'Heipa\'"',**kws) + assert s==0 and o=='Heipa', (s, o) print ('ok') @@ -575,33 +575,33 @@ def test_execute_in(**kws): tmpfile = temp_file_name() fn = os.path.basename(tmpfile) tmpdir = os.path.dirname(tmpfile) - f = open(tmpfile,'w') + f = open(tmpfile, 'w') f.write('Hello') f.close() - s,o = exec_command('%s -c "print \'Ignore the following IOError:\','\ - 'open(%r,\'r\')"' % (pythonexe,fn),**kws) - assert s and o!='',(s,o) - s,o = exec_command('%s -c "print open(%r,\'r\').read()"' % (pythonexe,fn), + s, o = exec_command('%s -c "print \'Ignore the following IOError:\','\ + 'open(%r,\'r\')"' % (pythonexe, fn),**kws) + assert s and o!='', (s, o) + s, o = exec_command('%s -c "print open(%r,\'r\').read()"' % (pythonexe, fn), execute_in = tmpdir,**kws) - assert s==0 and o=='Hello',(s,o) + assert s==0 and o=='Hello', (s, o) os.remove(tmpfile) print ('ok') def test_svn(**kws): - s,o = exec_command(['svn','status'],**kws) - assert s,(s,o) + s, o = exec_command(['svn', 'status'],**kws) + assert s, (s, o) print ('svn ok') def test_cl(**kws): if os.name=='nt': - s,o = exec_command(['cl','/V'],**kws) - assert s,(s,o) + s, o = exec_command(['cl', '/V'],**kws) + assert s, (s, o) print ('cl ok') if os.name=='posix': test = test_posix -elif os.name in ['nt','dos']: +elif os.name in ['nt', 'dos']: test = test_nt else: raise NotImplementedError('exec_command tests for ', os.name) diff --git a/numpy/distutils/extension.py b/numpy/distutils/extension.py index d0182eb14..344c66da0 100644 --- a/numpy/distutils/extension.py +++ b/numpy/distutils/extension.py @@ -16,8 +16,8 @@ if sys.version_info[0] >= 3: basestring = str -cxx_ext_re = re.compile(r'.*[.](cpp|cxx|cc)\Z',re.I).match -fortran_pyf_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f|pyf)\Z',re.I).match +cxx_ext_re = re.compile(r'.*[.](cpp|cxx|cc)\Z', re.I).match +fortran_pyf_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f|pyf)\Z', re.I).match class Extension(old_Extension): def __init__ (self, name, sources, @@ -39,7 +39,7 @@ class Extension(old_Extension): extra_f77_compile_args=None, extra_f90_compile_args=None, ): - old_Extension.__init__(self,name, [], + old_Extension.__init__(self, name, [], include_dirs, define_macros, undef_macros, diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py index 37852b0fb..d00228dcd 100644 --- a/numpy/distutils/fcompiler/__init__.py +++ b/numpy/distutils/fcompiler/__init__.py @@ -15,7 +15,7 @@ But note that FCompiler.executables is actually a dictionary of commands. """ from __future__ import division, absolute_import, print_function -__all__ = ['FCompiler','new_fcompiler','show_fcompilers', +__all__ = ['FCompiler', 'new_fcompiler', 'show_fcompilers', 'dummy_fortran_file'] import os @@ -144,16 +144,16 @@ class FCompiler(CCompiler): ar = ('flags.ar', 'ARFLAGS', 'arflags', flaglist), ) - language_map = {'.f':'f77', - '.for':'f77', - '.F':'f77', # XXX: needs preprocessor - '.ftn':'f77', - '.f77':'f77', - '.f90':'f90', - '.F90':'f90', # XXX: needs preprocessor - '.f95':'f90', + language_map = {'.f': 'f77', + '.for': 'f77', + '.F': 'f77', # XXX: needs preprocessor + '.ftn': 'f77', + '.f77': 'f77', + '.f90': 'f90', + '.F90': 'f90', # XXX: needs preprocessor + '.f95': 'f90', } - language_order = ['f90','f77'] + language_order = ['f90', 'f77'] # These will be set by the subclass @@ -164,14 +164,14 @@ class FCompiler(CCompiler): possible_executables = [] executables = { - 'version_cmd' : ["f77", "-v"], - 'compiler_f77' : ["f77"], - 'compiler_f90' : ["f90"], - 'compiler_fix' : ["f90", "-fixed"], - 'linker_so' : ["f90", "-shared"], - 'linker_exe' : ["f90"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : None, + 'version_cmd': ["f77", "-v"], + 'compiler_f77': ["f77"], + 'compiler_f90': ["f90"], + 'compiler_fix': ["f90", "-fixed"], + 'linker_so': ["f90", "-shared"], + 'linker_exe': ["f90"], + 'archiver': ["ar", "-cr"], + 'ranlib': None, } # If compiler does not support compiling Fortran 90 then it can @@ -196,7 +196,7 @@ class FCompiler(CCompiler): pic_flags = [] # Flags to create position-independent code - src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95','.F','.F90'] + src_extensions = ['.for', '.ftn', '.f77', '.f', '.f90', '.f95', '.F', '.F90'] obj_extension = ".o" shared_lib_extension = get_shared_lib_extension() @@ -543,10 +543,10 @@ class FCompiler(CCompiler): """Print out the attributes of a compiler instance.""" props = [] for key in list(self.executables.keys()) + \ - ['version','libraries','library_dirs', - 'object_switch','compile_switch']: - if hasattr(self,key): - v = getattr(self,key) + ['version', 'libraries', 'library_dirs', + 'object_switch', 'compile_switch']: + if hasattr(self, key): + v = getattr(self, key) props.append((key, None, '= '+repr(v))) props.sort() @@ -572,17 +572,17 @@ class FCompiler(CCompiler): compiler = self.compiler_f90 if compiler is None: raise DistutilsExecError('f90 not supported by %s needed for %s'\ - % (self.__class__.__name__,src)) + % (self.__class__.__name__, src)) extra_compile_args = self.extra_f90_compile_args or [] else: flavor = ':fix' compiler = self.compiler_fix if compiler is None: raise DistutilsExecError('f90 (fixed) not supported by %s needed for %s'\ - % (self.__class__.__name__,src)) + % (self.__class__.__name__, src)) extra_compile_args = self.extra_f90_compile_args or [] if self.object_switch[-1]==' ': - o_args = [self.object_switch.strip(),obj] + o_args = [self.object_switch.strip(), obj] else: o_args = [self.object_switch.strip()+obj] @@ -593,7 +593,7 @@ class FCompiler(CCompiler): log.info('extra %s options: %r' \ % (flavor[1:], ' '.join(extra_compile_args))) - extra_flags = src_flags.get(self.compiler_type,[]) + extra_flags = src_flags.get(self.compiler_type, []) if extra_flags: log.info('using compile options from source: %r' \ % ' '.join(extra_flags)) @@ -604,7 +604,7 @@ class FCompiler(CCompiler): display = '%s: %s' % (os.path.basename(compiler[0]) + flavor, src) try: - self.spawn(command,display=display) + self.spawn(command, display=display) except DistutilsExecError: msg = str(get_exception()) raise CompileError(msg) @@ -613,18 +613,18 @@ class FCompiler(CCompiler): options = [] if self.module_dir_switch is not None: if self.module_dir_switch[-1]==' ': - options.extend([self.module_dir_switch.strip(),module_build_dir]) + options.extend([self.module_dir_switch.strip(), module_build_dir]) else: options.append(self.module_dir_switch.strip()+module_build_dir) else: print('XXX: module_build_dir=%r option ignored' % (module_build_dir)) - print('XXX: Fix module_dir_switch for ',self.__class__.__name__) + print('XXX: Fix module_dir_switch for ', self.__class__.__name__) if self.module_include_switch is not None: for d in [module_build_dir]+module_dirs: options.append('%s%s' % (self.module_include_switch, d)) else: print('XXX: module_dirs=%r option ignored' % (module_dirs)) - print('XXX: Fix module_include_switch for ',self.__class__.__name__) + print('XXX: Fix module_include_switch for ', self.__class__.__name__) return options def library_option(self, lib): @@ -650,7 +650,7 @@ class FCompiler(CCompiler): if self._need_link(objects, output_filename): if self.library_switch[-1]==' ': - o_args = [self.library_switch.strip(),output_filename] + o_args = [self.library_switch.strip(), output_filename] else: o_args = [self.library_switch.strip()+output_filename] @@ -705,19 +705,19 @@ class FCompiler(CCompiler): _default_compilers = ( # sys.platform mappings - ('win32', ('gnu','intelv','absoft','compaqv','intelev','gnu95','g95', + ('win32', ('gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem')), - ('cygwin.*', ('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')), - ('linux.*', ('gnu95','intel','lahey','pg','absoft','nag','vast','compaq', - 'intele','intelem','gnu','g95','pathf95')), + ('cygwin.*', ('gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95')), + ('linux.*', ('gnu95', 'intel', 'lahey', 'pg', 'absoft', 'nag', 'vast', 'compaq', + 'intele', 'intelem', 'gnu', 'g95', 'pathf95')), ('darwin.*', ('gnu95', 'nag', 'absoft', 'ibm', 'intel', 'gnu', 'g95', 'pg')), - ('sunos.*', ('sun','gnu','gnu95','g95')), - ('irix.*', ('mips','gnu','gnu95',)), - ('aix.*', ('ibm','gnu','gnu95',)), + ('sunos.*', ('sun', 'gnu', 'gnu95', 'g95')), + ('irix.*', ('mips', 'gnu', 'gnu95',)), + ('aix.*', ('ibm', 'gnu', 'gnu95',)), # os.name mappings - ('posix', ('gnu','gnu95',)), - ('nt', ('gnu','gnu95',)), - ('mac', ('gnu95','gnu','pg')), + ('posix', ('gnu', 'gnu95',)), + ('nt', ('gnu', 'gnu95',)), + ('mac', ('gnu95', 'gnu', 'pg')), ) fcompiler_class = None @@ -925,18 +925,18 @@ def dummy_fortran_file(): return name[:-2] -is_f_file = re.compile(r'.*[.](for|ftn|f77|f)\Z',re.I).match -_has_f_header = re.compile(r'-[*]-\s*fortran\s*-[*]-',re.I).search -_has_f90_header = re.compile(r'-[*]-\s*f90\s*-[*]-',re.I).search -_has_fix_header = re.compile(r'-[*]-\s*fix\s*-[*]-',re.I).search -_free_f90_start = re.compile(r'[^c*!]\s*[^\s\d\t]',re.I).match +is_f_file = re.compile(r'.*[.](for|ftn|f77|f)\Z', re.I).match +_has_f_header = re.compile(r'-[*]-\s*fortran\s*-[*]-', re.I).search +_has_f90_header = re.compile(r'-[*]-\s*f90\s*-[*]-', re.I).search +_has_fix_header = re.compile(r'-[*]-\s*fix\s*-[*]-', re.I).search +_free_f90_start = re.compile(r'[^c*!]\s*[^\s\d\t]', re.I).match def is_free_format(file): """Check if file is in free format Fortran.""" # f90 allows both fixed and free format, assuming fixed unless # signs of free format are detected. result = 0 - f = open_latin1(file,'r') + f = open_latin1(file, 'r') line = f.readline() n = 10000 # the number of non-comment lines to scan for hints if _has_f_header(line): @@ -956,12 +956,12 @@ def is_free_format(file): return result def has_f90_header(src): - f = open_latin1(src,'r') + f = open_latin1(src, 'r') line = f.readline() f.close() return _has_f90_header(line) or _has_fix_header(line) -_f77flags_re = re.compile(r'(c|)f77flags\s*\(\s*(?P<fcname>\w+)\s*\)\s*=\s*(?P<fflags>.*)',re.I) +_f77flags_re = re.compile(r'(c|)f77flags\s*\(\s*(?P<fcname>\w+)\s*\)\s*=\s*(?P<fflags>.*)', re.I) def get_f77flags(src): """ Search the first 20 lines of fortran 77 code for line pattern @@ -969,7 +969,7 @@ def get_f77flags(src): Return a dictionary {<fcompiler type>:<f77 flags>}. """ flags = {} - f = open_latin1(src,'r') + f = open_latin1(src, 'r') i = 0 for line in f: i += 1 diff --git a/numpy/distutils/fcompiler/absoft.py b/numpy/distutils/fcompiler/absoft.py index 03430fb0e..bde0529be 100644 --- a/numpy/distutils/fcompiler/absoft.py +++ b/numpy/distutils/fcompiler/absoft.py @@ -61,12 +61,12 @@ class AbsoftFCompiler(FCompiler): elif self.get_version() >= '9.0': opt = ['-shared'] else: - opt = ["-K","shared"] + opt = ["-K", "shared"] return opt def library_dir_option(self, dir): if os.name=='nt': - return ['-link','/PATH:"%s"' % (dir)] + return ['-link', '/PATH:"%s"' % (dir)] return "-L" + dir def library_option(self, lib): @@ -97,9 +97,9 @@ class AbsoftFCompiler(FCompiler): elif self.get_version() >= '10.0': opt.extend(['af90math', 'afio', 'af77math', 'U77']) elif self.get_version() >= '8.0': - opt.extend(['f90math','fio','f77math','U77']) + opt.extend(['f90math', 'fio', 'f77math', 'U77']) else: - opt.extend(['fio','f90math','fmath','U77']) + opt.extend(['fio', 'f90math', 'fmath', 'U77']) if os.name =='nt': opt.append('COMDLG32') return opt @@ -115,11 +115,11 @@ class AbsoftFCompiler(FCompiler): def get_flags_f77(self): opt = FCompiler.get_flags_f77(self) - opt.extend(['-N22','-N90','-N110']) + opt.extend(['-N22', '-N90', '-N110']) v = self.get_version() if os.name == 'nt': if v and v>='8.0': - opt.extend(['-f','-N15']) + opt.extend(['-f', '-N15']) else: opt.append('-f') if v: @@ -133,8 +133,8 @@ class AbsoftFCompiler(FCompiler): def get_flags_f90(self): opt = FCompiler.get_flags_f90(self) - opt.extend(["-YCFRL=1","-YCOM_NAMES=LCS","-YCOM_PFX","-YEXT_PFX", - "-YCOM_SFX=_","-YEXT_SFX=_","-YEXT_NAMES=LCS"]) + opt.extend(["-YCFRL=1", "-YCOM_NAMES=LCS", "-YCOM_PFX", "-YEXT_PFX", + "-YCOM_SFX=_", "-YEXT_SFX=_", "-YEXT_NAMES=LCS"]) if self.get_version(): if self.get_version()>'4.6': opt.extend(["-YDEALLOC=ALL"]) @@ -142,9 +142,9 @@ class AbsoftFCompiler(FCompiler): def get_flags_fix(self): opt = FCompiler.get_flags_fix(self) - opt.extend(["-YCFRL=1","-YCOM_NAMES=LCS","-YCOM_PFX","-YEXT_PFX", - "-YCOM_SFX=_","-YEXT_SFX=_","-YEXT_NAMES=LCS"]) - opt.extend(["-f","fixed"]) + opt.extend(["-YCFRL=1", "-YCOM_NAMES=LCS", "-YCOM_PFX", "-YEXT_PFX", + "-YCOM_SFX=_", "-YEXT_SFX=_", "-YEXT_NAMES=LCS"]) + opt.extend(["-f", "fixed"]) return opt def get_flags_opt(self): diff --git a/numpy/distutils/fcompiler/compaq.py b/numpy/distutils/fcompiler/compaq.py index 3831f88f7..5162b168c 100644 --- a/numpy/distutils/fcompiler/compaq.py +++ b/numpy/distutils/fcompiler/compaq.py @@ -29,7 +29,7 @@ class CompaqFCompiler(FCompiler): executables = { 'version_cmd' : ['<F90>', "-version"], - 'compiler_f77' : [fc_exe, "-f77rtl","-fixed"], + 'compiler_f77' : [fc_exe, "-f77rtl", "-fixed"], 'compiler_fix' : [fc_exe, "-fixed"], 'compiler_f90' : [fc_exe], 'linker_so' : ['<F90>'], @@ -41,18 +41,18 @@ class CompaqFCompiler(FCompiler): module_include_switch = '-I' def get_flags(self): - return ['-assume no2underscore','-nomixed_str_len_arg'] + return ['-assume no2underscore', '-nomixed_str_len_arg'] def get_flags_debug(self): - return ['-g','-check bounds'] + return ['-g', '-check bounds'] def get_flags_opt(self): - return ['-O4','-align dcommons','-assume bigarrays', - '-assume nozsize','-math_library fast'] + return ['-O4', '-align dcommons', '-assume bigarrays', + '-assume nozsize', '-math_library fast'] def get_flags_arch(self): return ['-arch host', '-tune host'] def get_flags_linker_so(self): if sys.platform[:5]=='linux': return ['-shared'] - return ['-shared','-Wl,-expect_unresolved,*'] + return ['-shared', '-Wl,-expect_unresolved,*'] class CompaqVisualFCompiler(FCompiler): @@ -101,7 +101,7 @@ class CompaqVisualFCompiler(FCompiler): executables = { 'version_cmd' : ['<F90>', "/what"], - 'compiler_f77' : [fc_exe, "/f77rtl","/fixed"], + 'compiler_f77' : [fc_exe, "/f77rtl", "/fixed"], 'compiler_fix' : [fc_exe, "/fixed"], 'compiler_f90' : [fc_exe], 'linker_so' : ['<F90>'], @@ -110,10 +110,10 @@ class CompaqVisualFCompiler(FCompiler): } def get_flags(self): - return ['/nologo','/MD','/WX','/iface=(cref,nomixed_str_len_arg)', - '/names:lowercase','/assume:underscore'] + return ['/nologo', '/MD', '/WX', '/iface=(cref,nomixed_str_len_arg)', + '/names:lowercase', '/assume:underscore'] def get_flags_opt(self): - return ['/Ox','/fast','/optimize:5','/unroll:0','/math_library:fast'] + return ['/Ox', '/fast', '/optimize:5', '/unroll:0', '/math_library:fast'] def get_flags_arch(self): return ['/threads'] def get_flags_debug(self): diff --git a/numpy/distutils/fcompiler/g95.py b/numpy/distutils/fcompiler/g95.py index 20c2c0d03..26f73b530 100644 --- a/numpy/distutils/fcompiler/g95.py +++ b/numpy/distutils/fcompiler/g95.py @@ -22,7 +22,7 @@ class G95FCompiler(FCompiler): 'compiler_f77' : ["g95", "-ffixed-form"], 'compiler_fix' : ["g95", "-ffixed-form"], 'compiler_f90' : ["g95"], - 'linker_so' : ["<F90>","-shared"], + 'linker_so' : ["<F90>", "-shared"], 'archiver' : ["ar", "-cr"], 'ranlib' : ["ranlib"] } diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py index 3402319e0..5ee3df2dc 100644 --- a/numpy/distutils/fcompiler/gnu.py +++ b/numpy/distutils/fcompiler/gnu.py @@ -170,7 +170,7 @@ class GnuFCompiler(FCompiler): if d is not None: g2c = self.g2c + '-pic' f = self.static_lib_format % (g2c, self.static_lib_extension) - if not os.path.isfile(os.path.join(d,f)): + if not os.path.isfile(os.path.join(d, f)): g2c = self.g2c else: g2c = self.g2c diff --git a/numpy/distutils/fcompiler/hpux.py b/numpy/distutils/fcompiler/hpux.py index 5560e199a..9004961e1 100644 --- a/numpy/distutils/fcompiler/hpux.py +++ b/numpy/distutils/fcompiler/hpux.py @@ -31,10 +31,10 @@ class HPUXFCompiler(FCompiler): def get_library_dirs(self): opt = ['/usr/lib/hpux64'] return opt - def get_version(self, force=0, ok_status=[256,0,1]): + def get_version(self, force=0, ok_status=[256, 0, 1]): # XXX status==256 may indicate 'unrecognized option' or # 'no input file'. So, version_cmd needs more work. - return FCompiler.get_version(self,force,ok_status) + return FCompiler.get_version(self, force, ok_status) if __name__ == '__main__': from distutils import log diff --git a/numpy/distutils/fcompiler/ibm.py b/numpy/distutils/fcompiler/ibm.py index e5061bd18..cc65df972 100644 --- a/numpy/distutils/fcompiler/ibm.py +++ b/numpy/distutils/fcompiler/ibm.py @@ -35,7 +35,7 @@ class IBMFCompiler(FCompiler): lslpp = find_executable('lslpp') xlf = find_executable('xlf') if os.path.exists(xlf) and os.path.exists(lslpp): - s,o = exec_command(lslpp + ' -Lc xlfcmp') + s, o = exec_command(lslpp + ' -Lc xlfcmp') m = re.search('xlfcmp:(?P<version>\d+([.]\d+)+)', o) if m: version = m.group('version') @@ -47,7 +47,7 @@ class IBMFCompiler(FCompiler): # let's try another method: l = sorted(os.listdir(xlf_dir)) l.reverse() - l = [d for d in l if os.path.isfile(os.path.join(xlf_dir,d,'xlf.cfg'))] + l = [d for d in l if os.path.isfile(os.path.join(xlf_dir, d, 'xlf.cfg'))] if l: from distutils.version import LooseVersion self.version = version = LooseVersion(l[0]) @@ -65,7 +65,7 @@ class IBMFCompiler(FCompiler): opt.append('-Wl,-bundle,-flat_namespace,-undefined,suppress') else: opt.append('-bshared') - version = self.get_version(ok_status=[0,40]) + version = self.get_version(ok_status=[0, 40]) if version is not None: if sys.platform.startswith('aix'): xlf_cfg = '/etc/xlf.cfg' @@ -73,7 +73,7 @@ class IBMFCompiler(FCompiler): xlf_cfg = '/etc/opt/ibmcmp/xlf/%s/xlf.cfg' % version fo, new_cfg = make_temp_file(suffix='_xlf.cfg') log.info('Creating '+new_cfg) - fi = open(xlf_cfg,'r') + fi = open(xlf_cfg, 'r') crt1_match = re.compile(r'\s*crt\s*[=]\s*(?P<path>.*)/crt1.o').match for line in fi: m = crt1_match(line) diff --git a/numpy/distutils/fcompiler/intel.py b/numpy/distutils/fcompiler/intel.py index f6aa687a8..21a3c5eaf 100644 --- a/numpy/distutils/fcompiler/intel.py +++ b/numpy/distutils/fcompiler/intel.py @@ -137,8 +137,8 @@ class IntelVisualFCompiler(BaseIntelFCompiler): executables = { 'version_cmd' : None, - 'compiler_f77' : [None,"-FI","-w90","-w95"], - 'compiler_fix' : [None,"-FI","-4L72","-w"], + 'compiler_f77' : [None, "-FI", "-w90", "-w95"], + 'compiler_fix' : [None, "-FI", "-4L72", "-w"], 'compiler_f90' : [None], 'linker_so' : ['<F90>', "-shared"], 'archiver' : [ar_exe, "/verbose", "/OUT:"], @@ -152,14 +152,14 @@ class IntelVisualFCompiler(BaseIntelFCompiler): module_include_switch = '/I' def get_flags(self): - opt = ['/nologo','/MD','/nbs','/Qlowercase','/us'] + opt = ['/nologo', '/MD', '/nbs', '/Qlowercase', '/us'] return opt def get_flags_free(self): return ["-FR"] def get_flags_debug(self): - return ['/4Yb','/d2'] + return ['/4Yb', '/d2'] def get_flags_opt(self): return ['/O2'] @@ -178,10 +178,10 @@ class IntelItaniumVisualFCompiler(IntelVisualFCompiler): executables = { 'version_cmd' : None, - 'compiler_f77' : [None,"-FI","-w90","-w95"], - 'compiler_fix' : [None,"-FI","-4L72","-w"], + 'compiler_f77' : [None, "-FI", "-w90", "-w95"], + 'compiler_fix' : [None, "-FI", "-4L72", "-w"], 'compiler_f90' : [None], - 'linker_so' : ['<F90>',"-shared"], + 'linker_so' : ['<F90>', "-shared"], 'archiver' : [ar_exe, "/verbose", "/OUT:"], 'ranlib' : None } diff --git a/numpy/distutils/fcompiler/lahey.py b/numpy/distutils/fcompiler/lahey.py index afca8e422..7a33b4b63 100644 --- a/numpy/distutils/fcompiler/lahey.py +++ b/numpy/distutils/fcompiler/lahey.py @@ -17,7 +17,7 @@ class LaheyFCompiler(FCompiler): 'compiler_f77' : ["lf95", "--fix"], 'compiler_fix' : ["lf95", "--fix"], 'compiler_f90' : ["lf95"], - 'linker_so' : ["lf95","-shared"], + 'linker_so' : ["lf95", "-shared"], 'archiver' : ["ar", "-cr"], 'ranlib' : ["ranlib"] } @@ -28,12 +28,12 @@ class LaheyFCompiler(FCompiler): def get_flags_opt(self): return ['-O'] def get_flags_debug(self): - return ['-g','--chk','--chkglobal'] + return ['-g', '--chk', '--chkglobal'] def get_library_dirs(self): opt = [] d = os.environ.get('LAHEY') if d: - opt.append(os.path.join(d,'lib')) + opt.append(os.path.join(d, 'lib')) return opt def get_libraries(self): opt = [] diff --git a/numpy/distutils/fcompiler/mips.py b/numpy/distutils/fcompiler/mips.py index 21fa00642..6a8d23099 100644 --- a/numpy/distutils/fcompiler/mips.py +++ b/numpy/distutils/fcompiler/mips.py @@ -16,7 +16,7 @@ class MIPSFCompiler(FCompiler): 'compiler_f77' : ["f77", "-f77"], 'compiler_fix' : ["f90", "-fixedform"], 'compiler_f90' : ["f90"], - 'linker_so' : ["f90","-shared"], + 'linker_so' : ["f90", "-shared"], 'archiver' : ["ar", "-cr"], 'ranlib' : None } @@ -31,7 +31,7 @@ class MIPSFCompiler(FCompiler): def get_flags_arch(self): opt = [] for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split(): - if getattr(cpu,'is_IP%s'%a)(): + if getattr(cpu, 'is_IP%s'%a)(): opt.append('-TARG:platform=IP%s' % a) break return opt diff --git a/numpy/distutils/fcompiler/nag.py b/numpy/distutils/fcompiler/nag.py index b02cf43a6..ae1b96faf 100644 --- a/numpy/distutils/fcompiler/nag.py +++ b/numpy/distutils/fcompiler/nag.py @@ -23,7 +23,7 @@ class NAGFCompiler(FCompiler): def get_flags_linker_so(self): if sys.platform=='darwin': - return ['-unsharedf95','-Wl,-bundle,-flat_namespace,-undefined,suppress'] + return ['-unsharedf95', '-Wl,-bundle,-flat_namespace,-undefined,suppress'] return ["-Wl,-shared"] def get_flags_opt(self): return ['-O4'] @@ -34,7 +34,7 @@ class NAGFCompiler(FCompiler): else: return [''] def get_flags_debug(self): - return ['-g','-gline','-g90','-nan','-C'] + return ['-g', '-gline', '-g90', '-nan', '-C'] if __name__ == '__main__': from distutils import log diff --git a/numpy/distutils/fcompiler/none.py b/numpy/distutils/fcompiler/none.py index 039957233..6f602d734 100644 --- a/numpy/distutils/fcompiler/none.py +++ b/numpy/distutils/fcompiler/none.py @@ -9,14 +9,14 @@ class NoneFCompiler(FCompiler): compiler_type = 'none' description = 'Fake Fortran compiler' - executables = {'compiler_f77' : None, - 'compiler_f90' : None, - 'compiler_fix' : None, - 'linker_so' : None, - 'linker_exe' : None, - 'archiver' : None, - 'ranlib' : None, - 'version_cmd' : None, + executables = {'compiler_f77': None, + 'compiler_f90': None, + 'compiler_fix': None, + 'linker_so': None, + 'linker_exe': None, + 'archiver': None, + 'ranlib': None, + 'version_cmd': None, } def find_executables(self): diff --git a/numpy/distutils/fcompiler/pg.py b/numpy/distutils/fcompiler/pg.py index 1cc201f22..f3f5ea22b 100644 --- a/numpy/distutils/fcompiler/pg.py +++ b/numpy/distutils/fcompiler/pg.py @@ -29,7 +29,7 @@ class PGroupFCompiler(FCompiler): 'compiler_f77' : ["pgfortran"], 'compiler_fix' : ["pgfortran", "-Mfixed"], 'compiler_f90' : ["pgfortran"], - 'linker_so' : ["pgfortran","-shared","-fpic"], + 'linker_so' : ["pgfortran", "-shared", "-fpic"], 'archiver' : ["ar", "-cr"], 'ranlib' : ["ranlib"] } @@ -40,7 +40,7 @@ class PGroupFCompiler(FCompiler): module_include_switch = '-I' def get_flags(self): - opt = ['-Minform=inform','-Mnosecond_underscore'] + opt = ['-Minform=inform', '-Mnosecond_underscore'] return self.pic_flags + opt def get_flags_opt(self): return ['-fast'] diff --git a/numpy/distutils/fcompiler/sun.py b/numpy/distutils/fcompiler/sun.py index 07d4eeb8e..0955f14a1 100644 --- a/numpy/distutils/fcompiler/sun.py +++ b/numpy/distutils/fcompiler/sun.py @@ -19,7 +19,7 @@ class SunFCompiler(FCompiler): 'compiler_f77' : ["f90"], 'compiler_fix' : ["f90", "-fixed"], 'compiler_f90' : ["f90"], - 'linker_so' : ["<F90>","-Bdynamic","-G"], + 'linker_so' : ["<F90>", "-Bdynamic", "-G"], 'archiver' : ["ar", "-cr"], 'ranlib' : ["ranlib"] } @@ -35,12 +35,12 @@ class SunFCompiler(FCompiler): ret.append("-fixed") return ret def get_opt(self): - return ['-fast','-dalign'] + return ['-fast', '-dalign'] def get_arch(self): return ['-xtarget=generic'] def get_libraries(self): opt = [] - opt.extend(['fsu','sunmath','mvec']) + opt.extend(['fsu', 'sunmath', 'mvec']) return opt if __name__ == '__main__': diff --git a/numpy/distutils/from_template.py b/numpy/distutils/from_template.py index 9052cf74e..d10b50218 100644 --- a/numpy/distutils/from_template.py +++ b/numpy/distutils/from_template.py @@ -47,15 +47,15 @@ process_file(filename) """ from __future__ import division, absolute_import, print_function -__all__ = ['process_str','process_file'] +__all__ = ['process_str', 'process_file'] 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) -function_start_re = re.compile(r'\n (\$|\*)\s*function\b',re.I) +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) +function_start_re = re.compile(r'\n (\$|\*)\s*function\b', re.I) def parse_structure(astr): """ Return a list of tuples for each function or subroutine each @@ -66,22 +66,22 @@ def parse_structure(astr): spanlist = [] ind = 0 while True: - m = routine_start_re.search(astr,ind) + m = routine_start_re.search(astr, ind) if m is None: break start = m.start() - if function_start_re.match(astr,start,m.end()): + if function_start_re.match(astr, start, m.end()): while True: - i = astr.rfind('\n',ind,start) + i = astr.rfind('\n', ind, start) if i==-1: break start = i if astr[i:i+7]!='\n $': break start += 1 - m = routine_end_re.search(astr,m.end()) + m = routine_end_re.search(astr, m.end()) ind = end = m and m.end()-1 or len(astr) - spanlist.append((start,end)) + spanlist.append((start, end)) return spanlist template_re = re.compile(r"<\s*(\w[\w\d]*)\s*>") @@ -93,7 +93,7 @@ def find_repl_patterns(astr): names = {} for rep in reps: name = rep[0].strip() or unique_key(names) - repl = rep[1].replace('\,','@comma@') + repl = rep[1].replace('\,', '@comma@') thelist = conv(repl) names[name] = thelist return names @@ -124,14 +124,14 @@ def unique_key(adict): template_name_re = re.compile(r'\A\s*(\w[\w\d]*)\s*\Z') -def expand_sub(substr,names): - substr = substr.replace('\>','@rightarrow@') - substr = substr.replace('\<','@leftarrow@') +def expand_sub(substr, names): + substr = substr.replace('\>', '@rightarrow@') + substr = substr.replace('\<', '@leftarrow@') lnames = find_repl_patterns(substr) - substr = named_re.sub(r"<\1>",substr) # get rid of definition templates + substr = named_re.sub(r"<\1>", substr) # get rid of definition templates def listrepl(mobj): - thelist = conv(mobj.group(1).replace('\,','@comma@')) + thelist = conv(mobj.group(1).replace('\,', '@comma@')) if template_name_re.match(thelist): return "<%s>" % (thelist) name = None @@ -151,12 +151,12 @@ def expand_sub(substr,names): rules = {} for r in template_re.findall(substr): if r not in rules: - thelist = lnames.get(r,names.get(r,None)) + thelist = lnames.get(r, names.get(r, None)) if thelist is None: raise ValueError('No replicates found for <%s>' % (r)) if r not in names and not thelist.startswith('_'): names[r] = thelist - rule = [i.replace('@comma@',',') for i in thelist.split(',')] + rule = [i.replace('@comma@', ',') for i in thelist.split(',')] num = len(rule) if numsubs is None: @@ -168,20 +168,20 @@ def expand_sub(substr,names): else: print("Mismatch in number of replacements (base <%s=%s>)" " for <%s=%s>. Ignoring." % - (base_rule, ','.join(rules[base_rule]), r,thelist)) + (base_rule, ','.join(rules[base_rule]), r, thelist)) if not rules: return substr def namerepl(mobj): name = mobj.group(1) - return rules.get(name,(k+1)*[name])[k] + return rules.get(name, (k+1)*[name])[k] newstr = '' for k in range(numsubs): newstr += template_re.sub(namerepl, substr) + '\n\n' - newstr = newstr.replace('@rightarrow@','>') - newstr = newstr.replace('@leftarrow@','<') + newstr = newstr.replace('@rightarrow@', '>') + newstr = newstr.replace('@leftarrow@', '<') return newstr def process_str(allstr): @@ -196,13 +196,13 @@ def process_str(allstr): for sub in struct: writestr += newstr[oldend:sub[0]] names.update(find_repl_patterns(newstr[oldend:sub[0]])) - writestr += expand_sub(newstr[sub[0]:sub[1]],names) + writestr += expand_sub(newstr[sub[0]:sub[1]], names) oldend = sub[1] writestr += newstr[oldend:] return writestr -include_src_re = re.compile(r"(\n|\A)\s*include\s*['\"](?P<name>[\w\d./\\]+[.]src)['\"]",re.I) +include_src_re = re.compile(r"(\n|\A)\s*include\s*['\"](?P<name>[\w\d./\\]+[.]src)['\"]", re.I) def resolve_includes(source): d = os.path.dirname(source) @@ -213,7 +213,7 @@ def resolve_includes(source): if m: fn = m.group('name') if not os.path.isabs(fn): - fn = os.path.join(d,fn) + fn = os.path.join(d, fn) if os.path.isfile(fn): print('Including file', fn) lines.extend(resolve_includes(fn)) @@ -246,10 +246,10 @@ if __name__ == "__main__": fid = sys.stdin outfile = sys.stdout else: - fid = open(file,'r') + fid = open(file, 'r') (base, ext) = os.path.splitext(file) newname = base - outfile = open(newname,'w') + outfile = open(newname, 'w') allstr = fid.read() writestr = process_str(allstr) diff --git a/numpy/distutils/intelccompiler.py b/numpy/distutils/intelccompiler.py index 16fe3a5fb..1d8dcd9fd 100644 --- a/numpy/distutils/intelccompiler.py +++ b/numpy/distutils/intelccompiler.py @@ -10,7 +10,7 @@ class IntelCCompiler(UnixCCompiler): cc_args = 'fPIC' def __init__ (self, verbose=0, dry_run=0, force=0): - UnixCCompiler.__init__ (self, verbose,dry_run, force) + UnixCCompiler.__init__ (self, verbose, dry_run, force) self.cc_exe = 'icc -fPIC' compiler = self.cc_exe self.set_executables(compiler=compiler, @@ -24,7 +24,7 @@ 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']): + for cc_exe in map(find_executable, ['icc', 'ecc']): if cc_exe: break @@ -35,7 +35,7 @@ class IntelEM64TCCompiler(UnixCCompiler): cc_exe = 'icc -m64 -fPIC' cc_args = "-fPIC" def __init__ (self, verbose=0, dry_run=0, force=0): - UnixCCompiler.__init__ (self, verbose,dry_run, force) + UnixCCompiler.__init__ (self, verbose, dry_run, force) self.cc_exe = 'icc -m64 -fPIC' compiler = self.cc_exe self.set_executables(compiler=compiler, diff --git a/numpy/distutils/line_endings.py b/numpy/distutils/line_endings.py index fe1efdca6..5ecb104ff 100644 --- a/numpy/distutils/line_endings.py +++ b/numpy/distutils/line_endings.py @@ -26,16 +26,16 @@ def dos2unix(file): else: print(file, 'ok') -def dos2unix_one_dir(modified_files,dir_name,file_names): +def dos2unix_one_dir(modified_files, dir_name, file_names): for file in file_names: - full_path = os.path.join(dir_name,file) + full_path = os.path.join(dir_name, file) file = dos2unix(full_path) if file is not None: modified_files.append(file) def dos2unix_dir(dir_name): modified_files = [] - os.path.walk(dir_name,dos2unix_one_dir,modified_files) + os.path.walk(dir_name, dos2unix_one_dir, modified_files) return modified_files #---------------------------------- @@ -60,16 +60,16 @@ def unix2dos(file): else: print(file, 'ok') -def unix2dos_one_dir(modified_files,dir_name,file_names): +def unix2dos_one_dir(modified_files, dir_name, file_names): for file in file_names: - full_path = os.path.join(dir_name,file) + full_path = os.path.join(dir_name, file) unix2dos(full_path) if file is not None: modified_files.append(file) def unix2dos_dir(dir_name): modified_files = [] - os.path.walk(dir_name,unix2dos_one_dir,modified_files) + os.path.walk(dir_name, unix2dos_one_dir, modified_files) return modified_files if __name__ == "__main__": diff --git a/numpy/distutils/log.py b/numpy/distutils/log.py index d77f98c63..37f9fe5dd 100644 --- a/numpy/distutils/log.py +++ b/numpy/distutils/log.py @@ -16,9 +16,9 @@ else: def _fix_args(args,flag=1): if is_string(args): - return args.replace('%','%%') + return args.replace('%', '%%') if flag and is_sequence(args): - return tuple([_fix_args(a,flag=0) for a in args]) + return tuple([_fix_args(a, flag=0) for a in args]) return args @@ -78,7 +78,7 @@ def set_verbosity(v, force=False): set_threshold(INFO, force) elif v >= 2: set_threshold(DEBUG, force) - return {FATAL:-2,ERROR:-1,WARN:0,INFO:1,DEBUG:2}.get(prev_level,1) + return {FATAL:-2,ERROR:-1,WARN:0,INFO:1,DEBUG:2}.get(prev_level, 1) _global_color_map = { diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py index 75687be84..c720d142a 100644 --- a/numpy/distutils/mingw32ccompiler.py +++ b/numpy/distutils/mingw32ccompiler.py @@ -54,7 +54,7 @@ class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler): force=0): distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, - verbose,dry_run, force) + verbose, dry_run, force) # we need to support 3.2 which doesn't match the standard # get_versions methods regex @@ -64,7 +64,7 @@ class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler): stdout=subprocess.PIPE) out_string = p.stdout.read() p.stdout.close() - result = re.search('(\d+\.\d+)',out_string) + result = re.search('(\d+\.\d+)', out_string) if result: self.gcc_version = StrictVersion(result.group(1)) @@ -215,11 +215,11 @@ class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler): # added these lines to strip off windows drive letters # without it, .o files are placed next to .c files # instead of the build directory - drv,base = os.path.splitdrive(base) + drv, base = os.path.splitdrive(base) if drv: base = base[1:] - if ext not in (self.src_extensions + ['.rc','.res']): + if ext not in (self.src_extensions + ['.rc', '.res']): raise UnknownFileError( "unknown file type '%s' (from '%s')" % \ (ext, src_name)) @@ -391,7 +391,7 @@ def _build_import_library_amd64(): return def_name = "python%d%d.def" % tuple(sys.version_info[:2]) - def_file = os.path.join(sys.prefix,'libs',def_name) + def_file = os.path.join(sys.prefix, 'libs', def_name) log.info('Building import library (arch=AMD64): "%s" (from %s)' \ % (out_file, dll_file)) @@ -405,9 +405,9 @@ def _build_import_library_x86(): """ Build the import libraries for Mingw32-gcc on Windows """ lib_name = "python%d%d.lib" % tuple(sys.version_info[:2]) - lib_file = os.path.join(sys.prefix,'libs',lib_name) + lib_file = os.path.join(sys.prefix, 'libs', lib_name) out_name = "libpython%d%d.a" % tuple(sys.version_info[:2]) - out_file = os.path.join(sys.prefix,'libs',out_name) + out_file = os.path.join(sys.prefix, 'libs', out_name) if not os.path.isfile(lib_file): log.warn('Cannot build import library: "%s" not found' % (lib_file)) return @@ -419,14 +419,14 @@ def _build_import_library_x86(): from numpy.distutils import lib2def def_name = "python%d%d.def" % tuple(sys.version_info[:2]) - def_file = os.path.join(sys.prefix,'libs',def_name) + def_file = os.path.join(sys.prefix, 'libs', def_name) nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file) nm_output = lib2def.getnm(nm_cmd) dlist, flist = lib2def.parse_nm(nm_output) lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w')) dll_name = "python%d%d.dll" % tuple(sys.version_info[:2]) - args = (dll_name,def_file,out_file) + args = (dll_name, def_file, out_file) cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args status = os.system(cmd) # for now, fail silently @@ -465,7 +465,7 @@ if sys.platform == 'win32': # Value from msvcrt.CRT_ASSEMBLY_VERSION under Python 3.3.0 on Windows XP: _MSVCRVER_TO_FULLVER['100'] = "10.0.30319.460" if hasattr(msvcrt, "CRT_ASSEMBLY_VERSION"): - major, minor, rest = msvcrt.CRT_ASSEMBLY_VERSION.split(".",2) + major, minor, rest = msvcrt.CRT_ASSEMBLY_VERSION.split(".", 2) _MSVCRVER_TO_FULLVER[major + minor] = msvcrt.CRT_ASSEMBLY_VERSION del major, minor, rest except ImportError: diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index bc073aee4..f77e52592 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -25,11 +25,11 @@ __all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict', 'dict_append', 'appendpath', 'generate_config_py', 'get_cmd', 'allpath', 'get_mathlibs', 'terminal_has_colors', 'red_text', 'green_text', 'yellow_text', - 'blue_text', 'cyan_text', 'cyg2win32','mingw32','all_strings', + 'blue_text', 'cyan_text', 'cyg2win32', 'mingw32', 'all_strings', 'has_f_sources', 'has_cxx_sources', 'filter_sources', 'get_dependencies', 'is_local_src_dir', 'get_ext_source_files', 'get_script_files', 'get_lib_source_files', 'get_data_files', - 'dot_join', 'get_frame', 'minrelpath','njoin', + 'dot_join', 'get_frame', 'minrelpath', 'njoin', 'is_sequence', 'is_string', 'as_list', 'gpaths', 'get_language', 'quote_args', 'get_build_architecture', 'get_info', 'get_pkg_info'] @@ -85,7 +85,7 @@ def rel_path(path, parent_path): if apath==pd: return '' if pd == apath[:len(pd)]: - assert apath[len(pd)] in [os.sep],repr((path,apath[len(pd)])) + assert apath[len(pd)] in [os.sep], repr((path, apath[len(pd)])) path = apath[len(pd)+1:] return path @@ -144,19 +144,19 @@ def njoin(*path): # njoin('a', 'b') joined = os.path.join(*path) if os.path.sep != '/': - joined = joined.replace('/',os.path.sep) + joined = joined.replace('/', os.path.sep) return minrelpath(joined) def get_mathlibs(path=None): """Return the MATHLIB line from numpyconfig.h """ if path is not None: - config_file = os.path.join(path,'_numpyconfig.h') + config_file = os.path.join(path, '_numpyconfig.h') else: # Look for the file in each of the numpy include directories. dirs = get_numpy_include_dirs() for path in dirs: - fn = os.path.join(path,'_numpyconfig.h') + fn = os.path.join(path, '_numpyconfig.h') if os.path.exists(fn): config_file = fn break @@ -185,34 +185,34 @@ def minrelpath(path): l = path.split(os.sep) while l: try: - i = l.index('.',1) + i = l.index('.', 1) except ValueError: break del l[i] j = 1 while l: try: - i = l.index('..',j) + i = l.index('..', j) except ValueError: break if l[i-1]=='..': j += 1 else: - del l[i],l[i-1] + del l[i], l[i-1] j = 1 if not l: return '' return os.sep.join(l) -def _fix_paths(paths,local_path,include_non_existing): +def _fix_paths(paths, local_path, include_non_existing): assert is_sequence(paths), repr(type(paths)) new_paths = [] - assert not is_string(paths),repr(paths) + assert not is_string(paths), repr(paths) for n in paths: if is_string(n): if '*' in n or '?' in n: p = glob.glob(n) - p2 = glob.glob(njoin(local_path,n)) + p2 = glob.glob(njoin(local_path, n)) if p2: new_paths.extend(p2) elif p: @@ -221,9 +221,9 @@ def _fix_paths(paths,local_path,include_non_existing): if include_non_existing: new_paths.append(n) print('could not resolve pattern in %r: %r' % - (local_path,n)) + (local_path, n)) else: - n2 = njoin(local_path,n) + n2 = njoin(local_path, n) if os.path.exists(n2): new_paths.append(n2) else: @@ -233,10 +233,10 @@ def _fix_paths(paths,local_path,include_non_existing): new_paths.append(n) if not os.path.exists(n): print('non-existing path in %r: %r' % - (local_path,n)) + (local_path, n)) elif is_sequence(n): - new_paths.extend(_fix_paths(n,local_path,include_non_existing)) + new_paths.extend(_fix_paths(n, local_path, include_non_existing)) else: new_paths.append(n) return [minrelpath(p) for p in new_paths] @@ -246,7 +246,7 @@ def gpaths(paths, local_path='', include_non_existing=True): """ if is_string(paths): paths = (paths,) - return _fix_paths(paths,local_path, include_non_existing) + return _fix_paths(paths, local_path, include_non_existing) _temporary_directory = None @@ -285,7 +285,7 @@ def terminal_has_colors(): # curses.version is 2.2 # CYGWIN_98-4.10, release 1.5.7(0.109/3/2)) return 0 - if hasattr(sys.stdout,'isatty') and sys.stdout.isatty(): + if hasattr(sys.stdout, 'isatty') and sys.stdout.isatty(): try: import curses curses.setupterm() @@ -346,9 +346,9 @@ def mingw32(): """Return true when using mingw32 environment. """ if sys.platform=='win32': - if os.environ.get('OSTYPE','')=='msys': + if os.environ.get('OSTYPE', '')=='msys': return True - if os.environ.get('MSYSTEM','')=='MINGW32': + if os.environ.get('MSYSTEM', '')=='MINGW32': return True return False @@ -357,11 +357,11 @@ def msvc_runtime_library(): msc_pos = sys.version.find('MSC v.') if msc_pos != -1: msc_ver = sys.version[msc_pos+6:msc_pos+10] - lib = {'1300' : 'msvcr70', # MSVC 7.0 - '1310' : 'msvcr71', # MSVC 7.1 - '1400' : 'msvcr80', # MSVC 8 - '1500' : 'msvcr90', # MSVC 9 (VS 2008) - '1600' : 'msvcr100', # MSVC 10 (aka 2010) + lib = {'1300': 'msvcr70', # MSVC 7.0 + '1310': 'msvcr71', # MSVC 7.1 + '1400': 'msvcr80', # MSVC 8 + '1500': 'msvcr90', # MSVC 9 (VS 2008) + '1600': 'msvcr100', # MSVC 10 (aka 2010) }.get(msc_ver, None) else: lib = None @@ -371,10 +371,10 @@ def msvc_runtime_library(): ######################### #XXX need support for .C that is also C++ -cxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\Z',re.I).match -fortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\Z',re.I).match -f90_ext_match = re.compile(r'.*[.](f90|f95)\Z',re.I).match -f90_module_name_match = re.compile(r'\s*module\s*(?P<name>[\w_]+)',re.I).match +cxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\Z', re.I).match +fortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\Z', re.I).match +f90_ext_match = re.compile(r'.*[.](f90|f95)\Z', re.I).match +f90_module_name_match = re.compile(r'\s*module\s*(?P<name>[\w_]+)', re.I).match def _get_f90_modules(source): """Return a list of Fortran f90 module names that given source file defines. @@ -382,7 +382,7 @@ def _get_f90_modules(source): if not f90_ext_match(source): return [] modules = [] - f = open(source,'r') + f = open(source, 'r') for line in f: m = f90_module_name_match(line) if m: @@ -474,7 +474,7 @@ def _get_headers(directory_list): # get *.h files from list of directories headers = [] for d in directory_list: - head = glob.glob(os.path.join(d,"*.h")) #XXX: *.hpp files?? + head = glob.glob(os.path.join(d, "*.h")) #XXX: *.hpp files?? headers.extend(head) return headers @@ -497,7 +497,7 @@ def is_local_src_dir(directory): if not is_string(directory): return False abs_dir = os.path.abspath(directory) - c = os.path.commonprefix([os.getcwd(),abs_dir]) + c = os.path.commonprefix([os.getcwd(), abs_dir]) new_dir = abs_dir[len(c):].split(os.sep) if new_dir and not new_dir[0]: new_dir = new_dir[1:] @@ -520,7 +520,7 @@ def general_source_directories_files(top_path): """Return a directory name relative to top_path and files contained. """ - pruned_directories = ['CVS','.svn','build'] + pruned_directories = ['CVS', '.svn', 'build'] prune_file_pat = re.compile(r'(?:[~#]|\.py[co]|\.o)$') for dirpath, dirnames, filenames in os.walk(top_path, topdown=True): pruned = [ d for d in dirnames if d not in pruned_directories ] @@ -530,13 +530,13 @@ def general_source_directories_files(top_path): rpath = rel_path(dpath, top_path) files = [] for f in os.listdir(dpath): - fn = os.path.join(dpath,f) + fn = os.path.join(dpath, f) if os.path.isfile(fn) and not prune_file_pat.search(fn): files.append(fn) yield rpath, files dpath = top_path rpath = rel_path(dpath, top_path) - filenames = [os.path.join(dpath,f) for f in os.listdir(dpath) \ + filenames = [os.path.join(dpath, f) for f in os.listdir(dpath) \ if not prune_file_pat.search(f)] files = [f for f in filenames if os.path.isfile(f)] yield rpath, files @@ -561,11 +561,11 @@ def get_script_files(scripts): def get_lib_source_files(lib): filenames = [] - sources = lib[1].get('sources',[]) + sources = lib[1].get('sources', []) sources = [_m for _m in sources if is_string(_m)] filenames.extend(sources) filenames.extend(get_dependencies(sources)) - depends = lib[1].get('depends',[]) + depends = lib[1].get('depends', []) for d in depends: if is_local_src_dir(d): filenames.extend(list(general_source_files(d))) @@ -701,8 +701,8 @@ class Configuration(object): self.local_path = '' if package_path is None: package_path = self.local_path - elif os.path.isdir(njoin(self.local_path,package_path)): - package_path = njoin(self.local_path,package_path) + elif os.path.isdir(njoin(self.local_path, package_path)): + package_path = njoin(self.local_path, package_path) if not os.path.isdir(package_path or '.'): raise ValueError("%r is not a directory" % (package_path,)) self.top_path = top_path @@ -727,7 +727,7 @@ class Configuration(object): if n in known_keys: continue a = attrs[n] - setattr(self,n,a) + setattr(self, n, a) if isinstance(a, list): self.list_keys.append(n) elif isinstance(a, dict): @@ -735,7 +735,7 @@ class Configuration(object): else: self.extra_keys.append(n) - if os.path.exists(njoin(package_path,'__init__.py')): + if os.path.exists(njoin(package_path, '__init__.py')): self.packages.append(self.name) self.package_dir[self.name] = package_path @@ -747,13 +747,13 @@ class Configuration(object): ) caller_instance = None - for i in range(1,3): + for i in range(1, 3): try: f = get_frame(i) except ValueError: break try: - caller_instance = eval('self',f.f_globals,f.f_locals) + caller_instance = eval('self', f.f_globals, f.f_locals) break except NameError: pass @@ -777,7 +777,7 @@ class Configuration(object): d = {} known_keys = self.list_keys + self.dict_keys + self.extra_keys for n in known_keys: - a = getattr(self,n) + a = getattr(self, n) if a: d[n] = a return d @@ -819,7 +819,7 @@ class Configuration(object): dirs = [_m for _m in glob.glob(subpackage_path) if os.path.isdir(_m)] config_list = [] for d in dirs: - if not os.path.isfile(njoin(d,'__init__.py')): + if not os.path.isfile(njoin(d, '__init__.py')): continue if 'build' in d.split(os.sep): continue @@ -836,17 +836,17 @@ class Configuration(object): parent_name, caller_level = 1): # In case setup_py imports local modules: - sys.path.insert(0,os.path.dirname(setup_py)) + sys.path.insert(0, os.path.dirname(setup_py)) try: fo_setup_py = open(setup_py, 'U') setup_name = os.path.splitext(os.path.basename(setup_py))[0] - n = dot_join(self.name,subpackage_name,setup_name) + n = dot_join(self.name, subpackage_name, setup_name) setup_module = imp.load_module('_'.join(n.split('.')), fo_setup_py, setup_py, ('.py', 'U', 1)) fo_setup_py.close() - if not hasattr(setup_module,'configuration'): + if not hasattr(setup_module, 'configuration'): if not self.options['assume_default_configuration']: self.warn('Assuming default configuration '\ '(%s does not define configuration())'\ @@ -870,9 +870,9 @@ class Configuration(object): else: args = fix_args_py3(args) config = setup_module.configuration(*args) - if config.name!=dot_join(parent_name,subpackage_name): + if config.name!=dot_join(parent_name, subpackage_name): self.warn('Subpackage %r configuration returned as %r' % \ - (dot_join(parent_name,subpackage_name), config.name)) + (dot_join(parent_name, subpackage_name), config.name)) finally: del sys.path[0] return config @@ -907,7 +907,7 @@ class Configuration(object): return self._wildcard_get_subpackage(subpackage_name, parent_name, caller_level = caller_level+1) - assert '*' not in subpackage_name,repr((subpackage_name, subpackage_path,parent_name)) + assert '*' not in subpackage_name, repr((subpackage_name, subpackage_path, parent_name)) if subpackage_path is None: subpackage_path = njoin([self.local_path] + l) else: @@ -961,7 +961,7 @@ class Configuration(object): parent_name = None else: parent_name = self.name - config_list = self.get_subpackage(subpackage_name,subpackage_path, + config_list = self.get_subpackage(subpackage_name, subpackage_path, parent_name = parent_name, caller_level = 2) if not config_list: @@ -970,7 +970,7 @@ class Configuration(object): d = config if isinstance(config, Configuration): d = config.todict() - assert isinstance(d,dict),repr(type(d)) + assert isinstance(d, dict), repr(type(d)) self.info('Appending %s configuration to %s' \ % (d.get('name'), self.name)) @@ -981,7 +981,7 @@ class Configuration(object): self.warn('distutils distribution has been initialized,'\ ' it may be too late to add a subpackage '+ subpackage_name) - def add_data_dir(self,data_path): + def add_data_dir(self, data_path): """Recursively add files under data_path to data_files list. Recursively add files under data_path to the list of data_files to be @@ -1040,7 +1040,7 @@ class Configuration(object): else: d = None if is_sequence(data_path): - [self.add_data_dir((d,p)) for p in data_path] + [self.add_data_dir((d, p)) for p in data_path] return if not is_string(data_path): raise TypeError("not a string: %r" % (data_path,)) @@ -1075,19 +1075,19 @@ class Configuration(object): % (d, path)) target_list.append(path_list[i]) else: - assert s==path_list[i],repr((s,path_list[i],data_path,d,path,rpath)) + assert s==path_list[i], repr((s, path_list[i], data_path, d, path, rpath)) target_list.append(s) i += 1 if path_list[i:]: self.warn('mismatch of pattern_list=%s and path_list=%s'\ - % (pattern_list,path_list)) + % (pattern_list, path_list)) target_list.reverse() - self.add_data_dir((os.sep.join(target_list),path)) + self.add_data_dir((os.sep.join(target_list), path)) else: for path in paths: - self.add_data_dir((d,path)) + self.add_data_dir((d, path)) return - assert not is_glob_pattern(d),repr(d) + assert not is_glob_pattern(d), repr(d) dist = self.get_distribution() if dist is not None and dist.data_files is not None: @@ -1096,18 +1096,18 @@ class Configuration(object): data_files = self.data_files for path in paths: - for d1,f in list(general_source_directories_files(path)): - target_path = os.path.join(self.path_in_package,d,d1) + for d1, f in list(general_source_directories_files(path)): + target_path = os.path.join(self.path_in_package, d, d1) data_files.append((target_path, f)) def _optimize_data_files(self): data_dict = {} - for p,files in self.data_files: + for p, files in self.data_files: if p not in data_dict: data_dict[p] = set() for f in files: data_dict[p].add(f) - self.data_files[:] = [(p,list(files)) for p,files in data_dict.items()] + self.data_files[:] = [(p, list(files)) for p, files in data_dict.items()] def add_data_files(self,*files): """Add data files to configuration data_files. @@ -1203,7 +1203,7 @@ class Configuration(object): return assert len(files)==1 if is_sequence(files[0]): - d,files = files[0] + d, files = files[0] else: d = None if is_string(files): @@ -1213,7 +1213,7 @@ class Configuration(object): filepat = files[0] else: for f in files: - self.add_data_files((d,f)) + self.add_data_files((d, f)) return else: raise TypeError(repr(type(files))) @@ -1225,7 +1225,7 @@ class Configuration(object): d = '' else: d = os.path.dirname(filepat) - self.add_data_files((d,files)) + self.add_data_files((d, files)) return paths = self.paths(filepat, include_non_existing=False) @@ -1248,9 +1248,9 @@ class Configuration(object): target_list.reverse() self.add_data_files((os.sep.join(target_list), path)) else: - self.add_data_files((d,paths)) + self.add_data_files((d, paths)) return - assert not is_glob_pattern(d),repr((d,filepat)) + assert not is_glob_pattern(d), repr((d, filepat)) dist = self.get_distribution() if dist is not None and dist.data_files is not None: @@ -1258,7 +1258,7 @@ class Configuration(object): else: data_files = self.data_files - data_files.append((os.path.join(self.path_in_package,d),paths)) + data_files.append((os.path.join(self.path_in_package, d), paths)) ### XXX Implement add_py_modules @@ -1319,11 +1319,11 @@ class Configuration(object): headers = [] for path in files: if is_string(path): - [headers.append((self.name,p)) for p in self.paths(path)] + [headers.append((self.name, p)) for p in self.paths(path)] else: if not isinstance(path, (tuple, list)) or len(path) != 2: raise TypeError(repr(path)) - [headers.append((path[0],p)) for p in self.paths(path[1])] + [headers.append((path[0], p)) for p in self.paths(path[1])] dist = self.get_distribution() if dist is not None: if dist.headers is None: @@ -1342,16 +1342,16 @@ class Configuration(object): path-names be relative to the source directory. """ - include_non_existing = kws.get('include_non_existing',True) + include_non_existing = kws.get('include_non_existing', True) return gpaths(paths, local_path = self.local_path, include_non_existing=include_non_existing) - def _fix_paths_dict(self,kw): + def _fix_paths_dict(self, kw): for k in kw.keys(): v = kw[k] - if k in ['sources','depends','include_dirs','library_dirs', - 'module_dirs','extra_objects']: + if k in ['sources', 'depends', 'include_dirs', 'library_dirs', + 'module_dirs', 'extra_objects']: new_v = self.paths(v) kw[k] = new_v @@ -1404,7 +1404,7 @@ class Configuration(object): paths. """ ext_args = copy.copy(kw) - ext_args['name'] = dot_join(self.name,name) + ext_args['name'] = dot_join(self.name, name) ext_args['sources'] = sources if 'extra_info' in ext_args: @@ -1419,26 +1419,26 @@ class Configuration(object): self._fix_paths_dict(ext_args) # Resolve out-of-tree dependencies - libraries = ext_args.get('libraries',[]) + libraries = ext_args.get('libraries', []) libnames = [] ext_args['libraries'] = [] for libname in libraries: - if isinstance(libname,tuple): + if isinstance(libname, tuple): self._fix_paths_dict(libname[1]) # Handle library names of the form libname@relative/path/to/library if '@' in libname: - lname,lpath = libname.split('@',1) - lpath = os.path.abspath(njoin(self.local_path,lpath)) + lname, lpath = libname.split('@', 1) + lpath = os.path.abspath(njoin(self.local_path, lpath)) if os.path.isdir(lpath): - c = self.get_subpackage(None,lpath, + c = self.get_subpackage(None, lpath, caller_level = 2) - if isinstance(c,Configuration): + if isinstance(c, Configuration): c = c.todict() - for l in [l[0] for l in c.get('libraries',[])]: - llname = l.split('__OF__',1)[0] + for l in [l[0] for l in c.get('libraries', [])]: + llname = l.split('__OF__', 1)[0] if llname == lname: - c.pop('name',None) + c.pop('name', None) dict_append(ext_args,**c) break continue @@ -1653,23 +1653,23 @@ class Configuration(object): def dict_append(self,**dict): for key in self.list_keys: - a = getattr(self,key) - a.extend(dict.get(key,[])) + a = getattr(self, key) + a.extend(dict.get(key, [])) for key in self.dict_keys: - a = getattr(self,key) - a.update(dict.get(key,{})) + a = getattr(self, key) + a.update(dict.get(key, {})) known_keys = self.list_keys + self.dict_keys + self.extra_keys for key in dict.keys(): if key not in known_keys: a = getattr(self, key, None) if a and a==dict[key]: continue self.warn('Inheriting attribute %r=%r from %r' \ - % (key,dict[key],dict.get('name','?'))) - setattr(self,key,dict[key]) + % (key, dict[key], dict.get('name', '?'))) + setattr(self, key, dict[key]) self.extra_keys.append(key) elif key in self.extra_keys: self.info('Ignoring attempt to set %r (from %r to %r)' \ - % (key, getattr(self,key), dict[key])) + % (key, getattr(self, key), dict[key])) elif key in known_keys: # key is already processed above pass @@ -1683,9 +1683,9 @@ class Configuration(object): s += 'Configuration of '+self.name+':\n' known_keys.sort() for k in known_keys: - a = getattr(self,k,None) + a = getattr(self, k, None) if a: - s += '%s = %s\n' % (k,pformat(a)) + s += '%s = %s\n' % (k, pformat(a)) s += 5*'-' + '>' return s @@ -1699,7 +1699,7 @@ class Configuration(object): cmd.noisy = 0 old_path = os.environ.get('PATH') if old_path: - path = os.pathsep.join(['.',old_path]) + path = os.pathsep.join(['.', old_path]) os.environ['PATH'] = path return cmd @@ -1728,7 +1728,7 @@ class Configuration(object): end ''' config_cmd = self.get_config_cmd() - flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77') + flag = config_cmd.try_compile(simple_fortran_subroutine, lang='f77') return flag def have_f90c(self): @@ -1747,7 +1747,7 @@ class Configuration(object): end ''' config_cmd = self.get_config_cmd() - flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90') + flag = config_cmd.try_compile(simple_fortran_subroutine, lang='f90') return flag def append_to(self, extlib): @@ -1760,11 +1760,11 @@ class Configuration(object): include_dirs=self.include_dirs) else: from numpy.distutils.core import Extension - assert isinstance(extlib,Extension), repr(extlib) + assert isinstance(extlib, Extension), repr(extlib) extlib.libraries.extend(self.libraries) extlib.include_dirs.extend(self.include_dirs) - def _get_svn_revision(self,path): + def _get_svn_revision(self, path): """Return path's SVN revision number. """ revision = None @@ -1783,16 +1783,16 @@ class Configuration(object): if m: revision = int(m.group('revision')) return revision - if sys.platform=='win32' and os.environ.get('SVN_ASP_DOT_NET_HACK',None): - entries = njoin(path,'_svn','entries') + if sys.platform=='win32' and os.environ.get('SVN_ASP_DOT_NET_HACK', None): + entries = njoin(path, '_svn', 'entries') else: - entries = njoin(path,'.svn','entries') + entries = njoin(path, '.svn', 'entries') if os.path.isfile(entries): f = open(entries) fstr = f.read() f.close() if fstr[:5] == '<?xml': # pre 1.4 - m = re.search(r'revision="(?P<revision>\d+)"',fstr) + m = re.search(r'revision="(?P<revision>\d+)"', fstr) if m: revision = int(m.group('revision')) else: # non-xml entries file --- check to be sure that @@ -1801,7 +1801,7 @@ class Configuration(object): revision = int(m.group('revision')) return revision - def _get_hg_revision(self,path): + def _get_hg_revision(self, path): """Return path's Mercurial revision number. """ revision = None @@ -1820,8 +1820,8 @@ class Configuration(object): if m: revision = int(m.group('revision')) return revision - branch_fn = njoin(path,'.hg','branch') - branch_cache_fn = njoin(path,'.hg','branch.cache') + branch_fn = njoin(path, '.hg', 'branch') + branch_cache_fn = njoin(path, '.hg', 'branch.cache') if os.path.isfile(branch_fn): branch0 = None @@ -1857,7 +1857,7 @@ class Configuration(object): __svn_version__.py for string variables version, __version\__, and <packagename>_version, until a version number is found. """ - version = getattr(self,'version',None) + version = getattr(self, 'version', None) if version is not None: return version @@ -1877,11 +1877,11 @@ class Configuration(object): else: version_vars = [version_variable] for f in files: - fn = njoin(self.local_path,f) + fn = njoin(self.local_path, f) if os.path.isfile(fn): - info = (open(fn),fn,('.py','U',1)) + info = (open(fn), fn, ('.py', 'U', 1)) name = os.path.splitext(os.path.basename(fn))[0] - n = dot_join(self.name,name) + n = dot_join(self.name, name) try: version_module = imp.load_module('_'.join(n.split('.')),*info) except ImportError: @@ -1892,7 +1892,7 @@ class Configuration(object): continue for a in version_vars: - version = getattr(version_module,a,None) + version = getattr(version_module, a, None) if version is not None: break if version is not None: @@ -1929,7 +1929,7 @@ class Configuration(object): intended for working with source directories that are in an SVN repository. """ - target = njoin(self.local_path,'__svn_version__.py') + target = njoin(self.local_path, '__svn_version__.py') revision = self._get_svn_revision(self.local_path) if os.path.isfile(target) or revision is None: return @@ -1937,8 +1937,8 @@ class Configuration(object): def generate_svn_version_py(): if not os.path.isfile(target): version = str(revision) - self.info('Creating %s (version=%r)' % (target,version)) - f = open(target,'w') + self.info('Creating %s (version=%r)' % (target, version)) + f = open(target, 'w') f.write('version = %r\n' % (version)) f.close() @@ -1971,7 +1971,7 @@ class Configuration(object): This is intended for working with source directories that are in an Mercurial repository. """ - target = njoin(self.local_path,'__hg_version__.py') + target = njoin(self.local_path, '__hg_version__.py') revision = self._get_hg_revision(self.local_path) if os.path.isfile(target) or revision is None: return @@ -1979,8 +1979,8 @@ class Configuration(object): def generate_hg_version_py(): if not os.path.isfile(target): version = str(revision) - self.info('Creating %s (version=%r)' % (target,version)) - f = open(target,'w') + self.info('Creating %s (version=%r)' % (target, version)) + f = open(target, 'w') f.write('version = %r\n' % (version)) f.close() @@ -2006,7 +2006,7 @@ class Configuration(object): package installation directory. """ - self.py_modules.append((self.name,name,generate_config_py)) + self.py_modules.append((self.name, name, generate_config_py)) def get_info(self,*names): @@ -2183,7 +2183,7 @@ def dict_append(d, **kws): for k, v in kws.items(): if k in d: ov = d[k] - if isinstance(ov,str): + if isinstance(ov, str): d[k] = v else: d[k].extend(v) diff --git a/numpy/distutils/setup.py b/numpy/distutils/setup.py index e4dbe240b..82a53bd08 100644 --- a/numpy/distutils/setup.py +++ b/numpy/distutils/setup.py @@ -3,7 +3,7 @@ from __future__ import division, print_function def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('distutils',parent_package,top_path) + config = Configuration('distutils', parent_package, top_path) config.add_subpackage('command') config.add_subpackage('fcompiler') config.add_data_dir('tests') diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index 13f52801e..8ec1b8446 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -1829,7 +1829,7 @@ class agg2_info(system_info): info = {'libraries': [('agg2_src', {'sources': agg2_srcs, - 'include_dirs':[os.path.join(src_dir, 'include')], + 'include_dirs': [os.path.join(src_dir, 'include')], } )], 'include_dirs': [os.path.join(src_dir, 'include')], diff --git a/numpy/distutils/tests/f2py_ext/setup.py b/numpy/distutils/tests/f2py_ext/setup.py index 658b01bb6..bb7d4bc1c 100644 --- a/numpy/distutils/tests/f2py_ext/setup.py +++ b/numpy/distutils/tests/f2py_ext/setup.py @@ -3,8 +3,8 @@ from __future__ import division, print_function def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('f2py_ext',parent_package,top_path) - config.add_extension('fib2', ['src/fib2.pyf','src/fib1.f']) + config = Configuration('f2py_ext', parent_package, top_path) + config.add_extension('fib2', ['src/fib2.pyf', 'src/fib1.f']) config.add_data_dir('tests') return config diff --git a/numpy/distutils/tests/f2py_ext/tests/test_fib2.py b/numpy/distutils/tests/f2py_ext/tests/test_fib2.py index bee1b9870..5252db283 100644 --- a/numpy/distutils/tests/f2py_ext/tests/test_fib2.py +++ b/numpy/distutils/tests/f2py_ext/tests/test_fib2.py @@ -7,7 +7,7 @@ from f2py_ext import fib2 class TestFib2(TestCase): def test_fib(self): - assert_array_equal(fib2.fib(6),[0,1,1,2,3,5]) + assert_array_equal(fib2.fib(6), [0, 1, 1, 2, 3, 5]) if __name__ == "__main__": run_module_suite() diff --git a/numpy/distutils/tests/f2py_f90_ext/setup.py b/numpy/distutils/tests/f2py_f90_ext/setup.py index 4b4c2390c..7cca81637 100644 --- a/numpy/distutils/tests/f2py_f90_ext/setup.py +++ b/numpy/distutils/tests/f2py_f90_ext/setup.py @@ -3,7 +3,7 @@ from __future__ import division, print_function def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('f2py_f90_ext',parent_package,top_path) + config = Configuration('f2py_f90_ext', parent_package, top_path) config.add_extension('foo', ['src/foo_free.f90'], include_dirs=['include'], diff --git a/numpy/distutils/tests/f2py_f90_ext/tests/test_foo.py b/numpy/distutils/tests/f2py_f90_ext/tests/test_foo.py index 92e559291..9653b9023 100644 --- a/numpy/distutils/tests/f2py_f90_ext/tests/test_foo.py +++ b/numpy/distutils/tests/f2py_f90_ext/tests/test_foo.py @@ -6,7 +6,7 @@ from f2py_f90_ext import foo class TestFoo(TestCase): def test_foo_free(self): - assert_equal(foo.foo_free.bar13(),13) + assert_equal(foo.foo_free.bar13(), 13) if __name__ == "__main__": run_module_suite() diff --git a/numpy/distutils/tests/gen_ext/setup.py b/numpy/distutils/tests/gen_ext/setup.py index ccab2a45e..de6b941e0 100644 --- a/numpy/distutils/tests/gen_ext/setup.py +++ b/numpy/distutils/tests/gen_ext/setup.py @@ -28,16 +28,16 @@ C END FILE FIB3.F def source_func(ext, build_dir): import os from distutils.dep_util import newer - target = os.path.join(build_dir,'fib3.f') + target = os.path.join(build_dir, 'fib3.f') if newer(__file__, target): - f = open(target,'w') + f = open(target, 'w') f.write(fib3_f) f.close() return [target] def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('gen_ext',parent_package,top_path) + config = Configuration('gen_ext', parent_package, top_path) config.add_extension('fib3', [source_func] ) diff --git a/numpy/distutils/tests/gen_ext/tests/test_fib3.py b/numpy/distutils/tests/gen_ext/tests/test_fib3.py index 7bab5a6be..5fd9be439 100644 --- a/numpy/distutils/tests/gen_ext/tests/test_fib3.py +++ b/numpy/distutils/tests/gen_ext/tests/test_fib3.py @@ -6,7 +6,7 @@ from gen_ext import fib3 class TestFib3(TestCase): def test_fib(self): - assert_array_equal(fib3.fib(6),[0,1,1,2,3,5]) + assert_array_equal(fib3.fib(6), [0, 1, 1, 2, 3, 5]) if __name__ == "__main__": run_module_suite() diff --git a/numpy/distutils/tests/pyrex_ext/setup.py b/numpy/distutils/tests/pyrex_ext/setup.py index ad1f5207a..819dd3154 100644 --- a/numpy/distutils/tests/pyrex_ext/setup.py +++ b/numpy/distutils/tests/pyrex_ext/setup.py @@ -3,7 +3,7 @@ from __future__ import division, print_function def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('pyrex_ext',parent_package,top_path) + config = Configuration('pyrex_ext', parent_package, top_path) config.add_extension('primes', ['primes.pyx']) config.add_data_dir('tests') diff --git a/numpy/distutils/tests/setup.py b/numpy/distutils/tests/setup.py index 61f6ba751..135de7c47 100644 --- a/numpy/distutils/tests/setup.py +++ b/numpy/distutils/tests/setup.py @@ -3,7 +3,7 @@ from __future__ import division, print_function def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('testnumpydistutils',parent_package,top_path) + config = Configuration('testnumpydistutils', parent_package, top_path) config.add_subpackage('pyrex_ext') config.add_subpackage('f2py_ext') #config.add_subpackage('f2py_f90_ext') diff --git a/numpy/distutils/tests/swig_ext/setup.py b/numpy/distutils/tests/swig_ext/setup.py index 7ce3061a1..f6e07303b 100644 --- a/numpy/distutils/tests/swig_ext/setup.py +++ b/numpy/distutils/tests/swig_ext/setup.py @@ -3,12 +3,12 @@ from __future__ import division, print_function def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('swig_ext',parent_package,top_path) + config = Configuration('swig_ext', parent_package, top_path) config.add_extension('_example', - ['src/example.i','src/example.c'] + ['src/example.i', 'src/example.c'] ) config.add_extension('_example2', - ['src/zoo.i','src/zoo.cc'], + ['src/zoo.i', 'src/zoo.cc'], depends=['src/zoo.h'], include_dirs=['src'] ) diff --git a/numpy/distutils/tests/swig_ext/tests/test_example.py b/numpy/distutils/tests/swig_ext/tests/test_example.py index 3164c0831..e81f98b1d 100644 --- a/numpy/distutils/tests/swig_ext/tests/test_example.py +++ b/numpy/distutils/tests/swig_ext/tests/test_example.py @@ -6,12 +6,12 @@ from swig_ext import example class TestExample(TestCase): def test_fact(self): - assert_equal(example.fact(10),3628800) + assert_equal(example.fact(10), 3628800) def test_cvar(self): - assert_equal(example.cvar.My_variable,3.0) + assert_equal(example.cvar.My_variable, 3.0) example.cvar.My_variable = 5 - assert_equal(example.cvar.My_variable,5.0) + assert_equal(example.cvar.My_variable, 5.0) if __name__ == "__main__": diff --git a/numpy/distutils/tests/test_misc_util.py b/numpy/distutils/tests/test_misc_util.py index 33b6b1213..fd6af638f 100644 --- a/numpy/distutils/tests/test_misc_util.py +++ b/numpy/distutils/tests/test_misc_util.py @@ -11,49 +11,49 @@ ajoin = lambda *paths: join(*((sep,)+paths)) class TestAppendpath(TestCase): def test_1(self): - assert_equal(appendpath('prefix','name'),join('prefix','name')) - assert_equal(appendpath('/prefix','name'),ajoin('prefix','name')) - assert_equal(appendpath('/prefix','/name'),ajoin('prefix','name')) - assert_equal(appendpath('prefix','/name'),join('prefix','name')) + assert_equal(appendpath('prefix', 'name'), join('prefix', 'name')) + assert_equal(appendpath('/prefix', 'name'), ajoin('prefix', 'name')) + assert_equal(appendpath('/prefix', '/name'), ajoin('prefix', 'name')) + assert_equal(appendpath('prefix', '/name'), join('prefix', 'name')) def test_2(self): - assert_equal(appendpath('prefix/sub','name'), - join('prefix','sub','name')) - assert_equal(appendpath('prefix/sub','sup/name'), - join('prefix','sub','sup','name')) - assert_equal(appendpath('/prefix/sub','/prefix/name'), - ajoin('prefix','sub','name')) + assert_equal(appendpath('prefix/sub', 'name'), + join('prefix', 'sub', 'name')) + assert_equal(appendpath('prefix/sub', 'sup/name'), + join('prefix', 'sub', 'sup', 'name')) + assert_equal(appendpath('/prefix/sub', '/prefix/name'), + ajoin('prefix', 'sub', 'name')) def test_3(self): - assert_equal(appendpath('/prefix/sub','/prefix/sup/name'), - ajoin('prefix','sub','sup','name')) - assert_equal(appendpath('/prefix/sub/sub2','/prefix/sup/sup2/name'), - ajoin('prefix','sub','sub2','sup','sup2','name')) - assert_equal(appendpath('/prefix/sub/sub2','/prefix/sub/sup/name'), - ajoin('prefix','sub','sub2','sup','name')) + assert_equal(appendpath('/prefix/sub', '/prefix/sup/name'), + ajoin('prefix', 'sub', 'sup', 'name')) + assert_equal(appendpath('/prefix/sub/sub2', '/prefix/sup/sup2/name'), + ajoin('prefix', 'sub', 'sub2', 'sup', 'sup2', 'name')) + assert_equal(appendpath('/prefix/sub/sub2', '/prefix/sub/sup/name'), + ajoin('prefix', 'sub', 'sub2', 'sup', 'name')) class TestMinrelpath(TestCase): def test_1(self): - n = lambda path: path.replace('/',sep) - assert_equal(minrelpath(n('aa/bb')),n('aa/bb')) - assert_equal(minrelpath('..'),'..') - assert_equal(minrelpath(n('aa/..')),'') - assert_equal(minrelpath(n('aa/../bb')),'bb') - assert_equal(minrelpath(n('aa/bb/..')),'aa') - assert_equal(minrelpath(n('aa/bb/../..')),'') - assert_equal(minrelpath(n('aa/bb/../cc/../dd')),n('aa/dd')) - assert_equal(minrelpath(n('.././..')),n('../..')) - assert_equal(minrelpath(n('aa/bb/.././../dd')),n('dd')) + n = lambda path: path.replace('/', sep) + assert_equal(minrelpath(n('aa/bb')), n('aa/bb')) + assert_equal(minrelpath('..'), '..') + assert_equal(minrelpath(n('aa/..')), '') + assert_equal(minrelpath(n('aa/../bb')), 'bb') + assert_equal(minrelpath(n('aa/bb/..')), 'aa') + assert_equal(minrelpath(n('aa/bb/../..')), '') + assert_equal(minrelpath(n('aa/bb/../cc/../dd')), n('aa/dd')) + assert_equal(minrelpath(n('.././..')), n('../..')) + assert_equal(minrelpath(n('aa/bb/.././../dd')), n('dd')) class TestGpaths(TestCase): def test_gpaths(self): - local_path = minrelpath(join(dirname(__file__),'..')) + local_path = minrelpath(join(dirname(__file__), '..')) ls = gpaths('command/*.py', local_path) - assert_(join(local_path,'command','build_src.py') in ls,repr(ls)) + assert_(join(local_path, 'command', 'build_src.py') in ls, repr(ls)) f = gpaths('system_info.py', local_path) - assert_(join(local_path,'system_info.py')==f[0],repr(f)) + assert_(join(local_path, 'system_info.py')==f[0], repr(f)) class TestSharedExtension(TestCase): diff --git a/numpy/distutils/unixccompiler.py b/numpy/distutils/unixccompiler.py index 95b676ecf..955407aa0 100644 --- a/numpy/distutils/unixccompiler.py +++ b/numpy/distutils/unixccompiler.py @@ -31,7 +31,7 @@ def UnixCCompiler__compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts ccomp += ['-AA'] self.compiler_so = ccomp - display = '%s: %s' % (os.path.basename(self.compiler_so[0]),src) + display = '%s: %s' % (os.path.basename(self.compiler_so[0]), src) try: self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + extra_postargs, display = display) |
