[ { "hash": "b04d9606250f384bce67acd98c9accb20dbeb7fa", "msg": "Workaround for missing __cvs_version__ which is available only in MAIN branch", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-02T11:10:37+00:00", "author_timezone": 0, "committer_date": "2004-02-02T11:10:37+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "90f033bea18a08bbbeef9f83cb3d8b9011b85477" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 3, "insertions": 8, "lines": 11, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/scipy_distutils_version.py", "new_path": "scipy_distutils/scipy_distutils_version.py", "filename": "scipy_distutils_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,9 +3,14 @@\n micro = 2\n release_level = 'alpha'\n \n-from __cvs_version__ import cvs_version\n-cvs_minor = cvs_version[-3]\n-cvs_serial = cvs_version[-1]\n+try:\n+ from __cvs_version__ import cvs_version\n+ cvs_minor = cvs_version[-3]\n+ cvs_serial = cvs_version[-1]\n+except ImportError,msg:\n+ print msg\n+ cvs_minor = 0\n+ cvs_serial = 0\n \n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "added_lines": 8, "deleted_lines": 3, "source_code": "major = 0\nminor = 2\nmicro = 2\nrelease_level = 'alpha'\n\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nscipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "source_code_before": "major = 0\nminor = 2\nmicro = 2\nrelease_level = 'alpha'\n\nfrom __cvs_version__ import cvs_version\ncvs_minor = cvs_version[-3]\ncvs_serial = cvs_version[-1]\n\nscipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 14, "complexity": 0, "token_count": 56, "diff_parsed": { "added": [ "try:", " from __cvs_version__ import cvs_version", " cvs_minor = cvs_version[-3]", " cvs_serial = cvs_version[-1]", "except ImportError,msg:", " print msg", " cvs_minor = 0", " cvs_serial = 0" ], "deleted": [ "from __cvs_version__ import cvs_version", "cvs_minor = cvs_version[-3]", "cvs_serial = cvs_version[-1]" ] } } ] }, { "hash": "59c6f7c8809104ffcc97e2083529ae4111b41755", "msg": "Fixed use_tee=0 case for cygwin", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-02T11:11:26+00:00", "author_timezone": 0, "committer_date": "2004-02-02T11:11:26+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "b04d9606250f384bce67acd98c9accb20dbeb7fa" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 22, "insertions": 28, "lines": 50, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/exec_command.py", "new_path": "scipy_distutils/exec_command.py", "filename": "exec_command.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -197,7 +197,6 @@ def exec_command( command,\n use_tee = os.name=='posix'\n if use_shell is None:\n use_shell = os.name=='posix'\n-\n execute_in = os.path.abspath(execute_in)\n oldcwd = os.path.abspath(os.getcwd())\n \n@@ -260,6 +259,7 @@ def _exec_command_posix( command,\n command_str = command\n \n tmpfile = tempfile.mktemp()\n+ stsfile = None\n if use_tee:\n stsfile = tempfile.mktemp()\n filter = ''\n@@ -268,7 +268,10 @@ def _exec_command_posix( command,\n command_posix = '( %s ; echo $? > %s ) 2>&1 | tee %s %s'\\\n % (command_str,stsfile,tmpfile,filter)\n else:\n- command_posix = '%s > %s 2>&1' % (command_str,tmpfile)\n+ stsfile = tempfile.mktemp()\n+ command_posix = '( %s ; echo $? > %s ) > %s 2>&1'\\\n+ % (command_str,stsfile,tmpfile)\n+ #command_posix = '( %s ) > %s 2>&1' % (command_str,tmpfile)\n \n log.debug('Running os.system(%r)' % (command_posix))\n status = os.system(command_posix)\n@@ -278,6 +281,7 @@ def _exec_command_posix( command,\n # if command_tee fails then fall back to robust exec_command\n log.warn('_exec_command_posix failed (status=%s)' % status)\n return _exec_command(command, use_shell=use_shell, **env)\n+ if stsfile is not None:\n f = open(stsfile,'r')\n status = int(f.read())\n f.close()\n@@ -482,55 +486,55 @@ def test_nt():\n \n print 'ok'\n \n-def test_posix():\n- s,o=exec_command(\"echo Hello\")\n+def test_posix(**kws):\n+ s,o=exec_command(\"echo Hello\",**kws)\n assert s==0 and o=='Hello',(s,o)\n \n- s,o=exec_command('echo $AAA')\n+ s,o=exec_command('echo $AAA',**kws)\n assert s==0 and o=='',(s,o)\n \n- s,o=exec_command('echo \"$AAA\"',AAA='Tere')\n+ s,o=exec_command('echo \"$AAA\"',AAA='Tere',**kws)\n assert s==0 and o=='Tere',(s,o)\n \n \n- s,o=exec_command('echo \"$AAA\"')\n+ s,o=exec_command('echo \"$AAA\"',**kws)\n assert s==0 and o=='',(s,o)\n \n os.environ['BBB'] = 'Hi'\n- s,o=exec_command('echo \"$BBB\"')\n+ s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n \n- s,o=exec_command('echo \"$BBB\"',BBB='Hey')\n+ s,o=exec_command('echo \"$BBB\"',BBB='Hey',**kws)\n assert s==0 and o=='Hey',(s,o)\n \n- s,o=exec_command('echo \"$BBB\"')\n+ s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n \n \n- s,o=exec_command('this_is_not_a_command')\n+ s,o=exec_command('this_is_not_a_command',**kws)\n assert s!=0 and o!='',(s,o)\n \n- s,o=exec_command('echo path=$PATH')\n+ s,o=exec_command('echo path=$PATH',**kws)\n assert s==0 and o!='',(s,o)\n \n- s,o=exec_command('python -c \"import sys,os;sys.stderr.write(os.name)\"')\n+ s,o=exec_command('python -c \"import sys,os;sys.stderr.write(os.name)\"',**kws)\n assert s==0 and o=='posix',(s,o)\n \n- s,o=exec_command('python -c \"raise \\'Ignore me.\\'\"')\n+ s,o=exec_command('python -c \"raise \\'Ignore me.\\'\"',**kws)\n assert s==1 and o,(s,o)\n \n- s,o=exec_command('python -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"')\n+ s,o=exec_command('python -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"',**kws)\n assert s==0 and o=='012',(s,o)\n \n- s,o=exec_command('python -c \"import sys;sys.exit(15)\"')\n+ s,o=exec_command('python -c \"import sys;sys.exit(15)\"',**kws)\n assert s==15 and o=='',(s,o)\n \n- s,o=exec_command('python -c \"print \\'Heipa\\'\"')\n+ s,o=exec_command('python -c \"print \\'Heipa\\'\"',**kws)\n assert s==0 and o=='Heipa',(s,o)\n \n print 'ok'\n \n-def test_execute_in():\n+def test_execute_in(**kws):\n pythonexe = get_pythonexe()\n tmpfile = tempfile.mktemp()\n fn = os.path.basename(tmpfile)\n@@ -540,10 +544,10 @@ def test_execute_in():\n f.close()\n \n s,o = exec_command('%s -c \"print \\'Ignore following IOError:\\',open(%r,\\'r\\')\"' \\\n- % (pythonexe,fn))\n+ % (pythonexe,fn),**kws)\n assert s and o!='',(s,o)\n s,o = exec_command('%s -c \"print open(%r,\\'r\\').read()\"' % (pythonexe,fn),\n- execute_in = tmpdir)\n+ execute_in = tmpdir,**kws)\n assert s==0 and o=='Hello',(s,o)\n os.remove(tmpfile)\n print 'ok'\n@@ -562,5 +566,7 @@ def test_execute_in():\n log.setLevel(logging.DEBUG)\n \n test_splitcmdline()\n- test()\n- test_execute_in()\n+ test(use_tee=0)\n+ test(use_tee=1)\n+ test_execute_in(use_tee=0)\n+ test_execute_in(use_tee=1)\n", "added_lines": 28, "deleted_lines": 22, "source_code": "#!/usr/bin/env python\n#\n# exec_command\n#\n# Implements exec_command function that is (almost) equivalent to\n# commands.getstatusoutput function but on NT, DOS systems the\n# returned status is actually correct (though, the returned status\n# values may be different by a factor). In addition, exec_command\n# takes keyword arguments for (re-)defining environment variables.\n#\n# Provides functions:\n# exec_command --- execute command in a specified directory and\n# in the modified environment.\n# splitcmdline --- inverse of ' '.join(argv)\n# find_executable --- locate a command using info from environment\n# variable PATH. Equivalent to posix `which`\n# command.\n#\n# Author: Pearu Peterson \n# Created: 11 January 2003\n#\n# Requires: Python 2.x\n#\n# Succesfully tested on:\n# os.name | sys.platform | comments\n# --------+--------------+----------\n# posix | linux2 | Debian (sid) Linux, Python 2.1.3+, 2.2.3+, 2.3.3\n# PyCrust 0.9.3, Idle 1.0.2\n# posix | linux2 | Red Hat 9 Linux, Python 2.1.3, 2.2.2, 2.3.2\n# posix | sunos5 | SunOS 5.9, Python 2.2, 2.3.2\n# posix | darwin | Darwin 7.2.0, Python 2.3\n# nt | win32 | Windows Me\n# Python 2.3(EE), Idle 1.0, PyCrust 0.7.2\n# Python 2.1.1 Idle 0.8\n# nt | win32 | Windows 98, Python 2.1.1. Idle 0.8\n# nt | win32 | Cygwin 98-4.10, Python 2.1.1(MSC) - echo tests\n# fail i.e. redefining environment variables may\n# not work. FIXED: don't use cygwin echo!\n# posix | cygwin | Cygwin 98-4.10, Python 2.3.3(cygming special)\n\n__all__ = ['exec_command','find_executable']\n\nimport os\nimport re\nimport sys\nimport tempfile\n\n############################################################\n\ntry:\n import logging\n log = logging.getLogger('exec_command')\nexcept ImportError:\n class logging:\n DEBUG = 0\n def info(self,message): print 'info:',message\n def warn(self,message): print 'warn:',message\n def debug(self,message): print 'debug:',message\n def basicConfig(self): pass\n def setLevel(self,level): pass\n log = logging = logging()\n\n############################################################\n\ndef get_pythonexe():\n pythonexe = sys.executable\n if os.name in ['nt','dos']:\n fdir,fn = os.path.split(pythonexe)\n fn = fn.upper().replace('PYTHONW','PYTHON')\n pythonexe = os.path.join(fdir,fn)\n assert os.path.isfile(pythonexe),`pythonexe`+' is not a file'\n return pythonexe\n\n############################################################\n\ndef splitcmdline(line):\n \"\"\" Inverse of ' '.join(sys.argv).\n \"\"\"\n log.info('splitcmdline(%r)' % (line))\n lst = []\n flag = 0\n s,pc,cc = '','',''\n for nc in line+' ':\n if flag==0:\n flag = (pc != '\\\\' and \\\n ((cc=='\"' and 1) or (cc==\"'\" and 2) or \\\n (cc==' ' and pc!=' ' and -2))) or flag\n elif flag==1:\n flag = (cc=='\"' and pc!='\\\\' and nc==' ' and -1) or flag\n elif flag==2:\n flag = (cc==\"'\" and pc!='\\\\' and nc==' ' and -1) or flag\n if flag!=-2:\n s += cc\n if flag<0:\n flag = 0\n s = s.strip()\n if s:\n lst.append(s)\n s = ''\n pc,cc = cc,nc\n else:\n s = s.strip()\n if s:\n lst.append(s)\n log.debug('splitcmdline -> %r' % (lst))\n return lst\n\ndef test_splitcmdline():\n l = splitcmdline('a b cc')\n assert l==['a','b','cc'],`l`\n l = splitcmdline('a')\n assert l==['a'],`l`\n l = splitcmdline('a \" b cc\"')\n assert l==['a','\" b cc\"'],`l`\n l = splitcmdline('\"a bcc\" -h')\n assert l==['\"a bcc\"','-h'],`l`\n l = splitcmdline(r'\"\\\"a \\\" bcc\" -h')\n assert l==[r'\"\\\"a \\\" bcc\"','-h'],`l`\n l = splitcmdline(\" 'a bcc' -h\")\n assert l==[\"'a bcc'\",'-h'],`l`\n l = splitcmdline(r\"'\\'a \\' bcc' -h\")\n assert l==[r\"'\\'a \\' bcc'\",'-h'],`l`\n\n############################################################\n\ndef find_executable(exe, path=None):\n \"\"\" Return full path of a executable.\n \"\"\"\n log.info('find_executable(%r)' % exe)\n if path is None:\n path = os.environ.get('PATH',os.defpath)\n suffices = ['']\n if os.name in ['nt','dos','os2']:\n fn,ext = os.path.splitext(exe)\n extra_suffices = ['.exe','.com','.bat']\n if ext.lower() not in extra_suffices:\n suffices = extra_suffices\n if os.path.isabs(exe):\n paths = ['']\n else:\n paths = map(os.path.abspath, path.split(os.pathsep))\n if os.name == 'nt':\n # Remove cygwin path components\n new_paths = []\n for path in paths:\n d,p = os.path.splitdrive(path)\n if p.lower().find('cygwin') >= 0:\n log.debug('removing \"%s\" from PATH' % (path))\n else:\n new_paths.append(path)\n paths = new_paths\n for path in paths:\n fn = os.path.join(path,exe)\n for s in suffices:\n f_ext = fn+s\n if os.path.isfile(f_ext) and os.access(f_ext,os.X_OK):\n log.debug('Found executable %s' % f_ext)\n return f_ext\n if not os.path.isfile(exe) or os.access(exe,os.X_OK):\n log.warn('Could not locate executable %s' % exe)\n return exe\n\n############################################################\n\ndef _preserve_environment( names ):\n log.debug('_preserve_environment(%r)' % (names))\n env = {}\n for name in names:\n env[name] = os.environ.get(name)\n return env\n\ndef _update_environment( **env ):\n log.debug('_update_environment(...)')\n for name,value in env.items():\n os.environ[name] = value or ''\n\ndef exec_command( command,\n execute_in='', use_shell=None, use_tee = None,\n _with_python = 1,\n **env ):\n \"\"\" Return (status,output) of executed command.\n\n command is a concatenated string of executable and arguments.\n The output contains both stdout and stderr messages.\n The following special keyword arguments can be used:\n use_shell - execute `sh -c command`\n use_tee - pipe the output of command through tee\n execute_in - before command `cd execute_in` and after `cd -`.\n\n On NT, DOS systems the returned status is correct for external commands.\n Wild cards will not work for non-posix systems or when use_shell=0.\n \"\"\"\n log.info('exec_command(%r,%s)' % (command,\\\n ','.join(['%s=%r'%kv for kv in env.items()])))\n\n if use_tee is None:\n use_tee = os.name=='posix'\n if use_shell is None:\n use_shell = os.name=='posix'\n execute_in = os.path.abspath(execute_in)\n oldcwd = os.path.abspath(os.getcwd())\n\n if __name__[-12:] == 'exec_command':\n exec_dir = os.path.dirname(os.path.abspath(__file__))\n elif os.path.isfile('exec_command.py'):\n exec_dir = os.path.abspath('.')\n else:\n exec_dir = os.path.abspath(sys.argv[0])\n if os.path.isfile(exec_dir):\n exec_dir = os.path.dirname(exec_dir)\n\n if oldcwd!=execute_in:\n os.chdir(execute_in)\n log.debug('New cwd: %s' % execute_in)\n else:\n log.debug('Retaining cwd: %s' % oldcwd)\n\n oldenv = _preserve_environment( env.keys() )\n _update_environment( **env )\n\n try:\n # _exec_command is robust but slow, it relies on\n # usable sys.std*.fileno() descriptors. If they\n # are bad (like in win32 Idle, PyCrust environments)\n # then _exec_command_python (even slower)\n # will be used as a last resort.\n #\n # _exec_command_posix uses os.system and is faster\n # but not on all platforms os.system will return\n # a correct status.\n if _with_python and (0 or sys.__stdout__.fileno()==-1):\n st = _exec_command_python(command,\n exec_command_dir = exec_dir,\n **env)\n elif os.name=='posix' and sys.platform[:5]!='sunos':\n st = _exec_command_posix(command,\n use_shell=use_shell,\n use_tee=use_tee,\n **env)\n else:\n st = _exec_command(command, use_shell=use_shell, **env)\n finally:\n if oldcwd!=execute_in:\n os.chdir(oldcwd)\n log.debug('Restored cwd to %s' % oldcwd)\n _update_environment(**oldenv)\n\n return st\n\ndef _exec_command_posix( command,\n use_shell = None,\n use_tee = None,\n **env ):\n log.debug('_exec_command_posix(...)')\n\n if type(command) is type([]):\n command_str = ' '.join(command)\n else:\n command_str = command\n\n tmpfile = tempfile.mktemp()\n stsfile = None\n if use_tee:\n stsfile = tempfile.mktemp()\n filter = ''\n if use_tee == 2:\n filter = r'| tr -cd \"\\n\" | tr \"\\n\" \".\"; echo'\n command_posix = '( %s ; echo $? > %s ) 2>&1 | tee %s %s'\\\n % (command_str,stsfile,tmpfile,filter)\n else:\n stsfile = tempfile.mktemp()\n command_posix = '( %s ; echo $? > %s ) > %s 2>&1'\\\n % (command_str,stsfile,tmpfile)\n #command_posix = '( %s ) > %s 2>&1' % (command_str,tmpfile)\n\n log.debug('Running os.system(%r)' % (command_posix))\n status = os.system(command_posix)\n\n if use_tee:\n if status:\n # if command_tee fails then fall back to robust exec_command\n log.warn('_exec_command_posix failed (status=%s)' % status)\n return _exec_command(command, use_shell=use_shell, **env)\n if stsfile is not None:\n f = open(stsfile,'r')\n status = int(f.read())\n f.close()\n os.remove(stsfile)\n\n f = open(tmpfile,'r')\n text = f.read()\n f.close()\n os.remove(tmpfile)\n\n if text[-1:]=='\\n':\n text = text[:-1]\n \n return status, text\n\n\ndef _exec_command_python(command,\n exec_command_dir='', **env):\n log.debug('_exec_command_python(...)')\n\n python_exe = get_pythonexe()\n cmdfile = tempfile.mktemp()\n stsfile = tempfile.mktemp()\n outfile = tempfile.mktemp()\n\n f = open(cmdfile,'w')\n f.write('import os\\n')\n f.write('import sys\\n')\n f.write('sys.path.insert(0,%r)\\n' % (exec_command_dir))\n f.write('from exec_command import exec_command\\n')\n f.write('del sys.path[0]\\n')\n f.write('cmd = %r\\n' % command)\n f.write('os.environ = %r\\n' % (os.environ))\n f.write('s,o = exec_command(cmd, _with_python=0, **%r)\\n' % (env))\n f.write('f=open(%r,\"w\")\\nf.write(str(s))\\nf.close()\\n' % (stsfile))\n f.write('f=open(%r,\"w\")\\nf.write(o)\\nf.close()\\n' % (outfile))\n f.close()\n\n cmd = '%s %s' % (python_exe, cmdfile)\n status = os.system(cmd)\n assert not status,`cmd`+' failed'\n os.remove(cmdfile)\n\n f = open(stsfile,'r')\n status = int(f.read())\n f.close()\n os.remove(stsfile)\n \n f = open(outfile,'r')\n text = f.read()\n f.close()\n os.remove(outfile)\n \n return status, text\n\n\ndef _exec_command( command, use_shell=None, **env ):\n log.debug('_exec_command(...)')\n \n if use_shell is None:\n use_shell = os.name=='posix'\n\n using_command = 0\n if use_shell:\n # We use shell (unless use_shell==0) so that wildcards can be\n # used.\n sh = os.environ.get('SHELL','/bin/sh')\n if type(command) is type([]):\n argv = [sh,'-c'] + command\n else:\n argv = [sh,'-c',command]\n else:\n # On NT, DOS we avoid using command.com as it's exit status is\n # not related to the exit status of a command.\n if type(command) is type([]):\n argv = command[:]\n else:\n argv = splitcmdline(command)\n \n if hasattr(os,'spawnvpe'):\n spawn_command = os.spawnvpe\n else:\n spawn_command = os.spawnve\n argv[0] = find_executable(argv[0])\n if not os.path.isfile(argv[0]):\n log.warn('Executable %s does not exist' % (argv[0]))\n if os.name in ['nt','dos']:\n # argv[0] might be internal command\n argv = [os.environ['COMSPEC'],'/C']+argv\n using_command = 1\n\n # sys.__std*__ is used instead of sys.std* because environments\n # like IDLE, PyCrust, etc overwrite sys.std* commands.\n so_fileno = sys.__stdout__.fileno()\n se_fileno = sys.__stderr__.fileno()\n so_flush = sys.__stdout__.flush\n se_flush = sys.__stderr__.flush\n so_dup = os.dup(so_fileno)\n se_dup = os.dup(se_fileno)\n\n outfile = tempfile.mktemp()\n fout = open(outfile,'w')\n if using_command:\n errfile = tempfile.mktemp()\n ferr = open(errfile,'w')\n\n log.debug('Running %s(%s,%r,%r,os.environ)' \\\n % (spawn_command.__name__,os.P_WAIT,argv[0],argv))\n\n so_flush()\n se_flush()\n os.dup2(fout.fileno(),so_fileno)\n if using_command:\n os.dup2(ferr.fileno(),se_fileno)\n else:\n os.dup2(fout.fileno(),se_fileno)\n\n try:\n status = spawn_command(os.P_WAIT,argv[0],argv,os.environ)\n except OSError,errmess:\n status = 999\n sys.stderr.write('%s: %s'%(errmess,argv[0]))\n\n so_flush()\n se_flush()\n os.dup2(so_dup,so_fileno)\n os.dup2(se_dup,se_fileno)\n\n fout.close()\n fout = open(outfile,'r')\n text = fout.read()\n fout.close()\n os.remove(outfile)\n\n if using_command:\n ferr.close()\n ferr = open(errfile,'r')\n errmess = ferr.read()\n ferr.close()\n os.remove(errfile)\n if errmess and not status:\n status = 998\n if text:\n text = text + '\\n'\n text = '%sCOMMAND %r FAILED: %s' %(text,command,errmess)\n\n if text[-1:]=='\\n':\n text = text[:-1]\n if status is None:\n status = 0\n\n return status, text\n\n\ndef test_nt():\n pythonexe = get_pythonexe()\n\n if 1: ## not (sys.platform=='win32' and os.environ.get('OSTYPE','')=='cygwin'):\n s,o=exec_command('echo Hello')\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo a%AAA%')\n assert s==0 and o=='a',(s,o)\n\n s,o=exec_command('echo a%AAA%',AAA='Tere')\n assert s==0 and o=='aTere',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('echo a%BBB%',BBB='Hey')\n assert s==0 and o=='aHey', (s,o)\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('this_is_not_a_command')\n assert s and o!='',(s,o)\n\n s,o=exec_command('type not_existing_file')\n assert s and o!='',(s,o)\n\n s,o=exec_command('echo path=%path%')\n assert s==0 and o!='',(s,o)\n \n s,o=exec_command('%s -c \"import sys;sys.stderr.write(sys.platform)\"' \\\n % pythonexe)\n assert s==0 and o=='win32',(s,o)\n\n s,o=exec_command('%s -c \"raise \\'Ignore me.\\'\"' % pythonexe)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"'\\\n % pythonexe)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.exit(15)\"' % pythonexe)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('%s -c \"print \\'Heipa\\'\"' % pythonexe)\n assert s==0 and o=='Heipa',(s,o)\n\n print 'ok'\n\ndef test_posix(**kws):\n s,o=exec_command(\"echo Hello\",**kws)\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo $AAA',**kws)\n assert s==0 and o=='',(s,o)\n\n s,o=exec_command('echo \"$AAA\"',AAA='Tere',**kws)\n assert s==0 and o=='Tere',(s,o)\n\n\n s,o=exec_command('echo \"$AAA\"',**kws)\n assert s==0 and o=='',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',BBB='Hey',**kws)\n assert s==0 and o=='Hey',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n\n s,o=exec_command('this_is_not_a_command',**kws)\n assert s!=0 and o!='',(s,o)\n\n s,o=exec_command('echo path=$PATH',**kws)\n assert s==0 and o!='',(s,o)\n \n s,o=exec_command('python -c \"import sys,os;sys.stderr.write(os.name)\"',**kws)\n assert s==0 and o=='posix',(s,o)\n\n s,o=exec_command('python -c \"raise \\'Ignore me.\\'\"',**kws)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"',**kws)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.exit(15)\"',**kws)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('python -c \"print \\'Heipa\\'\"',**kws)\n assert s==0 and o=='Heipa',(s,o)\n \n print 'ok'\n\ndef test_execute_in(**kws):\n pythonexe = get_pythonexe()\n tmpfile = tempfile.mktemp()\n fn = os.path.basename(tmpfile)\n tmpdir = os.path.dirname(tmpfile)\n f = open(tmpfile,'w')\n f.write('Hello')\n f.close()\n\n s,o = exec_command('%s -c \"print \\'Ignore following IOError:\\',open(%r,\\'r\\')\"' \\\n % (pythonexe,fn),**kws)\n assert s and o!='',(s,o)\n s,o = exec_command('%s -c \"print open(%r,\\'r\\').read()\"' % (pythonexe,fn),\n execute_in = tmpdir,**kws)\n assert s==0 and o=='Hello',(s,o)\n os.remove(tmpfile)\n print 'ok'\n\nif os.name=='posix':\n test = test_posix\nelif os.name in ['nt','dos']:\n test = test_nt\nelse:\n raise NotImplementedError,'exec_command tests for '+os.name\n\n############################################################\n\nif __name__ == \"__main__\":\n logging.basicConfig()\n log.setLevel(logging.DEBUG)\n\n test_splitcmdline()\n test(use_tee=0)\n test(use_tee=1)\n test_execute_in(use_tee=0)\n test_execute_in(use_tee=1)\n", "source_code_before": "#!/usr/bin/env python\n#\n# exec_command\n#\n# Implements exec_command function that is (almost) equivalent to\n# commands.getstatusoutput function but on NT, DOS systems the\n# returned status is actually correct (though, the returned status\n# values may be different by a factor). In addition, exec_command\n# takes keyword arguments for (re-)defining environment variables.\n#\n# Provides functions:\n# exec_command --- execute command in a specified directory and\n# in the modified environment.\n# splitcmdline --- inverse of ' '.join(argv)\n# find_executable --- locate a command using info from environment\n# variable PATH. Equivalent to posix `which`\n# command.\n#\n# Author: Pearu Peterson \n# Created: 11 January 2003\n#\n# Requires: Python 2.x\n#\n# Succesfully tested on:\n# os.name | sys.platform | comments\n# --------+--------------+----------\n# posix | linux2 | Debian (sid) Linux, Python 2.1.3+, 2.2.3+, 2.3.3\n# PyCrust 0.9.3, Idle 1.0.2\n# posix | linux2 | Red Hat 9 Linux, Python 2.1.3, 2.2.2, 2.3.2\n# posix | sunos5 | SunOS 5.9, Python 2.2, 2.3.2\n# posix | darwin | Darwin 7.2.0, Python 2.3\n# nt | win32 | Windows Me\n# Python 2.3(EE), Idle 1.0, PyCrust 0.7.2\n# Python 2.1.1 Idle 0.8\n# nt | win32 | Windows 98, Python 2.1.1. Idle 0.8\n# nt | win32 | Cygwin 98-4.10, Python 2.1.1(MSC) - echo tests\n# fail i.e. redefining environment variables may\n# not work. FIXED: don't use cygwin echo!\n# posix | cygwin | Cygwin 98-4.10, Python 2.3.3(cygming special)\n\n__all__ = ['exec_command','find_executable']\n\nimport os\nimport re\nimport sys\nimport tempfile\n\n############################################################\n\ntry:\n import logging\n log = logging.getLogger('exec_command')\nexcept ImportError:\n class logging:\n DEBUG = 0\n def info(self,message): print 'info:',message\n def warn(self,message): print 'warn:',message\n def debug(self,message): print 'debug:',message\n def basicConfig(self): pass\n def setLevel(self,level): pass\n log = logging = logging()\n\n############################################################\n\ndef get_pythonexe():\n pythonexe = sys.executable\n if os.name in ['nt','dos']:\n fdir,fn = os.path.split(pythonexe)\n fn = fn.upper().replace('PYTHONW','PYTHON')\n pythonexe = os.path.join(fdir,fn)\n assert os.path.isfile(pythonexe),`pythonexe`+' is not a file'\n return pythonexe\n\n############################################################\n\ndef splitcmdline(line):\n \"\"\" Inverse of ' '.join(sys.argv).\n \"\"\"\n log.info('splitcmdline(%r)' % (line))\n lst = []\n flag = 0\n s,pc,cc = '','',''\n for nc in line+' ':\n if flag==0:\n flag = (pc != '\\\\' and \\\n ((cc=='\"' and 1) or (cc==\"'\" and 2) or \\\n (cc==' ' and pc!=' ' and -2))) or flag\n elif flag==1:\n flag = (cc=='\"' and pc!='\\\\' and nc==' ' and -1) or flag\n elif flag==2:\n flag = (cc==\"'\" and pc!='\\\\' and nc==' ' and -1) or flag\n if flag!=-2:\n s += cc\n if flag<0:\n flag = 0\n s = s.strip()\n if s:\n lst.append(s)\n s = ''\n pc,cc = cc,nc\n else:\n s = s.strip()\n if s:\n lst.append(s)\n log.debug('splitcmdline -> %r' % (lst))\n return lst\n\ndef test_splitcmdline():\n l = splitcmdline('a b cc')\n assert l==['a','b','cc'],`l`\n l = splitcmdline('a')\n assert l==['a'],`l`\n l = splitcmdline('a \" b cc\"')\n assert l==['a','\" b cc\"'],`l`\n l = splitcmdline('\"a bcc\" -h')\n assert l==['\"a bcc\"','-h'],`l`\n l = splitcmdline(r'\"\\\"a \\\" bcc\" -h')\n assert l==[r'\"\\\"a \\\" bcc\"','-h'],`l`\n l = splitcmdline(\" 'a bcc' -h\")\n assert l==[\"'a bcc'\",'-h'],`l`\n l = splitcmdline(r\"'\\'a \\' bcc' -h\")\n assert l==[r\"'\\'a \\' bcc'\",'-h'],`l`\n\n############################################################\n\ndef find_executable(exe, path=None):\n \"\"\" Return full path of a executable.\n \"\"\"\n log.info('find_executable(%r)' % exe)\n if path is None:\n path = os.environ.get('PATH',os.defpath)\n suffices = ['']\n if os.name in ['nt','dos','os2']:\n fn,ext = os.path.splitext(exe)\n extra_suffices = ['.exe','.com','.bat']\n if ext.lower() not in extra_suffices:\n suffices = extra_suffices\n if os.path.isabs(exe):\n paths = ['']\n else:\n paths = map(os.path.abspath, path.split(os.pathsep))\n if os.name == 'nt':\n # Remove cygwin path components\n new_paths = []\n for path in paths:\n d,p = os.path.splitdrive(path)\n if p.lower().find('cygwin') >= 0:\n log.debug('removing \"%s\" from PATH' % (path))\n else:\n new_paths.append(path)\n paths = new_paths\n for path in paths:\n fn = os.path.join(path,exe)\n for s in suffices:\n f_ext = fn+s\n if os.path.isfile(f_ext) and os.access(f_ext,os.X_OK):\n log.debug('Found executable %s' % f_ext)\n return f_ext\n if not os.path.isfile(exe) or os.access(exe,os.X_OK):\n log.warn('Could not locate executable %s' % exe)\n return exe\n\n############################################################\n\ndef _preserve_environment( names ):\n log.debug('_preserve_environment(%r)' % (names))\n env = {}\n for name in names:\n env[name] = os.environ.get(name)\n return env\n\ndef _update_environment( **env ):\n log.debug('_update_environment(...)')\n for name,value in env.items():\n os.environ[name] = value or ''\n\ndef exec_command( command,\n execute_in='', use_shell=None, use_tee = None,\n _with_python = 1,\n **env ):\n \"\"\" Return (status,output) of executed command.\n\n command is a concatenated string of executable and arguments.\n The output contains both stdout and stderr messages.\n The following special keyword arguments can be used:\n use_shell - execute `sh -c command`\n use_tee - pipe the output of command through tee\n execute_in - before command `cd execute_in` and after `cd -`.\n\n On NT, DOS systems the returned status is correct for external commands.\n Wild cards will not work for non-posix systems or when use_shell=0.\n \"\"\"\n log.info('exec_command(%r,%s)' % (command,\\\n ','.join(['%s=%r'%kv for kv in env.items()])))\n\n if use_tee is None:\n use_tee = os.name=='posix'\n if use_shell is None:\n use_shell = os.name=='posix'\n\n execute_in = os.path.abspath(execute_in)\n oldcwd = os.path.abspath(os.getcwd())\n\n if __name__[-12:] == 'exec_command':\n exec_dir = os.path.dirname(os.path.abspath(__file__))\n elif os.path.isfile('exec_command.py'):\n exec_dir = os.path.abspath('.')\n else:\n exec_dir = os.path.abspath(sys.argv[0])\n if os.path.isfile(exec_dir):\n exec_dir = os.path.dirname(exec_dir)\n\n if oldcwd!=execute_in:\n os.chdir(execute_in)\n log.debug('New cwd: %s' % execute_in)\n else:\n log.debug('Retaining cwd: %s' % oldcwd)\n\n oldenv = _preserve_environment( env.keys() )\n _update_environment( **env )\n\n try:\n # _exec_command is robust but slow, it relies on\n # usable sys.std*.fileno() descriptors. If they\n # are bad (like in win32 Idle, PyCrust environments)\n # then _exec_command_python (even slower)\n # will be used as a last resort.\n #\n # _exec_command_posix uses os.system and is faster\n # but not on all platforms os.system will return\n # a correct status.\n if _with_python and (0 or sys.__stdout__.fileno()==-1):\n st = _exec_command_python(command,\n exec_command_dir = exec_dir,\n **env)\n elif os.name=='posix' and sys.platform[:5]!='sunos':\n st = _exec_command_posix(command,\n use_shell=use_shell,\n use_tee=use_tee,\n **env)\n else:\n st = _exec_command(command, use_shell=use_shell, **env)\n finally:\n if oldcwd!=execute_in:\n os.chdir(oldcwd)\n log.debug('Restored cwd to %s' % oldcwd)\n _update_environment(**oldenv)\n\n return st\n\ndef _exec_command_posix( command,\n use_shell = None,\n use_tee = None,\n **env ):\n log.debug('_exec_command_posix(...)')\n\n if type(command) is type([]):\n command_str = ' '.join(command)\n else:\n command_str = command\n\n tmpfile = tempfile.mktemp()\n if use_tee:\n stsfile = tempfile.mktemp()\n filter = ''\n if use_tee == 2:\n filter = r'| tr -cd \"\\n\" | tr \"\\n\" \".\"; echo'\n command_posix = '( %s ; echo $? > %s ) 2>&1 | tee %s %s'\\\n % (command_str,stsfile,tmpfile,filter)\n else:\n command_posix = '%s > %s 2>&1' % (command_str,tmpfile)\n\n log.debug('Running os.system(%r)' % (command_posix))\n status = os.system(command_posix)\n\n if use_tee:\n if status:\n # if command_tee fails then fall back to robust exec_command\n log.warn('_exec_command_posix failed (status=%s)' % status)\n return _exec_command(command, use_shell=use_shell, **env)\n f = open(stsfile,'r')\n status = int(f.read())\n f.close()\n os.remove(stsfile)\n\n f = open(tmpfile,'r')\n text = f.read()\n f.close()\n os.remove(tmpfile)\n\n if text[-1:]=='\\n':\n text = text[:-1]\n \n return status, text\n\n\ndef _exec_command_python(command,\n exec_command_dir='', **env):\n log.debug('_exec_command_python(...)')\n\n python_exe = get_pythonexe()\n cmdfile = tempfile.mktemp()\n stsfile = tempfile.mktemp()\n outfile = tempfile.mktemp()\n\n f = open(cmdfile,'w')\n f.write('import os\\n')\n f.write('import sys\\n')\n f.write('sys.path.insert(0,%r)\\n' % (exec_command_dir))\n f.write('from exec_command import exec_command\\n')\n f.write('del sys.path[0]\\n')\n f.write('cmd = %r\\n' % command)\n f.write('os.environ = %r\\n' % (os.environ))\n f.write('s,o = exec_command(cmd, _with_python=0, **%r)\\n' % (env))\n f.write('f=open(%r,\"w\")\\nf.write(str(s))\\nf.close()\\n' % (stsfile))\n f.write('f=open(%r,\"w\")\\nf.write(o)\\nf.close()\\n' % (outfile))\n f.close()\n\n cmd = '%s %s' % (python_exe, cmdfile)\n status = os.system(cmd)\n assert not status,`cmd`+' failed'\n os.remove(cmdfile)\n\n f = open(stsfile,'r')\n status = int(f.read())\n f.close()\n os.remove(stsfile)\n \n f = open(outfile,'r')\n text = f.read()\n f.close()\n os.remove(outfile)\n \n return status, text\n\n\ndef _exec_command( command, use_shell=None, **env ):\n log.debug('_exec_command(...)')\n \n if use_shell is None:\n use_shell = os.name=='posix'\n\n using_command = 0\n if use_shell:\n # We use shell (unless use_shell==0) so that wildcards can be\n # used.\n sh = os.environ.get('SHELL','/bin/sh')\n if type(command) is type([]):\n argv = [sh,'-c'] + command\n else:\n argv = [sh,'-c',command]\n else:\n # On NT, DOS we avoid using command.com as it's exit status is\n # not related to the exit status of a command.\n if type(command) is type([]):\n argv = command[:]\n else:\n argv = splitcmdline(command)\n \n if hasattr(os,'spawnvpe'):\n spawn_command = os.spawnvpe\n else:\n spawn_command = os.spawnve\n argv[0] = find_executable(argv[0])\n if not os.path.isfile(argv[0]):\n log.warn('Executable %s does not exist' % (argv[0]))\n if os.name in ['nt','dos']:\n # argv[0] might be internal command\n argv = [os.environ['COMSPEC'],'/C']+argv\n using_command = 1\n\n # sys.__std*__ is used instead of sys.std* because environments\n # like IDLE, PyCrust, etc overwrite sys.std* commands.\n so_fileno = sys.__stdout__.fileno()\n se_fileno = sys.__stderr__.fileno()\n so_flush = sys.__stdout__.flush\n se_flush = sys.__stderr__.flush\n so_dup = os.dup(so_fileno)\n se_dup = os.dup(se_fileno)\n\n outfile = tempfile.mktemp()\n fout = open(outfile,'w')\n if using_command:\n errfile = tempfile.mktemp()\n ferr = open(errfile,'w')\n\n log.debug('Running %s(%s,%r,%r,os.environ)' \\\n % (spawn_command.__name__,os.P_WAIT,argv[0],argv))\n\n so_flush()\n se_flush()\n os.dup2(fout.fileno(),so_fileno)\n if using_command:\n os.dup2(ferr.fileno(),se_fileno)\n else:\n os.dup2(fout.fileno(),se_fileno)\n\n try:\n status = spawn_command(os.P_WAIT,argv[0],argv,os.environ)\n except OSError,errmess:\n status = 999\n sys.stderr.write('%s: %s'%(errmess,argv[0]))\n\n so_flush()\n se_flush()\n os.dup2(so_dup,so_fileno)\n os.dup2(se_dup,se_fileno)\n\n fout.close()\n fout = open(outfile,'r')\n text = fout.read()\n fout.close()\n os.remove(outfile)\n\n if using_command:\n ferr.close()\n ferr = open(errfile,'r')\n errmess = ferr.read()\n ferr.close()\n os.remove(errfile)\n if errmess and not status:\n status = 998\n if text:\n text = text + '\\n'\n text = '%sCOMMAND %r FAILED: %s' %(text,command,errmess)\n\n if text[-1:]=='\\n':\n text = text[:-1]\n if status is None:\n status = 0\n\n return status, text\n\n\ndef test_nt():\n pythonexe = get_pythonexe()\n\n if 1: ## not (sys.platform=='win32' and os.environ.get('OSTYPE','')=='cygwin'):\n s,o=exec_command('echo Hello')\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo a%AAA%')\n assert s==0 and o=='a',(s,o)\n\n s,o=exec_command('echo a%AAA%',AAA='Tere')\n assert s==0 and o=='aTere',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('echo a%BBB%',BBB='Hey')\n assert s==0 and o=='aHey', (s,o)\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('this_is_not_a_command')\n assert s and o!='',(s,o)\n\n s,o=exec_command('type not_existing_file')\n assert s and o!='',(s,o)\n\n s,o=exec_command('echo path=%path%')\n assert s==0 and o!='',(s,o)\n \n s,o=exec_command('%s -c \"import sys;sys.stderr.write(sys.platform)\"' \\\n % pythonexe)\n assert s==0 and o=='win32',(s,o)\n\n s,o=exec_command('%s -c \"raise \\'Ignore me.\\'\"' % pythonexe)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"'\\\n % pythonexe)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.exit(15)\"' % pythonexe)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('%s -c \"print \\'Heipa\\'\"' % pythonexe)\n assert s==0 and o=='Heipa',(s,o)\n\n print 'ok'\n\ndef test_posix():\n s,o=exec_command(\"echo Hello\")\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo $AAA')\n assert s==0 and o=='',(s,o)\n\n s,o=exec_command('echo \"$AAA\"',AAA='Tere')\n assert s==0 and o=='Tere',(s,o)\n\n\n s,o=exec_command('echo \"$AAA\"')\n assert s==0 and o=='',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo \"$BBB\"')\n assert s==0 and o=='Hi',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',BBB='Hey')\n assert s==0 and o=='Hey',(s,o)\n\n s,o=exec_command('echo \"$BBB\"')\n assert s==0 and o=='Hi',(s,o)\n\n\n s,o=exec_command('this_is_not_a_command')\n assert s!=0 and o!='',(s,o)\n\n s,o=exec_command('echo path=$PATH')\n assert s==0 and o!='',(s,o)\n \n s,o=exec_command('python -c \"import sys,os;sys.stderr.write(os.name)\"')\n assert s==0 and o=='posix',(s,o)\n\n s,o=exec_command('python -c \"raise \\'Ignore me.\\'\"')\n assert s==1 and o,(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"')\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.exit(15)\"')\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('python -c \"print \\'Heipa\\'\"')\n assert s==0 and o=='Heipa',(s,o)\n \n print 'ok'\n\ndef test_execute_in():\n pythonexe = get_pythonexe()\n tmpfile = tempfile.mktemp()\n fn = os.path.basename(tmpfile)\n tmpdir = os.path.dirname(tmpfile)\n f = open(tmpfile,'w')\n f.write('Hello')\n f.close()\n\n s,o = exec_command('%s -c \"print \\'Ignore following IOError:\\',open(%r,\\'r\\')\"' \\\n % (pythonexe,fn))\n assert s and o!='',(s,o)\n s,o = exec_command('%s -c \"print open(%r,\\'r\\').read()\"' % (pythonexe,fn),\n execute_in = tmpdir)\n assert s==0 and o=='Hello',(s,o)\n os.remove(tmpfile)\n print 'ok'\n\nif os.name=='posix':\n test = test_posix\nelif os.name in ['nt','dos']:\n test = test_nt\nelse:\n raise NotImplementedError,'exec_command tests for '+os.name\n\n############################################################\n\nif __name__ == \"__main__\":\n logging.basicConfig()\n log.setLevel(logging.DEBUG)\n\n test_splitcmdline()\n test()\n test_execute_in()\n", "methods": [ { "name": "get_pythonexe", "long_name": "get_pythonexe( )", "filename": "exec_command.py", "nloc": 8, "complexity": 2, "token_count": 75, "parameters": [], "start_line": 65, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "splitcmdline", "long_name": "splitcmdline( line )", "filename": "exec_command.py", "nloc": 29, "complexity": 25, "token_count": 211, "parameters": [ "line" ], "start_line": 76, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "test_splitcmdline", "long_name": "test_splitcmdline( )", "filename": "exec_command.py", "nloc": 15, "complexity": 1, "token_count": 134, "parameters": [], "start_line": 108, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "find_executable", "long_name": "find_executable( exe , path = None )", "filename": "exec_command.py", "nloc": 33, "complexity": 14, "token_count": 278, "parameters": [ "exe", "path" ], "start_line": 126, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "_preserve_environment", "long_name": "_preserve_environment( names )", "filename": "exec_command.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "names" ], "start_line": 165, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_update_environment", "long_name": "_update_environment( ** env )", "filename": "exec_command.py", "nloc": 4, "complexity": 3, "token_count": 33, "parameters": [ "env" ], "start_line": 172, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "exec_command", "long_name": "exec_command( command , execute_in = '' , use_shell = None , use_tee = None , _with_python = 1 , ** env )", "filename": "exec_command.py", "nloc": 45, "complexity": 15, "token_count": 341, "parameters": [ "command", "execute_in", "use_shell", "use_tee", "_with_python", "env" ], "start_line": 177, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "_exec_command_posix", "long_name": "_exec_command_posix( command , use_shell = None , use_tee = None , ** env )", "filename": "exec_command.py", "nloc": 40, "complexity": 8, "token_count": 241, "parameters": [ "command", "use_shell", "use_tee", "env" ], "start_line": 250, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "_exec_command_python", "long_name": "_exec_command_python( command , exec_command_dir = '' , ** env )", "filename": "exec_command.py", "nloc": 32, "complexity": 1, "token_count": 232, "parameters": [ "command", "exec_command_dir", "env" ], "start_line": 301, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "_exec_command", "long_name": "_exec_command( command , use_shell = None , ** env )", "filename": "exec_command.py", "nloc": 76, "complexity": 17, "token_count": 538, "parameters": [ "command", "use_shell", "env" ], "start_line": 341, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "test_nt", "long_name": "test_nt( )", "filename": "exec_command.py", "nloc": 35, "complexity": 16, "token_count": 344, "parameters": [], "start_line": 439, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "test_posix", "long_name": "test_posix( ** kws )", "filename": "exec_command.py", "nloc": 31, "complexity": 15, "token_count": 372, "parameters": [ "kws" ], "start_line": 489, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "test_execute_in", "long_name": "test_execute_in( ** kws )", "filename": "exec_command.py", "nloc": 16, "complexity": 3, "token_count": 130, "parameters": [ "kws" ], "start_line": 537, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_pythonexe", "long_name": "get_pythonexe( )", "filename": "exec_command.py", "nloc": 8, "complexity": 2, "token_count": 75, "parameters": [], "start_line": 65, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "splitcmdline", "long_name": "splitcmdline( line )", "filename": "exec_command.py", "nloc": 29, "complexity": 25, "token_count": 211, "parameters": [ "line" ], "start_line": 76, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "test_splitcmdline", "long_name": "test_splitcmdline( )", "filename": "exec_command.py", "nloc": 15, "complexity": 1, "token_count": 134, "parameters": [], "start_line": 108, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "find_executable", "long_name": "find_executable( exe , path = None )", "filename": "exec_command.py", "nloc": 33, "complexity": 14, "token_count": 278, "parameters": [ "exe", "path" ], "start_line": 126, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "_preserve_environment", "long_name": "_preserve_environment( names )", "filename": "exec_command.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "names" ], "start_line": 165, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_update_environment", "long_name": "_update_environment( ** env )", "filename": "exec_command.py", "nloc": 4, "complexity": 3, "token_count": 33, "parameters": [ "env" ], "start_line": 172, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "exec_command", "long_name": "exec_command( command , execute_in = '' , use_shell = None , use_tee = None , _with_python = 1 , ** env )", "filename": "exec_command.py", "nloc": 45, "complexity": 15, "token_count": 341, "parameters": [ "command", "execute_in", "use_shell", "use_tee", "_with_python", "env" ], "start_line": 177, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 73, "top_nesting_level": 0 }, { "name": "_exec_command_posix", "long_name": "_exec_command_posix( command , use_shell = None , use_tee = None , ** env )", "filename": "exec_command.py", "nloc": 36, "complexity": 7, "token_count": 222, "parameters": [ "command", "use_shell", "use_tee", "env" ], "start_line": 251, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "_exec_command_python", "long_name": "_exec_command_python( command , exec_command_dir = '' , ** env )", "filename": "exec_command.py", "nloc": 32, "complexity": 1, "token_count": 232, "parameters": [ "command", "exec_command_dir", "env" ], "start_line": 297, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "_exec_command", "long_name": "_exec_command( command , use_shell = None , ** env )", "filename": "exec_command.py", "nloc": 76, "complexity": 17, "token_count": 538, "parameters": [ "command", "use_shell", "env" ], "start_line": 337, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "test_nt", "long_name": "test_nt( )", "filename": "exec_command.py", "nloc": 35, "complexity": 16, "token_count": 344, "parameters": [], "start_line": 435, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "test_posix", "long_name": "test_posix( )", "filename": "exec_command.py", "nloc": 31, "complexity": 15, "token_count": 328, "parameters": [], "start_line": 485, "end_line": 531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "test_execute_in", "long_name": "test_execute_in( )", "filename": "exec_command.py", "nloc": 16, "complexity": 3, "token_count": 122, "parameters": [], "start_line": 533, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "_exec_command_posix", "long_name": "_exec_command_posix( command , use_shell = None , use_tee = None , ** env )", "filename": "exec_command.py", "nloc": 40, "complexity": 8, "token_count": 241, "parameters": [ "command", "use_shell", "use_tee", "env" ], "start_line": 250, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "test_posix", "long_name": "test_posix( )", "filename": "exec_command.py", "nloc": 31, "complexity": 15, "token_count": 328, "parameters": [], "start_line": 485, "end_line": 531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "test_posix", "long_name": "test_posix( ** kws )", "filename": "exec_command.py", "nloc": 31, "complexity": 15, "token_count": 372, "parameters": [ "kws" ], "start_line": 489, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "exec_command", "long_name": "exec_command( command , execute_in = '' , use_shell = None , use_tee = None , _with_python = 1 , ** env )", "filename": "exec_command.py", "nloc": 45, "complexity": 15, "token_count": 341, "parameters": [ "command", "execute_in", "use_shell", "use_tee", "_with_python", "env" ], "start_line": 177, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 73, "top_nesting_level": 0 }, { "name": "test_execute_in", "long_name": "test_execute_in( ** kws )", "filename": "exec_command.py", "nloc": 16, "complexity": 3, "token_count": 130, "parameters": [ "kws" ], "start_line": 537, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "test_execute_in", "long_name": "test_execute_in( )", "filename": "exec_command.py", "nloc": 16, "complexity": 3, "token_count": 122, "parameters": [], "start_line": 533, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 } ], "nloc": 401, "complexity": 122, "token_count": 3155, "diff_parsed": { "added": [ " stsfile = None", " stsfile = tempfile.mktemp()", " command_posix = '( %s ; echo $? > %s ) > %s 2>&1'\\", " % (command_str,stsfile,tmpfile)", " #command_posix = '( %s ) > %s 2>&1' % (command_str,tmpfile)", " if stsfile is not None:", "def test_posix(**kws):", " s,o=exec_command(\"echo Hello\",**kws)", " s,o=exec_command('echo $AAA',**kws)", " s,o=exec_command('echo \"$AAA\"',AAA='Tere',**kws)", " s,o=exec_command('echo \"$AAA\"',**kws)", " s,o=exec_command('echo \"$BBB\"',**kws)", " s,o=exec_command('echo \"$BBB\"',BBB='Hey',**kws)", " s,o=exec_command('echo \"$BBB\"',**kws)", " s,o=exec_command('this_is_not_a_command',**kws)", " s,o=exec_command('echo path=$PATH',**kws)", " s,o=exec_command('python -c \"import sys,os;sys.stderr.write(os.name)\"',**kws)", " s,o=exec_command('python -c \"raise \\'Ignore me.\\'\"',**kws)", " s,o=exec_command('python -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"',**kws)", " s,o=exec_command('python -c \"import sys;sys.exit(15)\"',**kws)", " s,o=exec_command('python -c \"print \\'Heipa\\'\"',**kws)", "def test_execute_in(**kws):", " % (pythonexe,fn),**kws)", " execute_in = tmpdir,**kws)", " test(use_tee=0)", " test(use_tee=1)", " test_execute_in(use_tee=0)", " test_execute_in(use_tee=1)" ], "deleted": [ "", " command_posix = '%s > %s 2>&1' % (command_str,tmpfile)", "def test_posix():", " s,o=exec_command(\"echo Hello\")", " s,o=exec_command('echo $AAA')", " s,o=exec_command('echo \"$AAA\"',AAA='Tere')", " s,o=exec_command('echo \"$AAA\"')", " s,o=exec_command('echo \"$BBB\"')", " s,o=exec_command('echo \"$BBB\"',BBB='Hey')", " s,o=exec_command('echo \"$BBB\"')", " s,o=exec_command('this_is_not_a_command')", " s,o=exec_command('echo path=$PATH')", " s,o=exec_command('python -c \"import sys,os;sys.stderr.write(os.name)\"')", " s,o=exec_command('python -c \"raise \\'Ignore me.\\'\"')", " s,o=exec_command('python -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"')", " s,o=exec_command('python -c \"import sys;sys.exit(15)\"')", " s,o=exec_command('python -c \"print \\'Heipa\\'\"')", "def test_execute_in():", " % (pythonexe,fn))", " execute_in = tmpdir)", " test()", " test_execute_in()" ] } } ] }, { "hash": "23dc54f27a74764ed0ae9e5619f37d35006b7c91", "msg": "Using NOCOLOR env.var to workaround cygncurses bug under cygwin.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-02T15:43:50+00:00", "author_timezone": 0, "committer_date": "2004-02-02T15:43:50+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "e9019344e79916bb6ecb025d6eaad6c691dba258" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 2, "insertions": 3, "lines": 5, "files": 2, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "setup.py", "new_path": "setup.py", "filename": "setup.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -33,7 +33,7 @@ def setup_package():\n sys.path.insert(0,os.path.join(local_path,n))\n try:\n mod = __import__('setup_'+n)\n- configs.append(mod.configuration())\n+ configs.append(mod.configuration(parent_path=local_path))\n mod = __import__(n+'_version')\n versions.append(mod)\n finally:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\"\"\"\nBundle of SciPy core modules:\n scipy_test\n scipy_distutils\n scipy_base\n weave\n\nUsage:\n python setup.py install\n python setup.py sdist -f\n\"\"\"\n\nimport os\nimport sys\n\nfrom scipy_distutils.core import setup\nfrom scipy_distutils.misc_util import default_config_dict\nfrom scipy_distutils.misc_util import get_path, merge_config_dicts\n\nbundle_packages = ['scipy_distutils','scipy_test','scipy_base','weave']\n\ndef setup_package():\n old_path = os.getcwd()\n local_path = os.path.dirname(os.path.abspath(sys.argv[0]))\n os.chdir(local_path)\n sys.path.insert(0, local_path)\n\n try:\n configs = [{'name':'Scipy_core'}]\n versions = []\n for n in bundle_packages:\n sys.path.insert(0,os.path.join(local_path,n))\n try:\n mod = __import__('setup_'+n)\n configs.append(mod.configuration(parent_path=local_path))\n mod = __import__(n+'_version')\n versions.append(mod)\n finally:\n del sys.path[0]\n \n config_dict = merge_config_dicts(configs)\n\n major = max([v.major for v in versions])\n minor = max([v.minor for v in versions])\n micro = max([v.micro for v in versions])\n release_level = min([v.release_level for v in versions])\n cvs_minor = reduce(lambda a,b:a+b,[v.cvs_minor for v in versions],0)\n cvs_serial = reduce(lambda a,b:a+b,[v.cvs_serial for v in versions],0)\n\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n\n print 'SciPy Core Version %s' % scipy_core_version\n setup( version = scipy_core_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy core modules: scipy_{distutils,test,base}\",\n license = \"SciPy License (BSD Style)\",\n url = \"http://www.scipy.org\",\n **config_dict\n )\n\n finally:\n del sys.path[0]\n os.chdir(old_path)\n\nif __name__ == \"__main__\":\n setup_package()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nBundle of SciPy core modules:\n scipy_test\n scipy_distutils\n scipy_base\n weave\n\nUsage:\n python setup.py install\n python setup.py sdist -f\n\"\"\"\n\nimport os\nimport sys\n\nfrom scipy_distutils.core import setup\nfrom scipy_distutils.misc_util import default_config_dict\nfrom scipy_distutils.misc_util import get_path, merge_config_dicts\n\nbundle_packages = ['scipy_distutils','scipy_test','scipy_base','weave']\n\ndef setup_package():\n old_path = os.getcwd()\n local_path = os.path.dirname(os.path.abspath(sys.argv[0]))\n os.chdir(local_path)\n sys.path.insert(0, local_path)\n\n try:\n configs = [{'name':'Scipy_core'}]\n versions = []\n for n in bundle_packages:\n sys.path.insert(0,os.path.join(local_path,n))\n try:\n mod = __import__('setup_'+n)\n configs.append(mod.configuration())\n mod = __import__(n+'_version')\n versions.append(mod)\n finally:\n del sys.path[0]\n \n config_dict = merge_config_dicts(configs)\n\n major = max([v.major for v in versions])\n minor = max([v.minor for v in versions])\n micro = max([v.micro for v in versions])\n release_level = min([v.release_level for v in versions])\n cvs_minor = reduce(lambda a,b:a+b,[v.cvs_minor for v in versions],0)\n cvs_serial = reduce(lambda a,b:a+b,[v.cvs_serial for v in versions],0)\n\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n\n print 'SciPy Core Version %s' % scipy_core_version\n setup( version = scipy_core_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy core modules: scipy_{distutils,test,base}\",\n license = \"SciPy License (BSD Style)\",\n url = \"http://www.scipy.org\",\n **config_dict\n )\n\n finally:\n del sys.path[0]\n os.chdir(old_path)\n\nif __name__ == \"__main__\":\n setup_package()\n", "methods": [ { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 39, "complexity": 10, "token_count": 307, "parameters": [], "start_line": 23, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 } ], "methods_before": [ { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 39, "complexity": 10, "token_count": 304, "parameters": [], "start_line": 23, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 39, "complexity": 10, "token_count": 307, "parameters": [], "start_line": 23, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 } ], "nloc": 58, "complexity": 10, "token_count": 352, "diff_parsed": { "added": [ " configs.append(mod.configuration(parent_path=local_path))" ], "deleted": [ " configs.append(mod.configuration())" ] } }, { "old_path": "weave/setup_weave.py", "new_path": "weave/setup_weave.py", "filename": "setup_weave.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -4,7 +4,8 @@\n from glob import glob\n from scipy_distutils.misc_util import get_path, default_config_dict, dot_join\n \n-def configuration(parent_package='',parent_path2=None):\n+def configuration(parent_package='',parent_path=None):\n+ parent_path2 = parent_path\n parent_path = parent_package\n local_path = get_path(__name__,parent_path2)\n config = default_config_dict('weave',parent_package)\n", "added_lines": 2, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\nimport os\nfrom glob import glob\nfrom scipy_distutils.misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package='',parent_path=None):\n parent_path2 = parent_path\n parent_path = parent_package\n local_path = get_path(__name__,parent_path2)\n config = default_config_dict('weave',parent_package)\n config['packages'].append(dot_join(parent_package,'weave.tests'))\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['weave.tests'] = test_path\n \n scxx_files = glob(os.path.join(local_path,'scxx','*.*'))\n install_path = os.path.join(parent_path,'weave','scxx')\n config['data_files'].extend( [(install_path,scxx_files)])\n \n blitz_files = glob(os.path.join(local_path,'blitz-20001213','blitz','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz')\n config['data_files'].extend( [(install_path,blitz_files)])\n \n array_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'array','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','array')\n config['data_files'].extend( [(install_path,array_files)])\n \n meta_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'meta','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','meta')\n config['data_files'].extend( [(install_path,meta_files)])\n\n swig_files = glob(os.path.join(local_path,'swig','*.c'))\n install_path = os.path.join(parent_path,'weave','swig')\n config['data_files'].extend( [(install_path,swig_files)])\n\n doc_files = glob(os.path.join(local_path,'doc','*.html'))\n install_path = os.path.join(parent_path,'weave','doc')\n config['data_files'].extend( [(install_path,doc_files)])\n\n example_files = glob(os.path.join(local_path,'examples','*.py'))\n install_path = os.path.join(parent_path,'weave','examples')\n config['data_files'].extend( [(install_path,example_files)])\n \n return config\n\nif __name__ == '__main__': \n from scipy_distutils.core import setup\n setup(**configuration())\n", "source_code_before": "#!/usr/bin/env python\n\nimport os\nfrom glob import glob\nfrom scipy_distutils.misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package='',parent_path2=None):\n parent_path = parent_package\n local_path = get_path(__name__,parent_path2)\n config = default_config_dict('weave',parent_package)\n config['packages'].append(dot_join(parent_package,'weave.tests'))\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['weave.tests'] = test_path\n \n scxx_files = glob(os.path.join(local_path,'scxx','*.*'))\n install_path = os.path.join(parent_path,'weave','scxx')\n config['data_files'].extend( [(install_path,scxx_files)])\n \n blitz_files = glob(os.path.join(local_path,'blitz-20001213','blitz','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz')\n config['data_files'].extend( [(install_path,blitz_files)])\n \n array_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'array','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','array')\n config['data_files'].extend( [(install_path,array_files)])\n \n meta_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'meta','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','meta')\n config['data_files'].extend( [(install_path,meta_files)])\n\n swig_files = glob(os.path.join(local_path,'swig','*.c'))\n install_path = os.path.join(parent_path,'weave','swig')\n config['data_files'].extend( [(install_path,swig_files)])\n\n doc_files = glob(os.path.join(local_path,'doc','*.html'))\n install_path = os.path.join(parent_path,'weave','doc')\n config['data_files'].extend( [(install_path,doc_files)])\n\n example_files = glob(os.path.join(local_path,'examples','*.py'))\n install_path = os.path.join(parent_path,'weave','examples')\n config['data_files'].extend( [(install_path,example_files)])\n \n return config\n\nif __name__ == '__main__': \n from scipy_distutils.core import setup\n setup(**configuration())\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_weave.py", "nloc": 35, "complexity": 1, "token_count": 412, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path2 = None )", "filename": "setup_weave.py", "nloc": 34, "complexity": 1, "token_count": 409, "parameters": [ "parent_package", "parent_path2" ], "start_line": 7, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path2 = None )", "filename": "setup_weave.py", "nloc": 34, "complexity": 1, "token_count": 409, "parameters": [ "parent_package", "parent_path2" ], "start_line": 7, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_weave.py", "nloc": 35, "complexity": 1, "token_count": 412, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 } ], "nloc": 41, "complexity": 1, "token_count": 447, "diff_parsed": { "added": [ "def configuration(parent_package='',parent_path=None):", " parent_path2 = parent_path" ], "deleted": [ "def configuration(parent_package='',parent_path2=None):" ] } } ] }, { "hash": "da3e21058bbbac8c8f53037c8932ca4e05ddb7b1", "msg": "Using NOCOLOR env.var to workaround cygncurses bug under cygwin.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-02T15:43:50+00:00", "author_timezone": 0, "committer_date": "2004-02-02T15:43:50+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "59c6f7c8809104ffcc97e2083529ae4111b41755" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 7, "insertions": 24, "lines": 31, "files": 2, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_ext.py", "new_path": "scipy_distutils/command/build_ext.py", "filename": "build_ext.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -146,6 +146,7 @@ def build_extension(self, ext):\n kws = {'depends':ext.depends}\n else:\n kws = {}\n+\n c_objects = self.compiler.compile(c_sources,\n output_dir=self.build_temp,\n macros=macros,\n", "added_lines": 1, "deleted_lines": 0, "source_code": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os\nimport string\nimport sys\nfrom glob import glob\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util, log\nfrom scipy_distutils.misc_util import filter_sources, has_f_sources, has_cxx_sources\n\nclass build_ext (old_build_ext):\n\n description = \"build C/C++/F extensions (compile/link to build directory)\"\n\n user_options = old_build_ext.user_options + [\n ('fcompiler=', None,\n \"specify the Fortran compiler type\"),\n ]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.fcompiler = None\n return\n\n def run(self):\n if not self.extensions:\n return\n\n if self.distribution.has_c_libraries():\n build_clib = self.get_finalized_command('build_clib')\n self.library_dirs.append(build_clib.build_clib)\n else:\n build_clib = None\n\n # Not including C libraries to the list of\n # extension libraries automatically to prevent\n # bogus linking commands. Extensions must\n # explicitly specify the C libraries that they use.\n\n save_mth = self.distribution.has_c_libraries\n self.distribution.has_c_libraries = self.distribution.return_false\n old_build_ext.run(self) # sets self.compiler\n self.distribution.has_c_libraries = save_mth\n \n # Determine if Fortran compiler is needed.\n if build_clib and build_clib.fcompiler is not None:\n need_f_compiler = 1\n else:\n need_f_compiler = 0\n for ext in self.extensions:\n if has_f_sources(ext.sources):\n need_f_compiler = 1\n break\n\n # Determine if C++ compiler is needed.\n need_cxx_compiler = 0\n for ext in self.extensions:\n if has_cxx_sources(ext.sources):\n need_cxx_compiler = 1\n break\n\n # Initialize Fortran/C++ compilers if needed.\n if need_f_compiler:\n from scipy_distutils.fcompiler import new_fcompiler\n self.fcompiler = new_fcompiler(compiler=self.fcompiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n self.fcompiler.customize(self.distribution)\n self.fcompiler.customize_cmd(self)\n if need_cxx_compiler:\n c = self.compiler\n if c.compiler[0].find('gcc')>=0:\n if sys.version[:3]>='2.3':\n if not c.compiler_cxx:\n c.compiler_cxx = [c.compiler[0].replace('gcc','g++')]\\\n + c.compiler[1:]\n else:\n c.compiler_cxx = [c.compiler[0].replace('gcc','g++')]\\\n + c.compiler[1:]\n else:\n print 'XXX: Fix compiler_cxx for',c.__class__.__name__\n\n # Build extensions\n self.build_extensions2()\n return\n\n def build_extensions(self):\n # Hold on building extensions in old_build_ext.run()\n # until Fortran/C++ compilers are set. Building will be\n # carried out in build_extensions2()\n return\n\n def build_extensions2(self):\n old_build_ext.build_extensions(self)\n return\n\n def swig_sources(self, sources):\n # Do nothing. Swig sources have beed handled in build_src command.\n return sources\n\n def build_extension(self, ext):\n sources = ext.sources\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'ext_modules' option (extension '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % ext.name\n sources = list(sources)\n\n fullname = self.get_ext_fullname(ext.name)\n if self.inplace:\n modpath = string.split(fullname, '.')\n package = string.join(modpath[0:-1], '.')\n base = modpath[-1]\n\n build_py = self.get_finalized_command('build_py')\n package_dir = build_py.get_package_dir(package)\n ext_filename = os.path.join(package_dir,\n self.get_ext_filename(base))\n else:\n ext_filename = os.path.join(self.build_lib,\n self.get_ext_filename(fullname))\n depends = sources + ext.depends\n\n if not (self.force or newer_group(depends, ext_filename, 'newer')):\n log.debug(\"skipping '%s' extension (up-to-date)\", ext.name)\n return\n else:\n log.info(\"building '%s' extension\", ext.name)\n\n extra_args = ext.extra_compile_args or []\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n c_sources, cxx_sources, f_sources, fmodule_sources = filter_sources(ext.sources)\n\n if sys.version[:3]>='2.3':\n kws = {'depends':ext.depends}\n else:\n kws = {}\n\n c_objects = self.compiler.compile(c_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=ext.include_dirs,\n debug=self.debug,\n extra_postargs=extra_args,\n **kws)\n if cxx_sources:\n old_compiler = self.compiler.compiler_so[0]\n self.compiler.compiler_so[0] = self.compiler.compiler_cxx[0]\n c_objects += self.compiler.compile(cxx_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=ext.include_dirs,\n debug=self.debug,\n extra_postargs=extra_args,\n **kws)\n self.compiler.compiler_so[0] = old_compiler\n\n check_for_f90_modules = not not fmodule_sources\n\n if f_sources or fmodule_sources:\n extra_postargs = []\n include_dirs = ext.include_dirs[:]\n module_dirs = [] # XXX Figure out how users could change this?\n\n if check_for_f90_modules:\n module_build_dir = os.path.join(\\\n self.build_temp,os.path.dirname(\\\n self.get_ext_filename(fullname)))\n\n self.mkpath(module_build_dir)\n if self.fcompiler.module_dir_switch is None:\n existing_modules = glob('*.mod')\n extra_postargs += self.fcompiler.module_options(\\\n module_dirs,module_build_dir)\n\n f_objects = self.fcompiler.compile(fmodule_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs,\n depends=ext.depends)\n\n if check_for_f90_modules \\\n and self.fcompiler.module_dir_switch is None:\n for f in glob('*.mod'):\n if f in existing_modules:\n continue\n self.move_file(f, module_build_dir)\n\n f_objects += self.fcompiler.compile(f_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs,\n depends=ext.depends)\n else:\n f_objects = []\n\n objects = c_objects + f_objects\n\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n old_linker_so_0 = self.compiler.linker_so[0]\n\n use_fortran_linker = 0\n if f_sources:\n use_fortran_linker = 1\n elif self.distribution.has_c_libraries(): \n build_clib = self.get_finalized_command('build_clib')\n f_libs = []\n for (lib_name, build_info) in build_clib.libraries:\n if has_f_sources(build_info.get('sources',[])):\n f_libs.append(lib_name)\n for l in ext.libraries:\n if l in f_libs:\n use_fortran_linker = 1\n break\n\n if use_fortran_linker:\n if cxx_sources:\n # XXX: Which linker should be used, Fortran or C++?\n log.warn('mixing Fortran and C++ is untested')\n link = self.fcompiler.link_shared_object\n language = ext.language or self.fcompiler.detect_language(f_sources)\n else:\n link = self.compiler.link_shared_object\n if sys.version[:3]>='2.3':\n language = ext.language or self.compiler.detect_language(sources)\n else:\n language = ext.language\n if cxx_sources:\n self.compiler.linker_so[0] = self.compiler.compiler_cxx[0]\n\n if sys.version[:3]>='2.3':\n kws = {'target_lang':language}\n else:\n kws = {}\n link(objects, ext_filename,\n libraries=self.get_libraries(ext),\n library_dirs=ext.library_dirs,\n runtime_library_dirs=ext.runtime_library_dirs,\n extra_postargs=extra_args,\n export_symbols=self.get_export_symbols(ext),\n debug=self.debug,\n build_temp=self.build_temp,**kws)\n\n self.compiler.linker_so[0] = old_linker_so_0\n return\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n def visit_func(filenames,dirname,names):\n if os.path.basename(dirname)=='CVS':\n return\n for name in names:\n fullname = os.path.join(dirname,name)\n if os.path.isfile(fullname):\n filenames.append(fullname)\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n sources = filter(lambda s:type(s) is StringType,ext.sources)\n filenames.extend(sources)\n filenames.extend(get_headers(get_directories(sources)))\n for d in ext.depends:\n if is_local_src_dir(d):\n os.path.walk(d,visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return 0\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os\nimport string\nimport sys\nfrom glob import glob\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util, log\nfrom scipy_distutils.misc_util import filter_sources, has_f_sources, has_cxx_sources\n\nclass build_ext (old_build_ext):\n\n description = \"build C/C++/F extensions (compile/link to build directory)\"\n\n user_options = old_build_ext.user_options + [\n ('fcompiler=', None,\n \"specify the Fortran compiler type\"),\n ]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.fcompiler = None\n return\n\n def run(self):\n if not self.extensions:\n return\n\n if self.distribution.has_c_libraries():\n build_clib = self.get_finalized_command('build_clib')\n self.library_dirs.append(build_clib.build_clib)\n else:\n build_clib = None\n\n # Not including C libraries to the list of\n # extension libraries automatically to prevent\n # bogus linking commands. Extensions must\n # explicitly specify the C libraries that they use.\n\n save_mth = self.distribution.has_c_libraries\n self.distribution.has_c_libraries = self.distribution.return_false\n old_build_ext.run(self) # sets self.compiler\n self.distribution.has_c_libraries = save_mth\n \n # Determine if Fortran compiler is needed.\n if build_clib and build_clib.fcompiler is not None:\n need_f_compiler = 1\n else:\n need_f_compiler = 0\n for ext in self.extensions:\n if has_f_sources(ext.sources):\n need_f_compiler = 1\n break\n\n # Determine if C++ compiler is needed.\n need_cxx_compiler = 0\n for ext in self.extensions:\n if has_cxx_sources(ext.sources):\n need_cxx_compiler = 1\n break\n\n # Initialize Fortran/C++ compilers if needed.\n if need_f_compiler:\n from scipy_distutils.fcompiler import new_fcompiler\n self.fcompiler = new_fcompiler(compiler=self.fcompiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n self.fcompiler.customize(self.distribution)\n self.fcompiler.customize_cmd(self)\n if need_cxx_compiler:\n c = self.compiler\n if c.compiler[0].find('gcc')>=0:\n if sys.version[:3]>='2.3':\n if not c.compiler_cxx:\n c.compiler_cxx = [c.compiler[0].replace('gcc','g++')]\\\n + c.compiler[1:]\n else:\n c.compiler_cxx = [c.compiler[0].replace('gcc','g++')]\\\n + c.compiler[1:]\n else:\n print 'XXX: Fix compiler_cxx for',c.__class__.__name__\n\n # Build extensions\n self.build_extensions2()\n return\n\n def build_extensions(self):\n # Hold on building extensions in old_build_ext.run()\n # until Fortran/C++ compilers are set. Building will be\n # carried out in build_extensions2()\n return\n\n def build_extensions2(self):\n old_build_ext.build_extensions(self)\n return\n\n def swig_sources(self, sources):\n # Do nothing. Swig sources have beed handled in build_src command.\n return sources\n\n def build_extension(self, ext):\n sources = ext.sources\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'ext_modules' option (extension '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % ext.name\n sources = list(sources)\n\n fullname = self.get_ext_fullname(ext.name)\n if self.inplace:\n modpath = string.split(fullname, '.')\n package = string.join(modpath[0:-1], '.')\n base = modpath[-1]\n\n build_py = self.get_finalized_command('build_py')\n package_dir = build_py.get_package_dir(package)\n ext_filename = os.path.join(package_dir,\n self.get_ext_filename(base))\n else:\n ext_filename = os.path.join(self.build_lib,\n self.get_ext_filename(fullname))\n depends = sources + ext.depends\n\n if not (self.force or newer_group(depends, ext_filename, 'newer')):\n log.debug(\"skipping '%s' extension (up-to-date)\", ext.name)\n return\n else:\n log.info(\"building '%s' extension\", ext.name)\n\n extra_args = ext.extra_compile_args or []\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n c_sources, cxx_sources, f_sources, fmodule_sources = filter_sources(ext.sources)\n\n if sys.version[:3]>='2.3':\n kws = {'depends':ext.depends}\n else:\n kws = {}\n c_objects = self.compiler.compile(c_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=ext.include_dirs,\n debug=self.debug,\n extra_postargs=extra_args,\n **kws)\n if cxx_sources:\n old_compiler = self.compiler.compiler_so[0]\n self.compiler.compiler_so[0] = self.compiler.compiler_cxx[0]\n c_objects += self.compiler.compile(cxx_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=ext.include_dirs,\n debug=self.debug,\n extra_postargs=extra_args,\n **kws)\n self.compiler.compiler_so[0] = old_compiler\n\n check_for_f90_modules = not not fmodule_sources\n\n if f_sources or fmodule_sources:\n extra_postargs = []\n include_dirs = ext.include_dirs[:]\n module_dirs = [] # XXX Figure out how users could change this?\n\n if check_for_f90_modules:\n module_build_dir = os.path.join(\\\n self.build_temp,os.path.dirname(\\\n self.get_ext_filename(fullname)))\n\n self.mkpath(module_build_dir)\n if self.fcompiler.module_dir_switch is None:\n existing_modules = glob('*.mod')\n extra_postargs += self.fcompiler.module_options(\\\n module_dirs,module_build_dir)\n\n f_objects = self.fcompiler.compile(fmodule_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs,\n depends=ext.depends)\n\n if check_for_f90_modules \\\n and self.fcompiler.module_dir_switch is None:\n for f in glob('*.mod'):\n if f in existing_modules:\n continue\n self.move_file(f, module_build_dir)\n\n f_objects += self.fcompiler.compile(f_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs,\n depends=ext.depends)\n else:\n f_objects = []\n\n objects = c_objects + f_objects\n\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n old_linker_so_0 = self.compiler.linker_so[0]\n\n use_fortran_linker = 0\n if f_sources:\n use_fortran_linker = 1\n elif self.distribution.has_c_libraries(): \n build_clib = self.get_finalized_command('build_clib')\n f_libs = []\n for (lib_name, build_info) in build_clib.libraries:\n if has_f_sources(build_info.get('sources',[])):\n f_libs.append(lib_name)\n for l in ext.libraries:\n if l in f_libs:\n use_fortran_linker = 1\n break\n\n if use_fortran_linker:\n if cxx_sources:\n # XXX: Which linker should be used, Fortran or C++?\n log.warn('mixing Fortran and C++ is untested')\n link = self.fcompiler.link_shared_object\n language = ext.language or self.fcompiler.detect_language(f_sources)\n else:\n link = self.compiler.link_shared_object\n if sys.version[:3]>='2.3':\n language = ext.language or self.compiler.detect_language(sources)\n else:\n language = ext.language\n if cxx_sources:\n self.compiler.linker_so[0] = self.compiler.compiler_cxx[0]\n\n if sys.version[:3]>='2.3':\n kws = {'target_lang':language}\n else:\n kws = {}\n link(objects, ext_filename,\n libraries=self.get_libraries(ext),\n library_dirs=ext.library_dirs,\n runtime_library_dirs=ext.runtime_library_dirs,\n extra_postargs=extra_args,\n export_symbols=self.get_export_symbols(ext),\n debug=self.debug,\n build_temp=self.build_temp,**kws)\n\n self.compiler.linker_so[0] = old_linker_so_0\n return\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n def visit_func(filenames,dirname,names):\n if os.path.basename(dirname)=='CVS':\n return\n for name in names:\n fullname = os.path.join(dirname,name)\n if os.path.isfile(fullname):\n filenames.append(fullname)\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n sources = filter(lambda s:type(s) is StringType,ext.sources)\n filenames.extend(sources)\n filenames.extend(get_headers(get_directories(sources)))\n for d in ext.depends:\n if is_local_src_dir(d):\n os.path.walk(d,visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return 0\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_ext.py", "nloc": 47, "complexity": 14, "token_count": 305, "parameters": [ "self" ], "start_line": 31, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 1 }, { "name": "build_extensions", "long_name": "build_extensions( self )", "filename": "build_ext.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 94, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_extensions2", "long_name": "build_extensions2( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "swig_sources", "long_name": "swig_sources( self , sources )", "filename": "build_ext.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "sources" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 134, "complexity": 33, "token_count": 897, "parameters": [ "self", "ext" ], "start_line": 108, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 156, "top_nesting_level": 1 }, { "name": "get_source_files.visit_func", "long_name": "get_source_files.visit_func( filenames , dirname , names )", "filename": "build_ext.py", "nloc": 7, "complexity": 4, "token_count": 55, "parameters": [ "filenames", "dirname", "names" ], "start_line": 268, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 14, "complexity": 5, "token_count": 105, "parameters": [ "self" ], "start_line": 265, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "is_local_src_dir", "long_name": "is_local_src_dir( directory )", "filename": "build_ext.py", "nloc": 10, "complexity": 5, "token_count": 98, "parameters": [ "directory" ], "start_line": 287, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_ext.py", "nloc": 47, "complexity": 14, "token_count": 305, "parameters": [ "self" ], "start_line": 31, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 1 }, { "name": "build_extensions", "long_name": "build_extensions( self )", "filename": "build_ext.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 94, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_extensions2", "long_name": "build_extensions2( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "swig_sources", "long_name": "swig_sources( self , sources )", "filename": "build_ext.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "sources" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 134, "complexity": 33, "token_count": 897, "parameters": [ "self", "ext" ], "start_line": 108, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 155, "top_nesting_level": 1 }, { "name": "get_source_files.visit_func", "long_name": "get_source_files.visit_func( filenames , dirname , names )", "filename": "build_ext.py", "nloc": 7, "complexity": 4, "token_count": 55, "parameters": [ "filenames", "dirname", "names" ], "start_line": 267, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 14, "complexity": 5, "token_count": 105, "parameters": [ "self" ], "start_line": 264, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "is_local_src_dir", "long_name": "is_local_src_dir( directory )", "filename": "build_ext.py", "nloc": 10, "complexity": 5, "token_count": 98, "parameters": [ "directory" ], "start_line": 286, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 134, "complexity": 33, "token_count": 897, "parameters": [ "self", "ext" ], "start_line": 108, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 156, "top_nesting_level": 1 } ], "nloc": 240, "complexity": 65, "token_count": 1595, "diff_parsed": { "added": [ "" ], "deleted": [] } }, { "old_path": "scipy_distutils/misc_util.py", "new_path": "scipy_distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -10,19 +10,30 @@\n # Hooks for colored terminal output.\n # See also http://www.livinglogic.de/Python/ansistyle\n def terminal_has_colors():\n- if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty(): \n+ if sys.platform=='cygwin' and os.environ.has_key('NOCOLOR'):\n+ # Avoid importing curses that causes illegal operation\n+ # with a message:\n+ # PYTHON2 caused an invalid page fault in\n+ # module CYGNURSES7.DLL as 015f:18bbfc28\n+ # Details: Python 2.3.3 [GCC 3.3.1 (cygming special)]\n+ # ssh to Win32 machine from debian\n+ # curses.version is 2.2\n+ # CYGWIN_98-4.10, release 1.5.7(0.109/3/2))\n return 0\n- try:\n- import curses\n- curses.setupterm()\n- return (curses.tigetnum(\"colors\") >= 0\n+ if hasattr(sys.stdout,'isatty') and sys.stdout.isatty(): \n+ try:\n+ import curses\n+ curses.setupterm()\n+ if (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n- or curses.tigetstr(\"scp\") is not None))\n- except: pass\n+ or curses.tigetstr(\"scp\") is not None)):\n+ return 1\n+ except Exception,msg:\n+ pass\n return 0\n \n if terminal_has_colors():\n@@ -345,3 +356,8 @@ def filter_sources(sources):\n else:\n c_sources.append(source) \n return c_sources, cxx_sources, f_sources, fmodule_sources\n+\n+if __name__ == '__main__':\n+ print 'terminal_has_colors:',terminal_has_colors()\n+ print red_text(\"This is red text\")\n+ print yellow_text(\"This is yellow text\")\n", "added_lines": 23, "deleted_lines": 7, "source_code": "import os,sys,string\nimport re\nimport types\n\nif sys.version[:3]<='2.1':\n from distutils import util\n util_get_platform = util.get_platform\n util.get_platform = lambda : util_get_platform().replace(' ','_')\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if sys.platform=='cygwin' and os.environ.has_key('NOCOLOR'):\n # Avoid importing curses that causes illegal operation\n # with a message:\n # PYTHON2 caused an invalid page fault in\n # module CYGNURSES7.DLL as 015f:18bbfc28\n # Details: Python 2.3.3 [GCC 3.3.1 (cygming special)]\n # ssh to Win32 machine from debian\n # curses.version is 2.2\n # CYGWIN_98-4.10, release 1.5.7(0.109/3/2))\n return 0\n if hasattr(sys.stdout,'isatty') and sys.stdout.isatty(): \n try:\n import curses\n curses.setupterm()\n if (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path is not None:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir']\n\ndef default_config_dict(name = None, parent_name = None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n test_path = os.path.join(local_path,'tests')\n if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n if os.path.exists(test_path):\n d['packages'].append(dot_join(full_name,'tests'))\n d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n name = d.get('name',None)\n if name is not None:\n result['name'] = name\n break\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ): #obsolete feature\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n\ndef get_environ_include_dirs(): #obsolete feature\n includes = []\n if os.environ.has_key('PYTHONINCLUDE'):\n includes = os.environ['PYTHONINCLUDE'].split(os.pathsep)\n return includes\n\ndef get_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\nclass SourceGenerator: #obsolete feature\n \"\"\" SourceGenerator\n func - creates target, arguments are (target,sources)+args\n sources - target source files\n args - extra arguments to func\n\n If func is None then target must exist and it is touched whenever\n sources are newer.\n \"\"\"\n def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target) and func is not None:\n g = sys._getframe(1).f_globals\n fn = g.get('__file__',g.get('__name__'))\n if fn=='__main__': fn = sys.argv[0]\n caller_dir = os.path.abspath(os.path.dirname(fn))\n prefix = os.path.commonprefix([caller_dir,os.getcwd()])\n target_dir = caller_dir[len(prefix)+1:]\n target = os.path.join(get_build_temp(),target_dir,target)\n self.func = func\n self.target = target\n self.sources = sources\n self.args = args\n def __str__(self):\n return str(self.target)\n def generate(self):\n from distutils import dep_util,dir_util\n if dep_util.newer_group(self.sources,self.target):\n print 'Running generate',self.target\n dir_util.mkpath(os.path.dirname(self.target),verbose=1)\n if self.func is None:\n # Touch target\n os.utime(self.target,None)\n else:\n self.func(self.target,self.sources,*self.args)\n assert os.path.exists(self.target),`self.target`\n return self.target\n def __call__(self, extension, src_dir):\n return self.generate()\n\nclass SourceFilter: #obsolete feature\n \"\"\" SourceFilter\n func - implements criteria to filter sources\n sources - source files\n args - extra arguments to func\n \"\"\"\n def __init__(self,func,sources,*args):\n self.func = func\n self.sources = sources\n self.args = args\n def filter(self):\n return self.func(self.sources,*self.args)\n def __call__(self, extension, src_dir):\n return self.filter()\n\n##\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return 1\n return 0\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return 1\n return 0\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source) \n return c_sources, cxx_sources, f_sources, fmodule_sources\n\nif __name__ == '__main__':\n print 'terminal_has_colors:',terminal_has_colors()\n print red_text(\"This is red text\")\n print yellow_text(\"This is yellow text\")\n", "source_code_before": "import os,sys,string\nimport re\nimport types\n\nif sys.version[:3]<='2.1':\n from distutils import util\n util_get_platform = util.get_platform\n util.get_platform = lambda : util_get_platform().replace(' ','_')\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty(): \n return 0\n try:\n import curses\n curses.setupterm()\n return (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None))\n except: pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path is not None:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir']\n\ndef default_config_dict(name = None, parent_name = None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n test_path = os.path.join(local_path,'tests')\n if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n if os.path.exists(test_path):\n d['packages'].append(dot_join(full_name,'tests'))\n d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n name = d.get('name',None)\n if name is not None:\n result['name'] = name\n break\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ): #obsolete feature\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n\ndef get_environ_include_dirs(): #obsolete feature\n includes = []\n if os.environ.has_key('PYTHONINCLUDE'):\n includes = os.environ['PYTHONINCLUDE'].split(os.pathsep)\n return includes\n\ndef get_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\nclass SourceGenerator: #obsolete feature\n \"\"\" SourceGenerator\n func - creates target, arguments are (target,sources)+args\n sources - target source files\n args - extra arguments to func\n\n If func is None then target must exist and it is touched whenever\n sources are newer.\n \"\"\"\n def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target) and func is not None:\n g = sys._getframe(1).f_globals\n fn = g.get('__file__',g.get('__name__'))\n if fn=='__main__': fn = sys.argv[0]\n caller_dir = os.path.abspath(os.path.dirname(fn))\n prefix = os.path.commonprefix([caller_dir,os.getcwd()])\n target_dir = caller_dir[len(prefix)+1:]\n target = os.path.join(get_build_temp(),target_dir,target)\n self.func = func\n self.target = target\n self.sources = sources\n self.args = args\n def __str__(self):\n return str(self.target)\n def generate(self):\n from distutils import dep_util,dir_util\n if dep_util.newer_group(self.sources,self.target):\n print 'Running generate',self.target\n dir_util.mkpath(os.path.dirname(self.target),verbose=1)\n if self.func is None:\n # Touch target\n os.utime(self.target,None)\n else:\n self.func(self.target,self.sources,*self.args)\n assert os.path.exists(self.target),`self.target`\n return self.target\n def __call__(self, extension, src_dir):\n return self.generate()\n\nclass SourceFilter: #obsolete feature\n \"\"\" SourceFilter\n func - implements criteria to filter sources\n sources - source files\n args - extra arguments to func\n \"\"\"\n def __init__(self,func,sources,*args):\n self.func = func\n self.sources = sources\n self.args = args\n def filter(self):\n return self.func(self.sources,*self.args)\n def __call__(self, extension, src_dir):\n return self.filter()\n\n##\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return 1\n return 0\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return 1\n return 0\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source) \n return c_sources, cxx_sources, f_sources, fmodule_sources\n", "methods": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 18, "complexity": 13, "token_count": 136, "parameters": [], "start_line": 12, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 58, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 61, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 14, "complexity": 5, "token_count": 124, "parameters": [ "mod_name", "parent_path" ], "start_line": 64, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 89, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 94, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 97, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 113, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 125, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 144, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 184, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 13, "complexity": 6, "token_count": 89, "parameters": [ "config_list" ], "start_line": 193, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 207, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 214, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 217, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "get_environ_include_dirs", "long_name": "get_environ_include_dirs( )", "filename": "misc_util.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 234, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "get_build_temp", "long_name": "get_build_temp( )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [], "start_line": 240, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , func , target , sources = [ ] , * args )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 154, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 254, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 267, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate", "long_name": "generate( self )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 107, "parameters": [ "self" ], "start_line": 269, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , extension , src_dir )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "extension", "src_dir" ], "start_line": 281, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , func , sources , * args )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "func", "sources", "args" ], "start_line": 290, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "filter", "long_name": "filter( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 294, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , extension , src_dir )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "extension", "src_dir" ], "start_line": 296, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_f90_modules", "long_name": "get_f90_modules( source )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 77, "parameters": [ "source" ], "start_line": 306, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "has_f_sources", "long_name": "has_f_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 324, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 331, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "filter_sources", "long_name": "filter_sources( sources )", "filename": "misc_util.py", "nloc": 17, "complexity": 5, "token_count": 84, "parameters": [ "sources" ], "start_line": 338, "end_line": 358, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 } ], "methods_before": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 15, "complexity": 10, "token_count": 116, "parameters": [], "start_line": 12, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 47, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 50, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 14, "complexity": 5, "token_count": 124, "parameters": [ "mod_name", "parent_path" ], "start_line": 53, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 74, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 78, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 83, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 86, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 102, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 114, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 133, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 173, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 13, "complexity": 6, "token_count": 89, "parameters": [ "config_list" ], "start_line": 182, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 196, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 203, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 206, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "get_environ_include_dirs", "long_name": "get_environ_include_dirs( )", "filename": "misc_util.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 223, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "get_build_temp", "long_name": "get_build_temp( )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [], "start_line": 229, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , func , target , sources = [ ] , * args )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 154, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 243, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 256, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate", "long_name": "generate( self )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 107, "parameters": [ "self" ], "start_line": 258, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , extension , src_dir )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "extension", "src_dir" ], "start_line": 270, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , func , sources , * args )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "func", "sources", "args" ], "start_line": 279, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "filter", "long_name": "filter( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 283, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , extension , src_dir )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "extension", "src_dir" ], "start_line": 285, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_f90_modules", "long_name": "get_f90_modules( source )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 77, "parameters": [ "source" ], "start_line": 295, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "has_f_sources", "long_name": "has_f_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 313, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 320, "end_line": 325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "filter_sources", "long_name": "filter_sources( sources )", "filename": "misc_util.py", "nloc": 17, "complexity": 5, "token_count": 84, "parameters": [ "sources" ], "start_line": 327, "end_line": 347, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 18, "complexity": 13, "token_count": 136, "parameters": [], "start_line": 12, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 } ], "nloc": 269, "complexity": 89, "token_count": 1976, "diff_parsed": { "added": [ " if sys.platform=='cygwin' and os.environ.has_key('NOCOLOR'):", " # Avoid importing curses that causes illegal operation", " # with a message:", " # PYTHON2 caused an invalid page fault in", " # module CYGNURSES7.DLL as 015f:18bbfc28", " # Details: Python 2.3.3 [GCC 3.3.1 (cygming special)]", " # ssh to Win32 machine from debian", " # curses.version is 2.2", " # CYGWIN_98-4.10, release 1.5.7(0.109/3/2))", " if hasattr(sys.stdout,'isatty') and sys.stdout.isatty():", " try:", " import curses", " curses.setupterm()", " if (curses.tigetnum(\"colors\") >= 0", " or curses.tigetstr(\"scp\") is not None)):", " return 1", " except Exception,msg:", " pass", "", "if __name__ == '__main__':", " print 'terminal_has_colors:',terminal_has_colors()", " print red_text(\"This is red text\")", " print yellow_text(\"This is yellow text\")" ], "deleted": [ " if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty():", " try:", " import curses", " curses.setupterm()", " return (curses.tigetnum(\"colors\") >= 0", " or curses.tigetstr(\"scp\") is not None))", " except: pass" ] } } ] }, { "hash": "8ad94b4e44e0de10f7c56170fda10d7f012603a0", "msg": "Merging changes (cygwin support) from build_src branch.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-02T15:51:31+00:00", "author_timezone": 0, "committer_date": "2004-02-02T15:51:31+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": true, "parents": [ "23dc54f27a74764ed0ae9e5619f37d35006b7c91", "da3e21058bbbac8c8f53037c8932ca4e05ddb7b1" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 30, "insertions": 118, "lines": 148, "files": 4, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null }, { "hash": "ec181525c9e42c4e7371c20c04271e37bcb1264f", "msg": "Raise NumericNotFoundError when Numeric is not found.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-02T15:59:41+00:00", "author_timezone": 0, "committer_date": "2004-02-02T15:59:41+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "8ad94b4e44e0de10f7c56170fda10d7f012603a0" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 7, "insertions": 5, "lines": 12, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_base/setup_scipy_base.py", "new_path": "scipy_base/setup_scipy_base.py", "filename": "setup_scipy_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -5,13 +5,7 @@\n import shutil\n \n def configuration(parent_package='',parent_path=None):\n- try:\n- import Numeric\n- except ImportError,msg:\n- print msg\n- print 'Working Numeric is required to build scipy_base'\n- return {}\n-\n+ from scipy_distutils.system_info import get_info, NumericNotFoundError\n from scipy_distutils.core import Extension\n from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n from scipy_distutils.misc_util import get_path,default_config_dict,\\\n@@ -21,6 +15,10 @@ def configuration(parent_package='',parent_path=None):\n local_path = get_path(__name__,parent_path)\n config = default_config_dict(package,parent_package)\n \n+ numpy_info = get_info('numpy')\n+ if not numpy_info:\n+ raise NumericNotFoundError, NumericNotFoundError.__doc__\n+\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n", "added_lines": 5, "deleted_lines": 7, "source_code": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nimport shutil\n\ndef configuration(parent_package='',parent_path=None):\n from scipy_distutils.system_info import get_info, NumericNotFoundError\n from scipy_distutils.core import Extension\n from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n from scipy_distutils.misc_util import get_path,default_config_dict,\\\n dot_join,SourceGenerator\n\n package = 'scipy_base'\n local_path = get_path(__name__,parent_path)\n config = default_config_dict(package,parent_package)\n\n numpy_info = get_info('numpy')\n if not numpy_info:\n raise NumericNotFoundError, NumericNotFoundError.__doc__\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n umath_c_sources = ['fastumathmodule.c',\n 'fastumath_unsigned.inc','fastumath_nounsigned.inc']\n umath_c_sources = [os.path.join(local_path,x) for x in umath_c_sources]\n umath_c = SourceGenerator(func = None,\n target = os.path.join(local_path,'fastumathmodule.c'),\n sources = umath_c_sources)\n sources = [umath_c, os.path.join(local_path,'isnan.c')]\n define_macros = []\n if sys.byteorder == \"little\":\n define_macros.append(('USE_MCONF_LITE_LE',None))\n else:\n define_macros.append(('USE_MCONF_LITE_BE',None))\n ext = Extension(dot_join(package,'fastumath'),sources,\n define_macros = define_macros,\n extra_compile_args=extra_compile_args,\n depends = umath_c_sources)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension(dot_join(package,'_compiled_base'),sources)\n config['ext_modules'].append(ext)\n\n return config\n\nif __name__ == '__main__':\n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n if sys.platform == 'win32':\n from scipy_distutils.mingw32_support import *\n from scipy_distutils.core import setup\n\n setup(version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "source_code_before": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nimport shutil\n\ndef configuration(parent_package='',parent_path=None):\n try:\n import Numeric\n except ImportError,msg:\n print msg\n print 'Working Numeric is required to build scipy_base'\n return {}\n\n from scipy_distutils.core import Extension\n from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n from scipy_distutils.misc_util import get_path,default_config_dict,\\\n dot_join,SourceGenerator\n\n package = 'scipy_base'\n local_path = get_path(__name__,parent_path)\n config = default_config_dict(package,parent_package)\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n umath_c_sources = ['fastumathmodule.c',\n 'fastumath_unsigned.inc','fastumath_nounsigned.inc']\n umath_c_sources = [os.path.join(local_path,x) for x in umath_c_sources]\n umath_c = SourceGenerator(func = None,\n target = os.path.join(local_path,'fastumathmodule.c'),\n sources = umath_c_sources)\n sources = [umath_c, os.path.join(local_path,'isnan.c')]\n define_macros = []\n if sys.byteorder == \"little\":\n define_macros.append(('USE_MCONF_LITE_LE',None))\n else:\n define_macros.append(('USE_MCONF_LITE_BE',None))\n ext = Extension(dot_join(package,'fastumath'),sources,\n define_macros = define_macros,\n extra_compile_args=extra_compile_args,\n depends = umath_c_sources)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension(dot_join(package,'_compiled_base'),sources)\n config['ext_modules'].append(ext)\n\n return config\n\nif __name__ == '__main__':\n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n if sys.platform == 'win32':\n from scipy_distutils.mingw32_support import *\n from scipy_distutils.core import setup\n\n setup(version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 35, "complexity": 5, "token_count": 269, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 37, "complexity": 5, "token_count": 261, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 35, "complexity": 5, "token_count": 269, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 } ], "nloc": 52, "complexity": 5, "token_count": 343, "diff_parsed": { "added": [ " from scipy_distutils.system_info import get_info, NumericNotFoundError", " numpy_info = get_info('numpy')", " if not numpy_info:", " raise NumericNotFoundError, NumericNotFoundError.__doc__", "" ], "deleted": [ " try:", " import Numeric", " except ImportError,msg:", " print msg", " print 'Working Numeric is required to build scipy_base'", " return {}", "" ] } } ] }, { "hash": "78aa98e2bc6b4bc1cb0d39dc8c43a40fc2a96215", "msg": "Fixed bug that occurs on win32", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-02T16:17:06+00:00", "author_timezone": 0, "committer_date": "2004-02-02T16:17:06+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "ec181525c9e42c4e7371c20c04271e37bcb1264f" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 7, "insertions": 6, "lines": 13, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/system_info.py", "new_path": "scipy_distutils/system_info.py", "filename": "system_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -275,7 +275,7 @@ def get_info(self):\n \n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n- if os.environ.has_key(self.dir_env_var):\n+ if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n@@ -763,10 +763,11 @@ def __init__(self):\n from distutils.sysconfig import get_python_inc\n py_incl_dir = get_python_inc()\n include_dirs = [py_incl_dir]\n- for d in default_include_dirs:\n- d = os.path.join(d, os.path.basename(py_incl_dir))\n- if d not in include_dirs:\n- include_dirs.append(d)\n+ if os.name=='posix':\n+ for d in default_include_dirs:\n+ d = os.path.join(d, os.path.basename(py_incl_dir))\n+ if d not in include_dirs:\n+ include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n@@ -862,5 +863,3 @@ def show_all():\n \n if __name__ == \"__main__\":\n show_all()\n- print numpy_info().get_info()\n- print numarray_info().get_info()\n", "added_lines": 6, "deleted_lines": 7, "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n atlas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'atlas_threads':atlas_threads_info,\n 'lapack_atlas_threads':lapack_atlas_threads_info,\n 'lapack_atlas':lapack_atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n self.set_info(**info)\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32','cygwin']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n py_incl_dir = get_python_inc()\n include_dirs = [py_incl_dir]\n if os.name=='posix':\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"%s\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n atlas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'atlas_threads':atlas_threads_info,\n 'lapack_atlas_threads':lapack_atlas_threads_info,\n 'lapack_atlas':lapack_atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n self.set_info(**info)\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32','cygwin']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n py_incl_dir = get_python_inc()\n include_dirs = [py_incl_dir]\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"%s\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n print numpy_info().get_info()\n print numarray_info().get_info()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 21, "complexity": 1, "token_count": 100, "parameters": [ "name" ], "start_line": 120, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 218, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 244, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 247, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 153, "parameters": [ "self" ], "start_line": 250, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 11, "complexity": 7, "token_count": 142, "parameters": [ "self", "section", "key" ], "start_line": 276, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 288, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 291, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 294, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 297, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 304, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 315, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 325, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 329, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 340, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 350, "end_line": 351, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 353, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 426, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 454, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 75, "complexity": 17, "token_count": 427, "parameters": [ "self" ], "start_line": 462, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 553, "end_line": 564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 570, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 577, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 668, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 685, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 692, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 732, "end_line": 735, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 116, "parameters": [ "self" ], "start_line": 737, "end_line": 756, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 12, "complexity": 4, "token_count": 79, "parameters": [ "self" ], "start_line": 762, "end_line": 773, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 775, "end_line": 803, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 818, "end_line": 842, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 844, "end_line": 852, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 854, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 21, "complexity": 1, "token_count": 100, "parameters": [ "name" ], "start_line": 120, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 218, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 244, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 247, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 153, "parameters": [ "self" ], "start_line": 250, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 11, "complexity": 6, "token_count": 138, "parameters": [ "self", "section", "key" ], "start_line": 276, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 288, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 291, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 294, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 297, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 304, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 315, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 325, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 329, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 340, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 350, "end_line": 351, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 353, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 426, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 454, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 75, "complexity": 17, "token_count": 427, "parameters": [ "self" ], "start_line": 462, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 553, "end_line": 564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 570, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 577, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 668, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 685, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 692, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 732, "end_line": 735, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 116, "parameters": [ "self" ], "start_line": 737, "end_line": 756, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 762, "end_line": 772, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 774, "end_line": 802, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 817, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 843, "end_line": 851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 853, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 11, "complexity": 7, "token_count": 142, "parameters": [ "self", "section", "key" ], "start_line": 276, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 12, "complexity": 4, "token_count": 79, "parameters": [ "self" ], "start_line": 762, "end_line": 773, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 } ], "nloc": 754, "complexity": 151, "token_count": 3884, "diff_parsed": { "added": [ " if self.dir_env_var and os.environ.has_key(self.dir_env_var):", " if os.name=='posix':", " for d in default_include_dirs:", " d = os.path.join(d, os.path.basename(py_incl_dir))", " if d not in include_dirs:", " include_dirs.append(d)" ], "deleted": [ " if os.environ.has_key(self.dir_env_var):", " for d in default_include_dirs:", " d = os.path.join(d, os.path.basename(py_incl_dir))", " if d not in include_dirs:", " include_dirs.append(d)", " print numpy_info().get_info()", " print numarray_info().get_info()" ] } } ] }, { "hash": "fcfff555fc0310884802637545dbe4df96b99c35", "msg": "Fixed test_nt missing arg.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-02T16:19:51+00:00", "author_timezone": 0, "committer_date": "2004-02-02T16:19:51+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "78aa98e2bc6b4bc1cb0d39dc8c43a40fc2a96215" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/exec_command.py", "new_path": "scipy_distutils/exec_command.py", "filename": "exec_command.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -436,7 +436,7 @@ def _exec_command( command, use_shell=None, **env ):\n return status, text\n \n \n-def test_nt():\n+def test_nt(**kws):\n pythonexe = get_pythonexe()\n \n if 1: ## not (sys.platform=='win32' and os.environ.get('OSTYPE','')=='cygwin'):\n", "added_lines": 1, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n#\n# exec_command\n#\n# Implements exec_command function that is (almost) equivalent to\n# commands.getstatusoutput function but on NT, DOS systems the\n# returned status is actually correct (though, the returned status\n# values may be different by a factor). In addition, exec_command\n# takes keyword arguments for (re-)defining environment variables.\n#\n# Provides functions:\n# exec_command --- execute command in a specified directory and\n# in the modified environment.\n# splitcmdline --- inverse of ' '.join(argv)\n# find_executable --- locate a command using info from environment\n# variable PATH. Equivalent to posix `which`\n# command.\n#\n# Author: Pearu Peterson \n# Created: 11 January 2003\n#\n# Requires: Python 2.x\n#\n# Succesfully tested on:\n# os.name | sys.platform | comments\n# --------+--------------+----------\n# posix | linux2 | Debian (sid) Linux, Python 2.1.3+, 2.2.3+, 2.3.3\n# PyCrust 0.9.3, Idle 1.0.2\n# posix | linux2 | Red Hat 9 Linux, Python 2.1.3, 2.2.2, 2.3.2\n# posix | sunos5 | SunOS 5.9, Python 2.2, 2.3.2\n# posix | darwin | Darwin 7.2.0, Python 2.3\n# nt | win32 | Windows Me\n# Python 2.3(EE), Idle 1.0, PyCrust 0.7.2\n# Python 2.1.1 Idle 0.8\n# nt | win32 | Windows 98, Python 2.1.1. Idle 0.8\n# nt | win32 | Cygwin 98-4.10, Python 2.1.1(MSC) - echo tests\n# fail i.e. redefining environment variables may\n# not work. FIXED: don't use cygwin echo!\n# posix | cygwin | Cygwin 98-4.10, Python 2.3.3(cygming special)\n\n__all__ = ['exec_command','find_executable']\n\nimport os\nimport re\nimport sys\nimport tempfile\n\n############################################################\n\ntry:\n import logging\n log = logging.getLogger('exec_command')\nexcept ImportError:\n class logging:\n DEBUG = 0\n def info(self,message): print 'info:',message\n def warn(self,message): print 'warn:',message\n def debug(self,message): print 'debug:',message\n def basicConfig(self): pass\n def setLevel(self,level): pass\n log = logging = logging()\n\n############################################################\n\ndef get_pythonexe():\n pythonexe = sys.executable\n if os.name in ['nt','dos']:\n fdir,fn = os.path.split(pythonexe)\n fn = fn.upper().replace('PYTHONW','PYTHON')\n pythonexe = os.path.join(fdir,fn)\n assert os.path.isfile(pythonexe),`pythonexe`+' is not a file'\n return pythonexe\n\n############################################################\n\ndef splitcmdline(line):\n \"\"\" Inverse of ' '.join(sys.argv).\n \"\"\"\n log.info('splitcmdline(%r)' % (line))\n lst = []\n flag = 0\n s,pc,cc = '','',''\n for nc in line+' ':\n if flag==0:\n flag = (pc != '\\\\' and \\\n ((cc=='\"' and 1) or (cc==\"'\" and 2) or \\\n (cc==' ' and pc!=' ' and -2))) or flag\n elif flag==1:\n flag = (cc=='\"' and pc!='\\\\' and nc==' ' and -1) or flag\n elif flag==2:\n flag = (cc==\"'\" and pc!='\\\\' and nc==' ' and -1) or flag\n if flag!=-2:\n s += cc\n if flag<0:\n flag = 0\n s = s.strip()\n if s:\n lst.append(s)\n s = ''\n pc,cc = cc,nc\n else:\n s = s.strip()\n if s:\n lst.append(s)\n log.debug('splitcmdline -> %r' % (lst))\n return lst\n\ndef test_splitcmdline():\n l = splitcmdline('a b cc')\n assert l==['a','b','cc'],`l`\n l = splitcmdline('a')\n assert l==['a'],`l`\n l = splitcmdline('a \" b cc\"')\n assert l==['a','\" b cc\"'],`l`\n l = splitcmdline('\"a bcc\" -h')\n assert l==['\"a bcc\"','-h'],`l`\n l = splitcmdline(r'\"\\\"a \\\" bcc\" -h')\n assert l==[r'\"\\\"a \\\" bcc\"','-h'],`l`\n l = splitcmdline(\" 'a bcc' -h\")\n assert l==[\"'a bcc'\",'-h'],`l`\n l = splitcmdline(r\"'\\'a \\' bcc' -h\")\n assert l==[r\"'\\'a \\' bcc'\",'-h'],`l`\n\n############################################################\n\ndef find_executable(exe, path=None):\n \"\"\" Return full path of a executable.\n \"\"\"\n log.info('find_executable(%r)' % exe)\n if path is None:\n path = os.environ.get('PATH',os.defpath)\n suffices = ['']\n if os.name in ['nt','dos','os2']:\n fn,ext = os.path.splitext(exe)\n extra_suffices = ['.exe','.com','.bat']\n if ext.lower() not in extra_suffices:\n suffices = extra_suffices\n if os.path.isabs(exe):\n paths = ['']\n else:\n paths = map(os.path.abspath, path.split(os.pathsep))\n if os.name == 'nt':\n # Remove cygwin path components\n new_paths = []\n for path in paths:\n d,p = os.path.splitdrive(path)\n if p.lower().find('cygwin') >= 0:\n log.debug('removing \"%s\" from PATH' % (path))\n else:\n new_paths.append(path)\n paths = new_paths\n for path in paths:\n fn = os.path.join(path,exe)\n for s in suffices:\n f_ext = fn+s\n if os.path.isfile(f_ext) and os.access(f_ext,os.X_OK):\n log.debug('Found executable %s' % f_ext)\n return f_ext\n if not os.path.isfile(exe) or os.access(exe,os.X_OK):\n log.warn('Could not locate executable %s' % exe)\n return exe\n\n############################################################\n\ndef _preserve_environment( names ):\n log.debug('_preserve_environment(%r)' % (names))\n env = {}\n for name in names:\n env[name] = os.environ.get(name)\n return env\n\ndef _update_environment( **env ):\n log.debug('_update_environment(...)')\n for name,value in env.items():\n os.environ[name] = value or ''\n\ndef exec_command( command,\n execute_in='', use_shell=None, use_tee = None,\n _with_python = 1,\n **env ):\n \"\"\" Return (status,output) of executed command.\n\n command is a concatenated string of executable and arguments.\n The output contains both stdout and stderr messages.\n The following special keyword arguments can be used:\n use_shell - execute `sh -c command`\n use_tee - pipe the output of command through tee\n execute_in - before command `cd execute_in` and after `cd -`.\n\n On NT, DOS systems the returned status is correct for external commands.\n Wild cards will not work for non-posix systems or when use_shell=0.\n \"\"\"\n log.info('exec_command(%r,%s)' % (command,\\\n ','.join(['%s=%r'%kv for kv in env.items()])))\n\n if use_tee is None:\n use_tee = os.name=='posix'\n if use_shell is None:\n use_shell = os.name=='posix'\n execute_in = os.path.abspath(execute_in)\n oldcwd = os.path.abspath(os.getcwd())\n\n if __name__[-12:] == 'exec_command':\n exec_dir = os.path.dirname(os.path.abspath(__file__))\n elif os.path.isfile('exec_command.py'):\n exec_dir = os.path.abspath('.')\n else:\n exec_dir = os.path.abspath(sys.argv[0])\n if os.path.isfile(exec_dir):\n exec_dir = os.path.dirname(exec_dir)\n\n if oldcwd!=execute_in:\n os.chdir(execute_in)\n log.debug('New cwd: %s' % execute_in)\n else:\n log.debug('Retaining cwd: %s' % oldcwd)\n\n oldenv = _preserve_environment( env.keys() )\n _update_environment( **env )\n\n try:\n # _exec_command is robust but slow, it relies on\n # usable sys.std*.fileno() descriptors. If they\n # are bad (like in win32 Idle, PyCrust environments)\n # then _exec_command_python (even slower)\n # will be used as a last resort.\n #\n # _exec_command_posix uses os.system and is faster\n # but not on all platforms os.system will return\n # a correct status.\n if _with_python and (0 or sys.__stdout__.fileno()==-1):\n st = _exec_command_python(command,\n exec_command_dir = exec_dir,\n **env)\n elif os.name=='posix' and sys.platform[:5]!='sunos':\n st = _exec_command_posix(command,\n use_shell=use_shell,\n use_tee=use_tee,\n **env)\n else:\n st = _exec_command(command, use_shell=use_shell, **env)\n finally:\n if oldcwd!=execute_in:\n os.chdir(oldcwd)\n log.debug('Restored cwd to %s' % oldcwd)\n _update_environment(**oldenv)\n\n return st\n\ndef _exec_command_posix( command,\n use_shell = None,\n use_tee = None,\n **env ):\n log.debug('_exec_command_posix(...)')\n\n if type(command) is type([]):\n command_str = ' '.join(command)\n else:\n command_str = command\n\n tmpfile = tempfile.mktemp()\n stsfile = None\n if use_tee:\n stsfile = tempfile.mktemp()\n filter = ''\n if use_tee == 2:\n filter = r'| tr -cd \"\\n\" | tr \"\\n\" \".\"; echo'\n command_posix = '( %s ; echo $? > %s ) 2>&1 | tee %s %s'\\\n % (command_str,stsfile,tmpfile,filter)\n else:\n stsfile = tempfile.mktemp()\n command_posix = '( %s ; echo $? > %s ) > %s 2>&1'\\\n % (command_str,stsfile,tmpfile)\n #command_posix = '( %s ) > %s 2>&1' % (command_str,tmpfile)\n\n log.debug('Running os.system(%r)' % (command_posix))\n status = os.system(command_posix)\n\n if use_tee:\n if status:\n # if command_tee fails then fall back to robust exec_command\n log.warn('_exec_command_posix failed (status=%s)' % status)\n return _exec_command(command, use_shell=use_shell, **env)\n if stsfile is not None:\n f = open(stsfile,'r')\n status = int(f.read())\n f.close()\n os.remove(stsfile)\n\n f = open(tmpfile,'r')\n text = f.read()\n f.close()\n os.remove(tmpfile)\n\n if text[-1:]=='\\n':\n text = text[:-1]\n \n return status, text\n\n\ndef _exec_command_python(command,\n exec_command_dir='', **env):\n log.debug('_exec_command_python(...)')\n\n python_exe = get_pythonexe()\n cmdfile = tempfile.mktemp()\n stsfile = tempfile.mktemp()\n outfile = tempfile.mktemp()\n\n f = open(cmdfile,'w')\n f.write('import os\\n')\n f.write('import sys\\n')\n f.write('sys.path.insert(0,%r)\\n' % (exec_command_dir))\n f.write('from exec_command import exec_command\\n')\n f.write('del sys.path[0]\\n')\n f.write('cmd = %r\\n' % command)\n f.write('os.environ = %r\\n' % (os.environ))\n f.write('s,o = exec_command(cmd, _with_python=0, **%r)\\n' % (env))\n f.write('f=open(%r,\"w\")\\nf.write(str(s))\\nf.close()\\n' % (stsfile))\n f.write('f=open(%r,\"w\")\\nf.write(o)\\nf.close()\\n' % (outfile))\n f.close()\n\n cmd = '%s %s' % (python_exe, cmdfile)\n status = os.system(cmd)\n assert not status,`cmd`+' failed'\n os.remove(cmdfile)\n\n f = open(stsfile,'r')\n status = int(f.read())\n f.close()\n os.remove(stsfile)\n \n f = open(outfile,'r')\n text = f.read()\n f.close()\n os.remove(outfile)\n \n return status, text\n\n\ndef _exec_command( command, use_shell=None, **env ):\n log.debug('_exec_command(...)')\n \n if use_shell is None:\n use_shell = os.name=='posix'\n\n using_command = 0\n if use_shell:\n # We use shell (unless use_shell==0) so that wildcards can be\n # used.\n sh = os.environ.get('SHELL','/bin/sh')\n if type(command) is type([]):\n argv = [sh,'-c'] + command\n else:\n argv = [sh,'-c',command]\n else:\n # On NT, DOS we avoid using command.com as it's exit status is\n # not related to the exit status of a command.\n if type(command) is type([]):\n argv = command[:]\n else:\n argv = splitcmdline(command)\n \n if hasattr(os,'spawnvpe'):\n spawn_command = os.spawnvpe\n else:\n spawn_command = os.spawnve\n argv[0] = find_executable(argv[0])\n if not os.path.isfile(argv[0]):\n log.warn('Executable %s does not exist' % (argv[0]))\n if os.name in ['nt','dos']:\n # argv[0] might be internal command\n argv = [os.environ['COMSPEC'],'/C']+argv\n using_command = 1\n\n # sys.__std*__ is used instead of sys.std* because environments\n # like IDLE, PyCrust, etc overwrite sys.std* commands.\n so_fileno = sys.__stdout__.fileno()\n se_fileno = sys.__stderr__.fileno()\n so_flush = sys.__stdout__.flush\n se_flush = sys.__stderr__.flush\n so_dup = os.dup(so_fileno)\n se_dup = os.dup(se_fileno)\n\n outfile = tempfile.mktemp()\n fout = open(outfile,'w')\n if using_command:\n errfile = tempfile.mktemp()\n ferr = open(errfile,'w')\n\n log.debug('Running %s(%s,%r,%r,os.environ)' \\\n % (spawn_command.__name__,os.P_WAIT,argv[0],argv))\n\n so_flush()\n se_flush()\n os.dup2(fout.fileno(),so_fileno)\n if using_command:\n os.dup2(ferr.fileno(),se_fileno)\n else:\n os.dup2(fout.fileno(),se_fileno)\n\n try:\n status = spawn_command(os.P_WAIT,argv[0],argv,os.environ)\n except OSError,errmess:\n status = 999\n sys.stderr.write('%s: %s'%(errmess,argv[0]))\n\n so_flush()\n se_flush()\n os.dup2(so_dup,so_fileno)\n os.dup2(se_dup,se_fileno)\n\n fout.close()\n fout = open(outfile,'r')\n text = fout.read()\n fout.close()\n os.remove(outfile)\n\n if using_command:\n ferr.close()\n ferr = open(errfile,'r')\n errmess = ferr.read()\n ferr.close()\n os.remove(errfile)\n if errmess and not status:\n status = 998\n if text:\n text = text + '\\n'\n text = '%sCOMMAND %r FAILED: %s' %(text,command,errmess)\n\n if text[-1:]=='\\n':\n text = text[:-1]\n if status is None:\n status = 0\n\n return status, text\n\n\ndef test_nt(**kws):\n pythonexe = get_pythonexe()\n\n if 1: ## not (sys.platform=='win32' and os.environ.get('OSTYPE','')=='cygwin'):\n s,o=exec_command('echo Hello')\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo a%AAA%')\n assert s==0 and o=='a',(s,o)\n\n s,o=exec_command('echo a%AAA%',AAA='Tere')\n assert s==0 and o=='aTere',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('echo a%BBB%',BBB='Hey')\n assert s==0 and o=='aHey', (s,o)\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('this_is_not_a_command')\n assert s and o!='',(s,o)\n\n s,o=exec_command('type not_existing_file')\n assert s and o!='',(s,o)\n\n s,o=exec_command('echo path=%path%')\n assert s==0 and o!='',(s,o)\n \n s,o=exec_command('%s -c \"import sys;sys.stderr.write(sys.platform)\"' \\\n % pythonexe)\n assert s==0 and o=='win32',(s,o)\n\n s,o=exec_command('%s -c \"raise \\'Ignore me.\\'\"' % pythonexe)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"'\\\n % pythonexe)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.exit(15)\"' % pythonexe)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('%s -c \"print \\'Heipa\\'\"' % pythonexe)\n assert s==0 and o=='Heipa',(s,o)\n\n print 'ok'\n\ndef test_posix(**kws):\n s,o=exec_command(\"echo Hello\",**kws)\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo $AAA',**kws)\n assert s==0 and o=='',(s,o)\n\n s,o=exec_command('echo \"$AAA\"',AAA='Tere',**kws)\n assert s==0 and o=='Tere',(s,o)\n\n\n s,o=exec_command('echo \"$AAA\"',**kws)\n assert s==0 and o=='',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',BBB='Hey',**kws)\n assert s==0 and o=='Hey',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n\n s,o=exec_command('this_is_not_a_command',**kws)\n assert s!=0 and o!='',(s,o)\n\n s,o=exec_command('echo path=$PATH',**kws)\n assert s==0 and o!='',(s,o)\n \n s,o=exec_command('python -c \"import sys,os;sys.stderr.write(os.name)\"',**kws)\n assert s==0 and o=='posix',(s,o)\n\n s,o=exec_command('python -c \"raise \\'Ignore me.\\'\"',**kws)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"',**kws)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.exit(15)\"',**kws)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('python -c \"print \\'Heipa\\'\"',**kws)\n assert s==0 and o=='Heipa',(s,o)\n \n print 'ok'\n\ndef test_execute_in(**kws):\n pythonexe = get_pythonexe()\n tmpfile = tempfile.mktemp()\n fn = os.path.basename(tmpfile)\n tmpdir = os.path.dirname(tmpfile)\n f = open(tmpfile,'w')\n f.write('Hello')\n f.close()\n\n s,o = exec_command('%s -c \"print \\'Ignore following IOError:\\',open(%r,\\'r\\')\"' \\\n % (pythonexe,fn),**kws)\n assert s and o!='',(s,o)\n s,o = exec_command('%s -c \"print open(%r,\\'r\\').read()\"' % (pythonexe,fn),\n execute_in = tmpdir,**kws)\n assert s==0 and o=='Hello',(s,o)\n os.remove(tmpfile)\n print 'ok'\n\nif os.name=='posix':\n test = test_posix\nelif os.name in ['nt','dos']:\n test = test_nt\nelse:\n raise NotImplementedError,'exec_command tests for '+os.name\n\n############################################################\n\nif __name__ == \"__main__\":\n logging.basicConfig()\n log.setLevel(logging.DEBUG)\n\n test_splitcmdline()\n test(use_tee=0)\n test(use_tee=1)\n test_execute_in(use_tee=0)\n test_execute_in(use_tee=1)\n", "source_code_before": "#!/usr/bin/env python\n#\n# exec_command\n#\n# Implements exec_command function that is (almost) equivalent to\n# commands.getstatusoutput function but on NT, DOS systems the\n# returned status is actually correct (though, the returned status\n# values may be different by a factor). In addition, exec_command\n# takes keyword arguments for (re-)defining environment variables.\n#\n# Provides functions:\n# exec_command --- execute command in a specified directory and\n# in the modified environment.\n# splitcmdline --- inverse of ' '.join(argv)\n# find_executable --- locate a command using info from environment\n# variable PATH. Equivalent to posix `which`\n# command.\n#\n# Author: Pearu Peterson \n# Created: 11 January 2003\n#\n# Requires: Python 2.x\n#\n# Succesfully tested on:\n# os.name | sys.platform | comments\n# --------+--------------+----------\n# posix | linux2 | Debian (sid) Linux, Python 2.1.3+, 2.2.3+, 2.3.3\n# PyCrust 0.9.3, Idle 1.0.2\n# posix | linux2 | Red Hat 9 Linux, Python 2.1.3, 2.2.2, 2.3.2\n# posix | sunos5 | SunOS 5.9, Python 2.2, 2.3.2\n# posix | darwin | Darwin 7.2.0, Python 2.3\n# nt | win32 | Windows Me\n# Python 2.3(EE), Idle 1.0, PyCrust 0.7.2\n# Python 2.1.1 Idle 0.8\n# nt | win32 | Windows 98, Python 2.1.1. Idle 0.8\n# nt | win32 | Cygwin 98-4.10, Python 2.1.1(MSC) - echo tests\n# fail i.e. redefining environment variables may\n# not work. FIXED: don't use cygwin echo!\n# posix | cygwin | Cygwin 98-4.10, Python 2.3.3(cygming special)\n\n__all__ = ['exec_command','find_executable']\n\nimport os\nimport re\nimport sys\nimport tempfile\n\n############################################################\n\ntry:\n import logging\n log = logging.getLogger('exec_command')\nexcept ImportError:\n class logging:\n DEBUG = 0\n def info(self,message): print 'info:',message\n def warn(self,message): print 'warn:',message\n def debug(self,message): print 'debug:',message\n def basicConfig(self): pass\n def setLevel(self,level): pass\n log = logging = logging()\n\n############################################################\n\ndef get_pythonexe():\n pythonexe = sys.executable\n if os.name in ['nt','dos']:\n fdir,fn = os.path.split(pythonexe)\n fn = fn.upper().replace('PYTHONW','PYTHON')\n pythonexe = os.path.join(fdir,fn)\n assert os.path.isfile(pythonexe),`pythonexe`+' is not a file'\n return pythonexe\n\n############################################################\n\ndef splitcmdline(line):\n \"\"\" Inverse of ' '.join(sys.argv).\n \"\"\"\n log.info('splitcmdline(%r)' % (line))\n lst = []\n flag = 0\n s,pc,cc = '','',''\n for nc in line+' ':\n if flag==0:\n flag = (pc != '\\\\' and \\\n ((cc=='\"' and 1) or (cc==\"'\" and 2) or \\\n (cc==' ' and pc!=' ' and -2))) or flag\n elif flag==1:\n flag = (cc=='\"' and pc!='\\\\' and nc==' ' and -1) or flag\n elif flag==2:\n flag = (cc==\"'\" and pc!='\\\\' and nc==' ' and -1) or flag\n if flag!=-2:\n s += cc\n if flag<0:\n flag = 0\n s = s.strip()\n if s:\n lst.append(s)\n s = ''\n pc,cc = cc,nc\n else:\n s = s.strip()\n if s:\n lst.append(s)\n log.debug('splitcmdline -> %r' % (lst))\n return lst\n\ndef test_splitcmdline():\n l = splitcmdline('a b cc')\n assert l==['a','b','cc'],`l`\n l = splitcmdline('a')\n assert l==['a'],`l`\n l = splitcmdline('a \" b cc\"')\n assert l==['a','\" b cc\"'],`l`\n l = splitcmdline('\"a bcc\" -h')\n assert l==['\"a bcc\"','-h'],`l`\n l = splitcmdline(r'\"\\\"a \\\" bcc\" -h')\n assert l==[r'\"\\\"a \\\" bcc\"','-h'],`l`\n l = splitcmdline(\" 'a bcc' -h\")\n assert l==[\"'a bcc'\",'-h'],`l`\n l = splitcmdline(r\"'\\'a \\' bcc' -h\")\n assert l==[r\"'\\'a \\' bcc'\",'-h'],`l`\n\n############################################################\n\ndef find_executable(exe, path=None):\n \"\"\" Return full path of a executable.\n \"\"\"\n log.info('find_executable(%r)' % exe)\n if path is None:\n path = os.environ.get('PATH',os.defpath)\n suffices = ['']\n if os.name in ['nt','dos','os2']:\n fn,ext = os.path.splitext(exe)\n extra_suffices = ['.exe','.com','.bat']\n if ext.lower() not in extra_suffices:\n suffices = extra_suffices\n if os.path.isabs(exe):\n paths = ['']\n else:\n paths = map(os.path.abspath, path.split(os.pathsep))\n if os.name == 'nt':\n # Remove cygwin path components\n new_paths = []\n for path in paths:\n d,p = os.path.splitdrive(path)\n if p.lower().find('cygwin') >= 0:\n log.debug('removing \"%s\" from PATH' % (path))\n else:\n new_paths.append(path)\n paths = new_paths\n for path in paths:\n fn = os.path.join(path,exe)\n for s in suffices:\n f_ext = fn+s\n if os.path.isfile(f_ext) and os.access(f_ext,os.X_OK):\n log.debug('Found executable %s' % f_ext)\n return f_ext\n if not os.path.isfile(exe) or os.access(exe,os.X_OK):\n log.warn('Could not locate executable %s' % exe)\n return exe\n\n############################################################\n\ndef _preserve_environment( names ):\n log.debug('_preserve_environment(%r)' % (names))\n env = {}\n for name in names:\n env[name] = os.environ.get(name)\n return env\n\ndef _update_environment( **env ):\n log.debug('_update_environment(...)')\n for name,value in env.items():\n os.environ[name] = value or ''\n\ndef exec_command( command,\n execute_in='', use_shell=None, use_tee = None,\n _with_python = 1,\n **env ):\n \"\"\" Return (status,output) of executed command.\n\n command is a concatenated string of executable and arguments.\n The output contains both stdout and stderr messages.\n The following special keyword arguments can be used:\n use_shell - execute `sh -c command`\n use_tee - pipe the output of command through tee\n execute_in - before command `cd execute_in` and after `cd -`.\n\n On NT, DOS systems the returned status is correct for external commands.\n Wild cards will not work for non-posix systems or when use_shell=0.\n \"\"\"\n log.info('exec_command(%r,%s)' % (command,\\\n ','.join(['%s=%r'%kv for kv in env.items()])))\n\n if use_tee is None:\n use_tee = os.name=='posix'\n if use_shell is None:\n use_shell = os.name=='posix'\n execute_in = os.path.abspath(execute_in)\n oldcwd = os.path.abspath(os.getcwd())\n\n if __name__[-12:] == 'exec_command':\n exec_dir = os.path.dirname(os.path.abspath(__file__))\n elif os.path.isfile('exec_command.py'):\n exec_dir = os.path.abspath('.')\n else:\n exec_dir = os.path.abspath(sys.argv[0])\n if os.path.isfile(exec_dir):\n exec_dir = os.path.dirname(exec_dir)\n\n if oldcwd!=execute_in:\n os.chdir(execute_in)\n log.debug('New cwd: %s' % execute_in)\n else:\n log.debug('Retaining cwd: %s' % oldcwd)\n\n oldenv = _preserve_environment( env.keys() )\n _update_environment( **env )\n\n try:\n # _exec_command is robust but slow, it relies on\n # usable sys.std*.fileno() descriptors. If they\n # are bad (like in win32 Idle, PyCrust environments)\n # then _exec_command_python (even slower)\n # will be used as a last resort.\n #\n # _exec_command_posix uses os.system and is faster\n # but not on all platforms os.system will return\n # a correct status.\n if _with_python and (0 or sys.__stdout__.fileno()==-1):\n st = _exec_command_python(command,\n exec_command_dir = exec_dir,\n **env)\n elif os.name=='posix' and sys.platform[:5]!='sunos':\n st = _exec_command_posix(command,\n use_shell=use_shell,\n use_tee=use_tee,\n **env)\n else:\n st = _exec_command(command, use_shell=use_shell, **env)\n finally:\n if oldcwd!=execute_in:\n os.chdir(oldcwd)\n log.debug('Restored cwd to %s' % oldcwd)\n _update_environment(**oldenv)\n\n return st\n\ndef _exec_command_posix( command,\n use_shell = None,\n use_tee = None,\n **env ):\n log.debug('_exec_command_posix(...)')\n\n if type(command) is type([]):\n command_str = ' '.join(command)\n else:\n command_str = command\n\n tmpfile = tempfile.mktemp()\n stsfile = None\n if use_tee:\n stsfile = tempfile.mktemp()\n filter = ''\n if use_tee == 2:\n filter = r'| tr -cd \"\\n\" | tr \"\\n\" \".\"; echo'\n command_posix = '( %s ; echo $? > %s ) 2>&1 | tee %s %s'\\\n % (command_str,stsfile,tmpfile,filter)\n else:\n stsfile = tempfile.mktemp()\n command_posix = '( %s ; echo $? > %s ) > %s 2>&1'\\\n % (command_str,stsfile,tmpfile)\n #command_posix = '( %s ) > %s 2>&1' % (command_str,tmpfile)\n\n log.debug('Running os.system(%r)' % (command_posix))\n status = os.system(command_posix)\n\n if use_tee:\n if status:\n # if command_tee fails then fall back to robust exec_command\n log.warn('_exec_command_posix failed (status=%s)' % status)\n return _exec_command(command, use_shell=use_shell, **env)\n if stsfile is not None:\n f = open(stsfile,'r')\n status = int(f.read())\n f.close()\n os.remove(stsfile)\n\n f = open(tmpfile,'r')\n text = f.read()\n f.close()\n os.remove(tmpfile)\n\n if text[-1:]=='\\n':\n text = text[:-1]\n \n return status, text\n\n\ndef _exec_command_python(command,\n exec_command_dir='', **env):\n log.debug('_exec_command_python(...)')\n\n python_exe = get_pythonexe()\n cmdfile = tempfile.mktemp()\n stsfile = tempfile.mktemp()\n outfile = tempfile.mktemp()\n\n f = open(cmdfile,'w')\n f.write('import os\\n')\n f.write('import sys\\n')\n f.write('sys.path.insert(0,%r)\\n' % (exec_command_dir))\n f.write('from exec_command import exec_command\\n')\n f.write('del sys.path[0]\\n')\n f.write('cmd = %r\\n' % command)\n f.write('os.environ = %r\\n' % (os.environ))\n f.write('s,o = exec_command(cmd, _with_python=0, **%r)\\n' % (env))\n f.write('f=open(%r,\"w\")\\nf.write(str(s))\\nf.close()\\n' % (stsfile))\n f.write('f=open(%r,\"w\")\\nf.write(o)\\nf.close()\\n' % (outfile))\n f.close()\n\n cmd = '%s %s' % (python_exe, cmdfile)\n status = os.system(cmd)\n assert not status,`cmd`+' failed'\n os.remove(cmdfile)\n\n f = open(stsfile,'r')\n status = int(f.read())\n f.close()\n os.remove(stsfile)\n \n f = open(outfile,'r')\n text = f.read()\n f.close()\n os.remove(outfile)\n \n return status, text\n\n\ndef _exec_command( command, use_shell=None, **env ):\n log.debug('_exec_command(...)')\n \n if use_shell is None:\n use_shell = os.name=='posix'\n\n using_command = 0\n if use_shell:\n # We use shell (unless use_shell==0) so that wildcards can be\n # used.\n sh = os.environ.get('SHELL','/bin/sh')\n if type(command) is type([]):\n argv = [sh,'-c'] + command\n else:\n argv = [sh,'-c',command]\n else:\n # On NT, DOS we avoid using command.com as it's exit status is\n # not related to the exit status of a command.\n if type(command) is type([]):\n argv = command[:]\n else:\n argv = splitcmdline(command)\n \n if hasattr(os,'spawnvpe'):\n spawn_command = os.spawnvpe\n else:\n spawn_command = os.spawnve\n argv[0] = find_executable(argv[0])\n if not os.path.isfile(argv[0]):\n log.warn('Executable %s does not exist' % (argv[0]))\n if os.name in ['nt','dos']:\n # argv[0] might be internal command\n argv = [os.environ['COMSPEC'],'/C']+argv\n using_command = 1\n\n # sys.__std*__ is used instead of sys.std* because environments\n # like IDLE, PyCrust, etc overwrite sys.std* commands.\n so_fileno = sys.__stdout__.fileno()\n se_fileno = sys.__stderr__.fileno()\n so_flush = sys.__stdout__.flush\n se_flush = sys.__stderr__.flush\n so_dup = os.dup(so_fileno)\n se_dup = os.dup(se_fileno)\n\n outfile = tempfile.mktemp()\n fout = open(outfile,'w')\n if using_command:\n errfile = tempfile.mktemp()\n ferr = open(errfile,'w')\n\n log.debug('Running %s(%s,%r,%r,os.environ)' \\\n % (spawn_command.__name__,os.P_WAIT,argv[0],argv))\n\n so_flush()\n se_flush()\n os.dup2(fout.fileno(),so_fileno)\n if using_command:\n os.dup2(ferr.fileno(),se_fileno)\n else:\n os.dup2(fout.fileno(),se_fileno)\n\n try:\n status = spawn_command(os.P_WAIT,argv[0],argv,os.environ)\n except OSError,errmess:\n status = 999\n sys.stderr.write('%s: %s'%(errmess,argv[0]))\n\n so_flush()\n se_flush()\n os.dup2(so_dup,so_fileno)\n os.dup2(se_dup,se_fileno)\n\n fout.close()\n fout = open(outfile,'r')\n text = fout.read()\n fout.close()\n os.remove(outfile)\n\n if using_command:\n ferr.close()\n ferr = open(errfile,'r')\n errmess = ferr.read()\n ferr.close()\n os.remove(errfile)\n if errmess and not status:\n status = 998\n if text:\n text = text + '\\n'\n text = '%sCOMMAND %r FAILED: %s' %(text,command,errmess)\n\n if text[-1:]=='\\n':\n text = text[:-1]\n if status is None:\n status = 0\n\n return status, text\n\n\ndef test_nt():\n pythonexe = get_pythonexe()\n\n if 1: ## not (sys.platform=='win32' and os.environ.get('OSTYPE','')=='cygwin'):\n s,o=exec_command('echo Hello')\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo a%AAA%')\n assert s==0 and o=='a',(s,o)\n\n s,o=exec_command('echo a%AAA%',AAA='Tere')\n assert s==0 and o=='aTere',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('echo a%BBB%',BBB='Hey')\n assert s==0 and o=='aHey', (s,o)\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('this_is_not_a_command')\n assert s and o!='',(s,o)\n\n s,o=exec_command('type not_existing_file')\n assert s and o!='',(s,o)\n\n s,o=exec_command('echo path=%path%')\n assert s==0 and o!='',(s,o)\n \n s,o=exec_command('%s -c \"import sys;sys.stderr.write(sys.platform)\"' \\\n % pythonexe)\n assert s==0 and o=='win32',(s,o)\n\n s,o=exec_command('%s -c \"raise \\'Ignore me.\\'\"' % pythonexe)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"'\\\n % pythonexe)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.exit(15)\"' % pythonexe)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('%s -c \"print \\'Heipa\\'\"' % pythonexe)\n assert s==0 and o=='Heipa',(s,o)\n\n print 'ok'\n\ndef test_posix(**kws):\n s,o=exec_command(\"echo Hello\",**kws)\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo $AAA',**kws)\n assert s==0 and o=='',(s,o)\n\n s,o=exec_command('echo \"$AAA\"',AAA='Tere',**kws)\n assert s==0 and o=='Tere',(s,o)\n\n\n s,o=exec_command('echo \"$AAA\"',**kws)\n assert s==0 and o=='',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',BBB='Hey',**kws)\n assert s==0 and o=='Hey',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n\n s,o=exec_command('this_is_not_a_command',**kws)\n assert s!=0 and o!='',(s,o)\n\n s,o=exec_command('echo path=$PATH',**kws)\n assert s==0 and o!='',(s,o)\n \n s,o=exec_command('python -c \"import sys,os;sys.stderr.write(os.name)\"',**kws)\n assert s==0 and o=='posix',(s,o)\n\n s,o=exec_command('python -c \"raise \\'Ignore me.\\'\"',**kws)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"',**kws)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.exit(15)\"',**kws)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('python -c \"print \\'Heipa\\'\"',**kws)\n assert s==0 and o=='Heipa',(s,o)\n \n print 'ok'\n\ndef test_execute_in(**kws):\n pythonexe = get_pythonexe()\n tmpfile = tempfile.mktemp()\n fn = os.path.basename(tmpfile)\n tmpdir = os.path.dirname(tmpfile)\n f = open(tmpfile,'w')\n f.write('Hello')\n f.close()\n\n s,o = exec_command('%s -c \"print \\'Ignore following IOError:\\',open(%r,\\'r\\')\"' \\\n % (pythonexe,fn),**kws)\n assert s and o!='',(s,o)\n s,o = exec_command('%s -c \"print open(%r,\\'r\\').read()\"' % (pythonexe,fn),\n execute_in = tmpdir,**kws)\n assert s==0 and o=='Hello',(s,o)\n os.remove(tmpfile)\n print 'ok'\n\nif os.name=='posix':\n test = test_posix\nelif os.name in ['nt','dos']:\n test = test_nt\nelse:\n raise NotImplementedError,'exec_command tests for '+os.name\n\n############################################################\n\nif __name__ == \"__main__\":\n logging.basicConfig()\n log.setLevel(logging.DEBUG)\n\n test_splitcmdline()\n test(use_tee=0)\n test(use_tee=1)\n test_execute_in(use_tee=0)\n test_execute_in(use_tee=1)\n", "methods": [ { "name": "get_pythonexe", "long_name": "get_pythonexe( )", "filename": "exec_command.py", "nloc": 8, "complexity": 2, "token_count": 75, "parameters": [], "start_line": 65, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "splitcmdline", "long_name": "splitcmdline( line )", "filename": "exec_command.py", "nloc": 29, "complexity": 25, "token_count": 211, "parameters": [ "line" ], "start_line": 76, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "test_splitcmdline", "long_name": "test_splitcmdline( )", "filename": "exec_command.py", "nloc": 15, "complexity": 1, "token_count": 134, "parameters": [], "start_line": 108, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "find_executable", "long_name": "find_executable( exe , path = None )", "filename": "exec_command.py", "nloc": 33, "complexity": 14, "token_count": 278, "parameters": [ "exe", "path" ], "start_line": 126, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "_preserve_environment", "long_name": "_preserve_environment( names )", "filename": "exec_command.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "names" ], "start_line": 165, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_update_environment", "long_name": "_update_environment( ** env )", "filename": "exec_command.py", "nloc": 4, "complexity": 3, "token_count": 33, "parameters": [ "env" ], "start_line": 172, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "exec_command", "long_name": "exec_command( command , execute_in = '' , use_shell = None , use_tee = None , _with_python = 1 , ** env )", "filename": "exec_command.py", "nloc": 45, "complexity": 15, "token_count": 341, "parameters": [ "command", "execute_in", "use_shell", "use_tee", "_with_python", "env" ], "start_line": 177, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "_exec_command_posix", "long_name": "_exec_command_posix( command , use_shell = None , use_tee = None , ** env )", "filename": "exec_command.py", "nloc": 40, "complexity": 8, "token_count": 241, "parameters": [ "command", "use_shell", "use_tee", "env" ], "start_line": 250, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "_exec_command_python", "long_name": "_exec_command_python( command , exec_command_dir = '' , ** env )", "filename": "exec_command.py", "nloc": 32, "complexity": 1, "token_count": 232, "parameters": [ "command", "exec_command_dir", "env" ], "start_line": 301, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "_exec_command", "long_name": "_exec_command( command , use_shell = None , ** env )", "filename": "exec_command.py", "nloc": 76, "complexity": 17, "token_count": 538, "parameters": [ "command", "use_shell", "env" ], "start_line": 341, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "test_nt", "long_name": "test_nt( ** kws )", "filename": "exec_command.py", "nloc": 35, "complexity": 16, "token_count": 346, "parameters": [ "kws" ], "start_line": 439, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "test_posix", "long_name": "test_posix( ** kws )", "filename": "exec_command.py", "nloc": 31, "complexity": 15, "token_count": 372, "parameters": [ "kws" ], "start_line": 489, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "test_execute_in", "long_name": "test_execute_in( ** kws )", "filename": "exec_command.py", "nloc": 16, "complexity": 3, "token_count": 130, "parameters": [ "kws" ], "start_line": 537, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_pythonexe", "long_name": "get_pythonexe( )", "filename": "exec_command.py", "nloc": 8, "complexity": 2, "token_count": 75, "parameters": [], "start_line": 65, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "splitcmdline", "long_name": "splitcmdline( line )", "filename": "exec_command.py", "nloc": 29, "complexity": 25, "token_count": 211, "parameters": [ "line" ], "start_line": 76, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "test_splitcmdline", "long_name": "test_splitcmdline( )", "filename": "exec_command.py", "nloc": 15, "complexity": 1, "token_count": 134, "parameters": [], "start_line": 108, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "find_executable", "long_name": "find_executable( exe , path = None )", "filename": "exec_command.py", "nloc": 33, "complexity": 14, "token_count": 278, "parameters": [ "exe", "path" ], "start_line": 126, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "_preserve_environment", "long_name": "_preserve_environment( names )", "filename": "exec_command.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "names" ], "start_line": 165, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_update_environment", "long_name": "_update_environment( ** env )", "filename": "exec_command.py", "nloc": 4, "complexity": 3, "token_count": 33, "parameters": [ "env" ], "start_line": 172, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "exec_command", "long_name": "exec_command( command , execute_in = '' , use_shell = None , use_tee = None , _with_python = 1 , ** env )", "filename": "exec_command.py", "nloc": 45, "complexity": 15, "token_count": 341, "parameters": [ "command", "execute_in", "use_shell", "use_tee", "_with_python", "env" ], "start_line": 177, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "_exec_command_posix", "long_name": "_exec_command_posix( command , use_shell = None , use_tee = None , ** env )", "filename": "exec_command.py", "nloc": 40, "complexity": 8, "token_count": 241, "parameters": [ "command", "use_shell", "use_tee", "env" ], "start_line": 250, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "_exec_command_python", "long_name": "_exec_command_python( command , exec_command_dir = '' , ** env )", "filename": "exec_command.py", "nloc": 32, "complexity": 1, "token_count": 232, "parameters": [ "command", "exec_command_dir", "env" ], "start_line": 301, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "_exec_command", "long_name": "_exec_command( command , use_shell = None , ** env )", "filename": "exec_command.py", "nloc": 76, "complexity": 17, "token_count": 538, "parameters": [ "command", "use_shell", "env" ], "start_line": 341, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "test_nt", "long_name": "test_nt( )", "filename": "exec_command.py", "nloc": 35, "complexity": 16, "token_count": 344, "parameters": [], "start_line": 439, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "test_posix", "long_name": "test_posix( ** kws )", "filename": "exec_command.py", "nloc": 31, "complexity": 15, "token_count": 372, "parameters": [ "kws" ], "start_line": 489, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "test_execute_in", "long_name": "test_execute_in( ** kws )", "filename": "exec_command.py", "nloc": 16, "complexity": 3, "token_count": 130, "parameters": [ "kws" ], "start_line": 537, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_nt", "long_name": "test_nt( )", "filename": "exec_command.py", "nloc": 35, "complexity": 16, "token_count": 344, "parameters": [], "start_line": 439, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "test_nt", "long_name": "test_nt( ** kws )", "filename": "exec_command.py", "nloc": 35, "complexity": 16, "token_count": 346, "parameters": [ "kws" ], "start_line": 439, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 } ], "nloc": 401, "complexity": 122, "token_count": 3157, "diff_parsed": { "added": [ "def test_nt(**kws):" ], "deleted": [ "def test_nt():" ] } } ] }, { "hash": "d82b5a62e22ccef47d5fd4b739cfac20046c7adc", "msg": "Added hooks so that Numeric behavior can be changed from within scipy_base", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2004-02-02T17:30:02+00:00", "author_timezone": 0, "committer_date": "2004-02-02T17:30:02+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "fcfff555fc0310884802637545dbe4df96b99c35" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 4, "insertions": 123, "lines": 127, "files": 2, "dmm_unit_size": 0.4057971014492754, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_base/_compiled_base.c", "new_path": "scipy_base/_compiled_base.c", "filename": "_compiled_base.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -678,16 +678,127 @@ static PyObject *map_PyFunc(PyObject *self, PyObject *args)\n return out;\n }\n \n+/* Update Numeric object behavior */\n+\n+/* A copy of the original PyArrayType structure is kept and can be used\n+ to restore the original Numeric behavior at any time. \n+*/\n+\n+static PyTypeObject BackupPyArray_Type;\n+static PyNumberMethods backup_array_as_number;\n+static PySequenceMethods backup_array_as_sequence;\n+static PyMappingMethods backup_array_as_mapping;\n+static PyBufferProcs backup_array_as_buffer;\n+static int numeric_stored = 0;\n+\n+/* make sure memory copy is going on with this */\n+void scipy_numeric_save() {\n+\n+ PyArrayObject *temp=NULL;\n+ int mydims[1]={1};\n+ PyTypeObject *obtype;\n+\n+ if (!numeric_stored) {\n+\ttemp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);\n+\tif (temp==NULL) return;\n+\tobtype = temp->ob_type;\n+\n+\tmemcpy(&BackupPyArray_Type, obtype, sizeof(PyTypeObject));\n+\tmemcpy(&backup_array_as_number, obtype->tp_as_number,\n+\t sizeof(PyNumberMethods));\n+\tmemcpy(&backup_array_as_sequence, obtype->tp_as_sequence,\n+\t sizeof(PySequenceMethods));\n+\tmemcpy(&backup_array_as_mapping, obtype->tp_as_mapping,\n+\t sizeof(PyMappingMethods));\n+\tmemcpy(&backup_array_as_buffer, obtype->tp_as_buffer,\n+\t sizeof(PyBufferProcs));\n+\tnumeric_stored = 1;\n+\tPy_DECREF(temp);\n+ }\n+\n+}\n+\n+void scipy_numeric_restore() {\n+ PyArrayObject *temp=NULL;\n+ int mydims[1]={1};\n+ PyTypeObject *obtype;\n+\n+ if (numeric_stored) {\n+\ttemp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);\n+\tif (temp==NULL) return;\n+\tobtype = temp->ob_type;\n+\n+\tmemcpy(obtype, &BackupPyArray_Type, sizeof(PyTypeObject));\n+\tmemcpy(obtype->tp_as_number, &backup_array_as_number, \n+\t sizeof(PyNumberMethods));\n+\tmemcpy(obtype->tp_as_sequence, &backup_array_as_sequence, \n+\t sizeof(PySequenceMethods));\n+\tmemcpy(obtype->tp_as_mapping, &backup_array_as_mapping,\n+\t sizeof(PyMappingMethods));\n+\tmemcpy(obtype->tp_as_buffer, &backup_array_as_buffer,\n+\t sizeof(PyBufferProcs));\n+\tPy_DECREF(temp);\n+ }\n+}\n+\n+static const char *_scipystr = \"array (scipy)\";\n+\n+void scipy_numeric_alter() {\n+ PyArrayObject *temp=NULL;\n+ int mydims[1]={1};\n+ PyTypeObject *obtype;\n+ \n+\n+ temp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);\n+ if (temp==NULL) return;\n+ obtype = temp->ob_type; \n+ \n+ obtype->tp_name = _scipystr;\n+\n+ Py_DECREF(temp);\n+}\n+\n+static char numeric_alter_doc[] = \"alter_numeric() update the behavior of Numeric objects.\\n\\n 1. Change coercion rules so that multiplying by a scalar does not upcast.\\n 2. Add index slicing capability to Numeric arrays.\\n 3. Speed up inner loops.\\n\\nThis call changes the behavior for ALL Numeric arrays currently defined\\n and to be defined in the future. The old behavior can be restored for ALL\\n arrays using numeric_restore().\";\n+\n+static PyObject *numeric_behavior_alter(PyObject *self, PyObject *args)\n+{\n+\n+ if (!PyArg_ParseTuple ( args, \"\")) return NULL;\n+\n+ scipy_numeric_save();\n+ scipy_numeric_alter();\n+ Py_INCREF(Py_None);\n+ return Py_None;\n+}\n+\n+static char numeric_restore_doc[] = \"restore_numeric() restore the default behavior of Numeric objects.\\n\\n SEE slter_numeric.\\n\";\n+\n+static PyObject *numeric_behavior_restore(PyObject *self, PyObject *args)\n+{\n+\n+ if (!PyArg_ParseTuple ( args, \"\")) return NULL;\n+ \n+ scipy_numeric_restore();\n+ Py_INCREF(Py_None);\n+ return Py_None;\n+}\n \n-/* Initialization function for the module (*must* be called initArray) */\n \n static struct PyMethodDef methods[] = {\n {\"arraymap\", map_PyFunc, METH_VARARGS, arraymap_doc},\n- {\"_unique\",\t (PyCFunction)base_unique, METH_VARARGS | METH_KEYWORDS, doc_base_unique},\n- {\"_insert\",\t (PyCFunction)base_insert, METH_VARARGS | METH_KEYWORDS, doc_base_insert},\n+ {\"_unique\",\t (PyCFunction)base_unique, METH_VARARGS | METH_KEYWORDS, \n+ doc_base_unique},\n+ {\"_insert\",\t (PyCFunction)base_insert, METH_VARARGS | METH_KEYWORDS, \n+ doc_base_insert},\n+ {\"alter_numeric\", numeric_behavior_alter, METH_VARARGS, \n+ numeric_alter_doc},\n+ {\"restore_numeric\", numeric_behavior_restore, METH_VARARGS, \n+ numeric_restore_doc},\n {NULL, NULL} /* sentinel */\n };\n \n+/* Initialization function for the module (*must* be called initArray) */\n+\n DL_EXPORT(void) init_compiled_base(void) {\n PyObject *m, *d, *s;\n \n", "added_lines": 114, "deleted_lines": 3, "source_code": "\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n\n\nstatic char doc_base_unique[] = \"Return the unique elements of a 1-D sequence.\";\n\nstatic PyObject *base_unique(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns a 1-D array containing the unique elements of a 1-D sequence.\n */\n\n void *new_mem=NULL;\n PyArrayObject *ainput=NULL, *aoutput=NULL;\n int asize, abytes, new;\n int copied=0, nd;\n int instride=0, elsize, k, j, dims[1];\n char *ip, *op; /* Current memory buffer */\n char *op2;\n \n static char *kwlist[] = {\"input\", NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!\", kwlist, &PyArray_Type, &ainput)) \n return NULL;\n \n if (ainput->nd > 1) {\n PyErr_SetString(PyExc_ValueError, \"Input array must be < 1 dimensional\");\n return NULL;\n }\n asize = PyArray_SIZE(ainput);\n elsize = ainput->descr->elsize;\n abytes = asize * elsize;\n nd = ainput->nd;\n if (nd > 0) {\n instride = ainput->strides[0];\n }\n\n new_mem = (void *)PyMem_Malloc((size_t) abytes);\n if (new_mem == NULL) {\n return PyErr_NoMemory();\n }\n \n ip = ainput->data;\n op = new_mem;\n for (k=0; k < asize; k++,ip+=instride) {\n new = 1; /* Assume it is new */\n op2 = new_mem;\n for (j=0; j < copied; j++,op2+=elsize) {\n if (memcmp(op2,ip,elsize) == 0) { /* Is a match found? */\n new = 0;\n break;\n }\n }\n /* No match found, copy this one over */\n if (new) {\n memcpy(op,ip,elsize);\n copied += 1;\n op += elsize; /* Get ready to put next match */\n }\n }\n\n dims[0] = copied;\n /* Make output array */\n if ((aoutput = (PyArrayObject *)PyArray_FromDims(nd, \n dims, ainput->descr->type_num))==NULL) goto fail;\n\n memcpy(aoutput->data,new_mem,elsize*copied);\n /* Reallocate memory to new-size */\n PyMem_Free(new_mem);\n return PyArray_Return(aoutput); \n \n fail:\n if (new_mem != NULL) PyMem_Free(new_mem);\n Py_XDECREF(aoutput);\n return NULL;\n}\n\n\nstatic char doc_base_insert[] = \"Insert vals sequenctially into equivalent 1-d positions indicated by mask.\";\n\nstatic PyObject *base_insert(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns input array with values inserted sequentially into places \n indicated by the mask\n */\n\n PyObject *mask=NULL, *vals=NULL;\n PyArrayObject *ainput=NULL, *amask=NULL, *avals=NULL, *avalscast=NULL, *tmp=NULL;\n int numvals, totmask, sameshape;\n char *input_data, *mptr, *vptr, *zero;\n int melsize, delsize, copied, nd;\n int *instrides, *inshape;\n int mindx, rem_indx, indx, i, k, objarray;\n \n static char *kwlist[] = {\"input\",\"mask\",\"vals\",NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!OO\", kwlist, &PyArray_Type, &ainput, &mask, &vals))\n return NULL;\n\n /* Fixed problem with OBJECT ARRAYS\n if (ainput->descr->type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"Not currently supported for Object arrays.\");\n return NULL;\n }\n */\n\n amask = (PyArrayObject *)PyArray_ContiguousFromObject(mask, PyArray_NOTYPE, 0, 0);\n if (amask == NULL) return NULL;\n /* Cast an object array */\n if (amask->descr->type_num == PyArray_OBJECT) {\n tmp = (PyArrayObject *)PyArray_Cast(amask, PyArray_LONG);\n if (tmp == NULL) goto fail;\n Py_DECREF(amask);\n amask = tmp;\n }\n\n sameshape = 1;\n if (amask->nd == ainput->nd) {\n for (k=0; k < amask->nd; k++) \n if (amask->dimensions[k] != ainput->dimensions[k])\n sameshape = 0;\n }\n else { /* Test to see if amask is 1d */\n if (amask->nd != 1) sameshape = 0;\n else if ((PyArray_SIZE(ainput)) != PyArray_SIZE(amask)) sameshape = 0;\n }\n if (!sameshape) {\n PyErr_SetString(PyExc_ValueError, \"Mask array must be 1D or same shape as input array.\");\n goto fail;\n }\n\n avals = (PyArrayObject *)PyArray_FromObject(vals, PyArray_NOTYPE, 0, 1);\n if (avals == NULL) goto fail;\n avalscast = (PyArrayObject *)PyArray_Cast(avals, ainput->descr->type_num);\n if (avalscast == NULL) goto fail;\n Py_DECREF(avals);\n\n numvals = PyArray_SIZE(avalscast);\n nd = ainput->nd;\n input_data = ainput->data;\n mptr = amask->data;\n melsize = amask->descr->elsize;\n vptr = avalscast->data;\n delsize = avalscast->descr->elsize;\n zero = amask->descr->zero;\n objarray = (ainput->descr->type_num == PyArray_OBJECT);\n \n /* Handle zero-dimensional case separately */\n if (nd == 0) {\n if (memcmp(mptr,zero,melsize) != 0) {\n /* Copy value element over to input array */\n memcpy(input_data,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n }\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n /* Walk through mask array, when non-zero is encountered\n copy next value in the vals array to the input array.\n If we get through the value array, repeat it as necessary. \n */\n totmask = PyArray_SIZE(amask);\n copied = 0;\n instrides = ainput->strides;\n inshape = ainput->dimensions;\n for (mindx = 0; mindx < totmask; mindx++) { \n if (memcmp(mptr,zero,melsize) != 0) { \n /* compute indx into input array \n */\n rem_indx = mindx;\n indx = 0;\n for(i=nd-1; i > 0; --i) {\n indx += (rem_indx % inshape[i]) * instrides[i];\n rem_indx /= inshape[i];\n }\n indx += rem_indx * instrides[0];\n /* fprintf(stderr, \"mindx = %d, indx=%d\\n\", mindx, indx); */\n /* Copy value element over to input array */\n memcpy(input_data+indx,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n vptr += delsize;\n copied += 1;\n /* If we move past value data. Reset */\n if (copied >= numvals) vptr = avalscast->data;\n }\n mptr += melsize;\n }\n\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n \n fail:\n Py_XDECREF(amask);\n Py_XDECREF(avals);\n Py_XDECREF(avalscast);\n return NULL;\n}\n\n\n/* Decrement the reference count of all objects in **arrays. */\nstatic void cleanup_arrays(PyArrayObject **arrays, int number)\n{\n int k;\n for (k=0; k < number; k++)\n Py_XDECREF((PyObject *)arrays[k]);\n return;\n}\n\n/* All rank-0 arrays are converted to rank-1 arrays */\n/* The number of dimensions of each array with rank less than\n the rank of the array with the most dimensions is increased by \n prepending with a dimenson length of one so that all arrays have\n the same rank. */\n/* Dimensions are checked and unmatched dimensions triggers an error */\n/* Strides for dimensions whose real length is one is set to zero but the dimension\n length is set to the maximum dimensions for the collection of inputs */\nstatic int setup_input_arrays(PyTupleObject *inputs, PyArrayObject **inputarrays, int nin)\n{\n int i, k;\n int maxrank=1;\n int *maxdims;\n PyObject *inputobj;\n PyArrayObject *ain, *tmparray;\n\n /* Convert nested sequences to arrays or just increase reference count\n if already an array */\n for (i=0; i < nin; i++) {\n ain = NULL;\n inputobj = PyTuple_GET_ITEM(inputs,i);\n ain = (PyArrayObject *)PyArray_FromObject(inputobj,PyArray_ObjectType(inputobj,0),0,0);\n if (NULL == ain) {\n cleanup_arrays(inputarrays,i);\n return -1;\n }\n if (PyArray_SIZE(ain)==0) {\n cleanup_arrays(inputarrays,i);\n PyErr_SetString(PyExc_IndexError,\"arraymap: Input arrays of zero-dimensions not supported.\");\n return -1;\n }\n if (ain->nd > maxrank) maxrank = ain->nd;\n if (ain->nd == 0) { /* turn into 1-d array */\n /* convert to rank-1 array */\n if ((ain->dimensions = (int *)malloc(sizeof(int))) == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,i);\n return -1;\n }\n if ((ain->strides = (int *)malloc(sizeof(int))) == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,i);\n free(ain->dimensions);\n return -1;\n }\n ain->nd = 1;\n ain->dimensions[0] = 1;\n ain->strides[0] = ain->descr->elsize;\n }\n inputarrays[i] = ain;\n }\n\n maxdims = (int*)malloc(2*sizeof(int)*maxrank);\n if (NULL == maxdims) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,nin);\n return -1;\n }\n\n\n /* Reshape all arrays so they have the same rank (pre-pend with length 1 dimensions) */\n /* We want to replace the header information without copying the data. \n Keeping the reference count correct can be tricky.\n We want to make a new array object with a different header and decrease the \n reference count of the old one without deallocating the data section */\n for (i=0; i < nin; i++) {\n ain = inputarrays[i];\n\n /* Initialize all dimensions to 1 */\n /* Change array shape */\n for (k=0; k < maxrank; k++) \n maxdims[k] = 1; \n for (k=maxrank-ain->nd; k< maxrank; k++) \n maxdims[k] = ain->dimensions[k-maxrank+ain->nd];\n\n tmparray = (PyArrayObject *)PyArray_FromDimsAndData(maxrank,maxdims,ain->descr->type,ain->data);\n if (NULL == tmparray) {\n free(maxdims);\n cleanup_arrays(inputarrays,nin);\n return -1;\n }\n memmove(tmparray->strides,ain->strides,sizeof(int)*tmparray->nd);\n tmparray->base = (PyObject *)ain; /* When tmparray is deallocated ain will be too */\n inputarrays[i] = tmparray; /* tmparray is new array */\n }\n\n /* Find dimension length for the output arrays (maximum length for each\n dimension) */\n for (k=0; k < maxrank; k++) { \n maxdims[k] = 1;\n for (i=0; i < nin; i++) \n if (inputarrays[i]->dimensions[k] > maxdims[k])\n\tmaxdims[k] = inputarrays[i]->dimensions[k];\n }\n\n /* Now set all lengths for input array dimensions to maxdims \n and make strides equal to zero for arrays whose\n real length is 1 for a particular dimension\n */\n\n for (i=0; idimensions[k]) {\n\tain->strides[k] = 0;\n\tain->dimensions[k] = maxdims[k];\n }\n else if (ain->dimensions[k] != maxdims[k]) {\n\tPyErr_SetString(PyExc_ValueError,\"arraymap: Frames are not aligned (mismatched dimensions).\");\n\tcleanup_arrays(inputarrays,nin);\n\tfree(maxdims);\n\treturn -1;\n }\n }\n }\n\n free(maxdims);\n return 0;\n\n}\n\nstatic int type_from_object(PyObject *obj)\n{\n if (PyArray_Check(obj))\n return ((PyArrayObject *)obj)->descr->type_num;\n if (PyComplex_Check(obj)) return PyArray_CDOUBLE;\n if (PyFloat_Check(obj)) return PyArray_DOUBLE;\n if (PyInt_Check(obj) || PyLong_Check(obj)) return PyArray_LONG;\n PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for output array.\");\n return -1;\n}\n\nstatic int type_from_char(char typechar)\n{\n switch(typechar) {\n case 'c': return PyArray_CHAR;\n case 'b': return PyArray_UBYTE;\n case '1': return PyArray_SBYTE;\n case 's': return PyArray_SHORT;\n case 'i': return PyArray_INT;\n#ifdef PyArray_UNSIGNED_TYPES\n case 'w': return PyArray_USHORT;\n case 'u': return PyArray_UINT;\n#endif\n case 'l': return PyArray_LONG;\n case 'f': return PyArray_FLOAT;\n case 'd': return PyArray_DOUBLE;\n case 'F': return PyArray_CFLOAT;\n case 'D': return PyArray_CDOUBLE;\n default:\n PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for array\");\n return -1;\n }\n}\n\n\n\n/* This sets up the output arrays by calling the function with arguments \n the first element of each input arrays. If otypes is NULL, the\n returned value type is used to establish the type of the output\n arrays, otherwise the characters in otypes determine the\n output types */\nstatic int setup_output_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject ***outarr, char *otypes, int numtypes)\n{\n PyObject *arglist, *result;\n PyObject *tmpobject;\n PyArrayObject *tmparr;\n int i, nout;\n int nd, *dimensions, type_num;\n\n nd = inarr[0]->nd;\n dimensions = inarr[0]->dimensions;\n\n if ((numtypes == 0) || (otypes == NULL)) { \n /* Call function to get number of outputs */\n\n /* Build argument list */\n if ((arglist = PyTuple_New(nin)) == NULL) {\n return -1;\n }\n /* Construct input argument by creating a tuple with an element\n from each input array (cast to an appropriate Python Object) */\n for (i=0; i < nin; i++) {\n tmparr = inarr[i];\n /* Get first data point */\n tmpobject = tmparr->descr->getitem((void *)tmparr->data);\n if (NULL == tmpobject) {\n\tPy_DECREF(arglist);\n\treturn -1;\n }\n PyTuple_SET_ITEM(arglist, i, tmpobject); /* arg1 owns reference to tmpobj now */\n } \n /* Call Python Function */\n if ((result=PyEval_CallObject(func, arglist))==NULL) {\n Py_DECREF(arglist);\n return -1;\n }\n\n Py_DECREF(arglist);\n\n /* If result is a tuple, create output_arrays according \n to output. */\n if (PyTuple_Check(result)) {\n nout = PyTuple_GET_SIZE(result);\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL == *outarr) {\n\tPyErr_SetString(PyExc_MemoryError, \"arraymap: Cannot allocate memory for output arrays.\");\n\tPy_DECREF(result);\n\treturn -1;\n }\n /* Create nout output arrays */\n for (i=0; i < nout; i++) {\n\t/* Determine type */\n\tif ((type_num=type_from_object(PyTuple_GET_ITEM(result, i)))==-1) {\n\t cleanup_arrays(*outarr,i);\n\t Py_DECREF(result);\n\t free(*outarr);\n\t return -1;\n\t}\n\t/* Create output array */\n\t(*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n\tif (NULL == (*outarr)[i]) {\n\t cleanup_arrays(*outarr,i);\n\t Py_DECREF(result);\n\t free(*outarr);\n\t return -1;\n\t}\n }\n }\n else { /* Only a single output result */\n nout = 1;\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL==*outarr) {\n\tPyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");\n\tPy_DECREF(result);\n\treturn -1;\n }\n if ((type_num = type_from_object(result))==-1) {\n\tPy_DECREF(result);\n\tfree(*outarr);\n\treturn -1;\n }\n (*outarr)[0] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n if (NULL == (*outarr)[0]) {\n\tPy_DECREF(result);\n\tfree(*outarr);\n\treturn -1;\n }\n }\n Py_DECREF(result);\n }\n\n else { /* Character output types entered */\n nout = numtypes;\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL==*outarr) {\n PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");\n return -1;\n }\n /* Create Output arrays */\n for (i=0; i < nout; i++) {\n /* Get type */\n if ((type_num = type_from_char(otypes[i]))==-1) {\n\tcleanup_arrays(*outarr,i);\n\tfree(*outarr);\n\treturn -1;\n }\n /* Create array */\n (*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n if (NULL == (*outarr)[i]) {\n\tcleanup_arrays(*outarr,i);\n\tfree(*outarr);\n\treturn -1;\n }\n } \n } \n return nout;\n}\n\n\n/* Corresponding dimensions are assumed to match, check before calling. */\n/* No rank-0 arrays (make them rank-1 arrays) */\n\n/* This replicates the standard Ufunc broadcasting rule that if the\n dimension length is one, incrementing does not occur for that dimension. \n\n This is currently done by setting the stride in that dimension to\n zero during input array setup.\n\n The purpose of this function is to perform a for loop over arbitrary\n discontiguous N-D arrays, call the Python function for each set of \n corresponding elements and place the results in the output_array.\n*/ \n#define INCREMENT(ret_ind, nd, max_ind) \\\n{ \\\n int k; \\\n k = (nd) - 1; \\\n if (++(ret_ind)[k] >= (max_ind)[k]) { \\\n while (k >= 0 && ((ret_ind)[k] >= (max_ind)[k]-1)) \\\n (ret_ind)[k--] = 0; \\\n if (k >= 0) (ret_ind)[k]++; \\\n else (ret_ind)[0] = (max_ind)[0]; \\\n } \\\n}\n\n#define CALCINDEX(indx, nd_index, strides, ndim) \\\n{ \\\n int i; \\\n \\\n indx = 0; \\\n for (i=0; i < (ndim); i++) \\\n indx += (nd_index)[i]*(strides)[i]; \\\n} \n\nstatic int loop_over_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject **outarr, int nout)\n{\n int i, loop_index;\n int *nd_index, indx_in, indx_out;\n PyArrayObject *in, *out, *tmparr;\n PyObject *result, *tmpobj, *arglist;\n\n in = inarr[0]; /* For any shape information needed */\n out = outarr[0];\n /* Allocate the N-D index initalized to zero. */\n nd_index = (int *)calloc(in->nd,sizeof(int));\n if (NULL == nd_index) {\n PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for arrays.\");\n return -1;\n }\n /* Build argument list */\n if ((arglist = PyTuple_New(nin)) == NULL) {\n free(nd_index);\n return -1;\n }\n\n loop_index = PyArray_Size((PyObject *)in); /* Total number of Python function calls */\n\n while(loop_index--) { \n /* Create input argument list with current element from the input\n arrays \n */\n for (i=0; i < nin; i++) {\n tmparr = inarr[i];\n /* Find linear index into this input array */\n CALCINDEX(indx_in,nd_index,tmparr->strides,in->nd);\n /* Get object at this index */\n tmpobj = tmparr->descr->getitem((void *)(tmparr->data+indx_in));\n if (NULL == tmpobj) {\n\tPy_DECREF(arglist);\n\tfree(nd_index);\n\treturn -1;\n }\n /* This steals reference of tmpobj */\n PyTuple_SET_ITEM(arglist, i, tmpobj); \n }\n /* Call Python Function for this set of inputs */\n if ((result=PyEval_CallObject(func, arglist))==NULL) {\n Py_DECREF(arglist);\n free(nd_index);\n return -1;\n } \n\n /* Find index into (all) output arrays */\n CALCINDEX(indx_out,nd_index,out->strides,out->nd);\n\n /* Copy the results to the output arrays */\n if (1==nout) {\n if ((outarr[0]->descr->setitem(result,(outarr[0]->data+indx_out)))==-1) {\n\tfree(nd_index);\n\tPy_DECREF(arglist);\n\tPy_DECREF(result);\n\treturn -1;\n }\n }\n else if (PyTuple_Check(result)) {\n for (i=0; idescr->setitem(PyTuple_GET_ITEM(result,i),(outarr[i]->data+indx_out)))==-1) {\n\t free(nd_index);\n\t Py_DECREF(arglist);\n\t Py_DECREF(result);\n return -1;\n\t}\n }\n }\n else { \n PyErr_SetString(PyExc_ValueError,\"arraymap: Function output of incorrect type.\");\n free(nd_index);\n Py_DECREF(arglist);\n Py_DECREF(result);\n return -1;\n }\n\n /* Increment the index counter */\n INCREMENT(nd_index,in->nd,in->dimensions);\n Py_DECREF(result);\n\n }\n Py_DECREF(arglist);\n free(nd_index);\n return 0;\n} \n\nstatic PyObject *build_output(PyArrayObject **outarr,int nout)\n{\n int i;\n PyObject *out;\n\n if (1==nout) return PyArray_Return(outarr[0]);\n if ((out=PyTuple_New(nout))==NULL) return NULL;\n for (i=0; iob_type;\n\n\tmemcpy(&BackupPyArray_Type, obtype, sizeof(PyTypeObject));\n\tmemcpy(&backup_array_as_number, obtype->tp_as_number,\n\t sizeof(PyNumberMethods));\n\tmemcpy(&backup_array_as_sequence, obtype->tp_as_sequence,\n\t sizeof(PySequenceMethods));\n\tmemcpy(&backup_array_as_mapping, obtype->tp_as_mapping,\n\t sizeof(PyMappingMethods));\n\tmemcpy(&backup_array_as_buffer, obtype->tp_as_buffer,\n\t sizeof(PyBufferProcs));\n\tnumeric_stored = 1;\n\tPy_DECREF(temp);\n }\n\n}\n\nvoid scipy_numeric_restore() {\n PyArrayObject *temp=NULL;\n int mydims[1]={1};\n PyTypeObject *obtype;\n\n if (numeric_stored) {\n\ttemp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);\n\tif (temp==NULL) return;\n\tobtype = temp->ob_type;\n\n\tmemcpy(obtype, &BackupPyArray_Type, sizeof(PyTypeObject));\n\tmemcpy(obtype->tp_as_number, &backup_array_as_number, \n\t sizeof(PyNumberMethods));\n\tmemcpy(obtype->tp_as_sequence, &backup_array_as_sequence, \n\t sizeof(PySequenceMethods));\n\tmemcpy(obtype->tp_as_mapping, &backup_array_as_mapping,\n\t sizeof(PyMappingMethods));\n\tmemcpy(obtype->tp_as_buffer, &backup_array_as_buffer,\n\t sizeof(PyBufferProcs));\n\tPy_DECREF(temp);\n }\n}\n\nstatic const char *_scipystr = \"array (scipy)\";\n\nvoid scipy_numeric_alter() {\n PyArrayObject *temp=NULL;\n int mydims[1]={1};\n PyTypeObject *obtype;\n \n\n temp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);\n if (temp==NULL) return;\n obtype = temp->ob_type; \n \n obtype->tp_name = _scipystr;\n\n Py_DECREF(temp);\n}\n\nstatic char numeric_alter_doc[] = \"alter_numeric() update the behavior of Numeric objects.\\n\\n 1. Change coercion rules so that multiplying by a scalar does not upcast.\\n 2. Add index slicing capability to Numeric arrays.\\n 3. Speed up inner loops.\\n\\nThis call changes the behavior for ALL Numeric arrays currently defined\\n and to be defined in the future. The old behavior can be restored for ALL\\n arrays using numeric_restore().\";\n\nstatic PyObject *numeric_behavior_alter(PyObject *self, PyObject *args)\n{\n\n if (!PyArg_ParseTuple ( args, \"\")) return NULL;\n\n scipy_numeric_save();\n scipy_numeric_alter();\n Py_INCREF(Py_None);\n return Py_None;\n}\n\nstatic char numeric_restore_doc[] = \"restore_numeric() restore the default behavior of Numeric objects.\\n\\n SEE slter_numeric.\\n\";\n\nstatic PyObject *numeric_behavior_restore(PyObject *self, PyObject *args)\n{\n\n if (!PyArg_ParseTuple ( args, \"\")) return NULL;\n \n scipy_numeric_restore();\n Py_INCREF(Py_None);\n return Py_None;\n}\n\n\nstatic struct PyMethodDef methods[] = {\n {\"arraymap\", map_PyFunc, METH_VARARGS, arraymap_doc},\n {\"_unique\",\t (PyCFunction)base_unique, METH_VARARGS | METH_KEYWORDS, \n doc_base_unique},\n {\"_insert\",\t (PyCFunction)base_insert, METH_VARARGS | METH_KEYWORDS, \n doc_base_insert},\n {\"alter_numeric\", numeric_behavior_alter, METH_VARARGS, \n numeric_alter_doc},\n {\"restore_numeric\", numeric_behavior_restore, METH_VARARGS, \n numeric_restore_doc},\n {NULL, NULL} /* sentinel */\n};\n\n/* Initialization function for the module (*must* be called initArray) */\n\nDL_EXPORT(void) init_compiled_base(void) {\n PyObject *m, *d, *s;\n \n /* Create the module and add the functions */\n m = Py_InitModule(\"_compiled_base\", methods); \n\n /* Import the array and ufunc objects */\n import_array();\n\n /* Add some symbolic constants to the module */\n d = PyModule_GetDict(m);\n\n s = PyString_FromString(\"0.2\");\n PyDict_SetItemString(d, \"__version__\", s);\n Py_DECREF(s);\n\n /* Check for errors */\n if (PyErr_Occurred())\n\tPy_FatalError(\"can't initialize module _compiled_base\");\n}\n\n", "source_code_before": "\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n\n\nstatic char doc_base_unique[] = \"Return the unique elements of a 1-D sequence.\";\n\nstatic PyObject *base_unique(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns a 1-D array containing the unique elements of a 1-D sequence.\n */\n\n void *new_mem=NULL;\n PyArrayObject *ainput=NULL, *aoutput=NULL;\n int asize, abytes, new;\n int copied=0, nd;\n int instride=0, elsize, k, j, dims[1];\n char *ip, *op; /* Current memory buffer */\n char *op2;\n \n static char *kwlist[] = {\"input\", NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!\", kwlist, &PyArray_Type, &ainput)) \n return NULL;\n \n if (ainput->nd > 1) {\n PyErr_SetString(PyExc_ValueError, \"Input array must be < 1 dimensional\");\n return NULL;\n }\n asize = PyArray_SIZE(ainput);\n elsize = ainput->descr->elsize;\n abytes = asize * elsize;\n nd = ainput->nd;\n if (nd > 0) {\n instride = ainput->strides[0];\n }\n\n new_mem = (void *)PyMem_Malloc((size_t) abytes);\n if (new_mem == NULL) {\n return PyErr_NoMemory();\n }\n \n ip = ainput->data;\n op = new_mem;\n for (k=0; k < asize; k++,ip+=instride) {\n new = 1; /* Assume it is new */\n op2 = new_mem;\n for (j=0; j < copied; j++,op2+=elsize) {\n if (memcmp(op2,ip,elsize) == 0) { /* Is a match found? */\n new = 0;\n break;\n }\n }\n /* No match found, copy this one over */\n if (new) {\n memcpy(op,ip,elsize);\n copied += 1;\n op += elsize; /* Get ready to put next match */\n }\n }\n\n dims[0] = copied;\n /* Make output array */\n if ((aoutput = (PyArrayObject *)PyArray_FromDims(nd, \n dims, ainput->descr->type_num))==NULL) goto fail;\n\n memcpy(aoutput->data,new_mem,elsize*copied);\n /* Reallocate memory to new-size */\n PyMem_Free(new_mem);\n return PyArray_Return(aoutput); \n \n fail:\n if (new_mem != NULL) PyMem_Free(new_mem);\n Py_XDECREF(aoutput);\n return NULL;\n}\n\n\nstatic char doc_base_insert[] = \"Insert vals sequenctially into equivalent 1-d positions indicated by mask.\";\n\nstatic PyObject *base_insert(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns input array with values inserted sequentially into places \n indicated by the mask\n */\n\n PyObject *mask=NULL, *vals=NULL;\n PyArrayObject *ainput=NULL, *amask=NULL, *avals=NULL, *avalscast=NULL, *tmp=NULL;\n int numvals, totmask, sameshape;\n char *input_data, *mptr, *vptr, *zero;\n int melsize, delsize, copied, nd;\n int *instrides, *inshape;\n int mindx, rem_indx, indx, i, k, objarray;\n \n static char *kwlist[] = {\"input\",\"mask\",\"vals\",NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!OO\", kwlist, &PyArray_Type, &ainput, &mask, &vals))\n return NULL;\n\n /* Fixed problem with OBJECT ARRAYS\n if (ainput->descr->type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"Not currently supported for Object arrays.\");\n return NULL;\n }\n */\n\n amask = (PyArrayObject *)PyArray_ContiguousFromObject(mask, PyArray_NOTYPE, 0, 0);\n if (amask == NULL) return NULL;\n /* Cast an object array */\n if (amask->descr->type_num == PyArray_OBJECT) {\n tmp = (PyArrayObject *)PyArray_Cast(amask, PyArray_LONG);\n if (tmp == NULL) goto fail;\n Py_DECREF(amask);\n amask = tmp;\n }\n\n sameshape = 1;\n if (amask->nd == ainput->nd) {\n for (k=0; k < amask->nd; k++) \n if (amask->dimensions[k] != ainput->dimensions[k])\n sameshape = 0;\n }\n else { /* Test to see if amask is 1d */\n if (amask->nd != 1) sameshape = 0;\n else if ((PyArray_SIZE(ainput)) != PyArray_SIZE(amask)) sameshape = 0;\n }\n if (!sameshape) {\n PyErr_SetString(PyExc_ValueError, \"Mask array must be 1D or same shape as input array.\");\n goto fail;\n }\n\n avals = (PyArrayObject *)PyArray_FromObject(vals, PyArray_NOTYPE, 0, 1);\n if (avals == NULL) goto fail;\n avalscast = (PyArrayObject *)PyArray_Cast(avals, ainput->descr->type_num);\n if (avalscast == NULL) goto fail;\n Py_DECREF(avals);\n\n numvals = PyArray_SIZE(avalscast);\n nd = ainput->nd;\n input_data = ainput->data;\n mptr = amask->data;\n melsize = amask->descr->elsize;\n vptr = avalscast->data;\n delsize = avalscast->descr->elsize;\n zero = amask->descr->zero;\n objarray = (ainput->descr->type_num == PyArray_OBJECT);\n \n /* Handle zero-dimensional case separately */\n if (nd == 0) {\n if (memcmp(mptr,zero,melsize) != 0) {\n /* Copy value element over to input array */\n memcpy(input_data,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n }\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n /* Walk through mask array, when non-zero is encountered\n copy next value in the vals array to the input array.\n If we get through the value array, repeat it as necessary. \n */\n totmask = PyArray_SIZE(amask);\n copied = 0;\n instrides = ainput->strides;\n inshape = ainput->dimensions;\n for (mindx = 0; mindx < totmask; mindx++) { \n if (memcmp(mptr,zero,melsize) != 0) { \n /* compute indx into input array \n */\n rem_indx = mindx;\n indx = 0;\n for(i=nd-1; i > 0; --i) {\n indx += (rem_indx % inshape[i]) * instrides[i];\n rem_indx /= inshape[i];\n }\n indx += rem_indx * instrides[0];\n /* fprintf(stderr, \"mindx = %d, indx=%d\\n\", mindx, indx); */\n /* Copy value element over to input array */\n memcpy(input_data+indx,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n vptr += delsize;\n copied += 1;\n /* If we move past value data. Reset */\n if (copied >= numvals) vptr = avalscast->data;\n }\n mptr += melsize;\n }\n\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n \n fail:\n Py_XDECREF(amask);\n Py_XDECREF(avals);\n Py_XDECREF(avalscast);\n return NULL;\n}\n\n\n/* Decrement the reference count of all objects in **arrays. */\nstatic void cleanup_arrays(PyArrayObject **arrays, int number)\n{\n int k;\n for (k=0; k < number; k++)\n Py_XDECREF((PyObject *)arrays[k]);\n return;\n}\n\n/* All rank-0 arrays are converted to rank-1 arrays */\n/* The number of dimensions of each array with rank less than\n the rank of the array with the most dimensions is increased by \n prepending with a dimenson length of one so that all arrays have\n the same rank. */\n/* Dimensions are checked and unmatched dimensions triggers an error */\n/* Strides for dimensions whose real length is one is set to zero but the dimension\n length is set to the maximum dimensions for the collection of inputs */\nstatic int setup_input_arrays(PyTupleObject *inputs, PyArrayObject **inputarrays, int nin)\n{\n int i, k;\n int maxrank=1;\n int *maxdims;\n PyObject *inputobj;\n PyArrayObject *ain, *tmparray;\n\n /* Convert nested sequences to arrays or just increase reference count\n if already an array */\n for (i=0; i < nin; i++) {\n ain = NULL;\n inputobj = PyTuple_GET_ITEM(inputs,i);\n ain = (PyArrayObject *)PyArray_FromObject(inputobj,PyArray_ObjectType(inputobj,0),0,0);\n if (NULL == ain) {\n cleanup_arrays(inputarrays,i);\n return -1;\n }\n if (PyArray_SIZE(ain)==0) {\n cleanup_arrays(inputarrays,i);\n PyErr_SetString(PyExc_IndexError,\"arraymap: Input arrays of zero-dimensions not supported.\");\n return -1;\n }\n if (ain->nd > maxrank) maxrank = ain->nd;\n if (ain->nd == 0) { /* turn into 1-d array */\n /* convert to rank-1 array */\n if ((ain->dimensions = (int *)malloc(sizeof(int))) == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,i);\n return -1;\n }\n if ((ain->strides = (int *)malloc(sizeof(int))) == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,i);\n free(ain->dimensions);\n return -1;\n }\n ain->nd = 1;\n ain->dimensions[0] = 1;\n ain->strides[0] = ain->descr->elsize;\n }\n inputarrays[i] = ain;\n }\n\n maxdims = (int*)malloc(2*sizeof(int)*maxrank);\n if (NULL == maxdims) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,nin);\n return -1;\n }\n\n\n /* Reshape all arrays so they have the same rank (pre-pend with length 1 dimensions) */\n /* We want to replace the header information without copying the data. \n Keeping the reference count correct can be tricky.\n We want to make a new array object with a different header and decrease the \n reference count of the old one without deallocating the data section */\n for (i=0; i < nin; i++) {\n ain = inputarrays[i];\n\n /* Initialize all dimensions to 1 */\n /* Change array shape */\n for (k=0; k < maxrank; k++) \n maxdims[k] = 1; \n for (k=maxrank-ain->nd; k< maxrank; k++) \n maxdims[k] = ain->dimensions[k-maxrank+ain->nd];\n\n tmparray = (PyArrayObject *)PyArray_FromDimsAndData(maxrank,maxdims,ain->descr->type,ain->data);\n if (NULL == tmparray) {\n free(maxdims);\n cleanup_arrays(inputarrays,nin);\n return -1;\n }\n memmove(tmparray->strides,ain->strides,sizeof(int)*tmparray->nd);\n tmparray->base = (PyObject *)ain; /* When tmparray is deallocated ain will be too */\n inputarrays[i] = tmparray; /* tmparray is new array */\n }\n\n /* Find dimension length for the output arrays (maximum length for each\n dimension) */\n for (k=0; k < maxrank; k++) { \n maxdims[k] = 1;\n for (i=0; i < nin; i++) \n if (inputarrays[i]->dimensions[k] > maxdims[k])\n\tmaxdims[k] = inputarrays[i]->dimensions[k];\n }\n\n /* Now set all lengths for input array dimensions to maxdims \n and make strides equal to zero for arrays whose\n real length is 1 for a particular dimension\n */\n\n for (i=0; idimensions[k]) {\n\tain->strides[k] = 0;\n\tain->dimensions[k] = maxdims[k];\n }\n else if (ain->dimensions[k] != maxdims[k]) {\n\tPyErr_SetString(PyExc_ValueError,\"arraymap: Frames are not aligned (mismatched dimensions).\");\n\tcleanup_arrays(inputarrays,nin);\n\tfree(maxdims);\n\treturn -1;\n }\n }\n }\n\n free(maxdims);\n return 0;\n\n}\n\nstatic int type_from_object(PyObject *obj)\n{\n if (PyArray_Check(obj))\n return ((PyArrayObject *)obj)->descr->type_num;\n if (PyComplex_Check(obj)) return PyArray_CDOUBLE;\n if (PyFloat_Check(obj)) return PyArray_DOUBLE;\n if (PyInt_Check(obj) || PyLong_Check(obj)) return PyArray_LONG;\n PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for output array.\");\n return -1;\n}\n\nstatic int type_from_char(char typechar)\n{\n switch(typechar) {\n case 'c': return PyArray_CHAR;\n case 'b': return PyArray_UBYTE;\n case '1': return PyArray_SBYTE;\n case 's': return PyArray_SHORT;\n case 'i': return PyArray_INT;\n#ifdef PyArray_UNSIGNED_TYPES\n case 'w': return PyArray_USHORT;\n case 'u': return PyArray_UINT;\n#endif\n case 'l': return PyArray_LONG;\n case 'f': return PyArray_FLOAT;\n case 'd': return PyArray_DOUBLE;\n case 'F': return PyArray_CFLOAT;\n case 'D': return PyArray_CDOUBLE;\n default:\n PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for array\");\n return -1;\n }\n}\n\n\n\n/* This sets up the output arrays by calling the function with arguments \n the first element of each input arrays. If otypes is NULL, the\n returned value type is used to establish the type of the output\n arrays, otherwise the characters in otypes determine the\n output types */\nstatic int setup_output_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject ***outarr, char *otypes, int numtypes)\n{\n PyObject *arglist, *result;\n PyObject *tmpobject;\n PyArrayObject *tmparr;\n int i, nout;\n int nd, *dimensions, type_num;\n\n nd = inarr[0]->nd;\n dimensions = inarr[0]->dimensions;\n\n if ((numtypes == 0) || (otypes == NULL)) { \n /* Call function to get number of outputs */\n\n /* Build argument list */\n if ((arglist = PyTuple_New(nin)) == NULL) {\n return -1;\n }\n /* Construct input argument by creating a tuple with an element\n from each input array (cast to an appropriate Python Object) */\n for (i=0; i < nin; i++) {\n tmparr = inarr[i];\n /* Get first data point */\n tmpobject = tmparr->descr->getitem((void *)tmparr->data);\n if (NULL == tmpobject) {\n\tPy_DECREF(arglist);\n\treturn -1;\n }\n PyTuple_SET_ITEM(arglist, i, tmpobject); /* arg1 owns reference to tmpobj now */\n } \n /* Call Python Function */\n if ((result=PyEval_CallObject(func, arglist))==NULL) {\n Py_DECREF(arglist);\n return -1;\n }\n\n Py_DECREF(arglist);\n\n /* If result is a tuple, create output_arrays according \n to output. */\n if (PyTuple_Check(result)) {\n nout = PyTuple_GET_SIZE(result);\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL == *outarr) {\n\tPyErr_SetString(PyExc_MemoryError, \"arraymap: Cannot allocate memory for output arrays.\");\n\tPy_DECREF(result);\n\treturn -1;\n }\n /* Create nout output arrays */\n for (i=0; i < nout; i++) {\n\t/* Determine type */\n\tif ((type_num=type_from_object(PyTuple_GET_ITEM(result, i)))==-1) {\n\t cleanup_arrays(*outarr,i);\n\t Py_DECREF(result);\n\t free(*outarr);\n\t return -1;\n\t}\n\t/* Create output array */\n\t(*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n\tif (NULL == (*outarr)[i]) {\n\t cleanup_arrays(*outarr,i);\n\t Py_DECREF(result);\n\t free(*outarr);\n\t return -1;\n\t}\n }\n }\n else { /* Only a single output result */\n nout = 1;\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL==*outarr) {\n\tPyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");\n\tPy_DECREF(result);\n\treturn -1;\n }\n if ((type_num = type_from_object(result))==-1) {\n\tPy_DECREF(result);\n\tfree(*outarr);\n\treturn -1;\n }\n (*outarr)[0] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n if (NULL == (*outarr)[0]) {\n\tPy_DECREF(result);\n\tfree(*outarr);\n\treturn -1;\n }\n }\n Py_DECREF(result);\n }\n\n else { /* Character output types entered */\n nout = numtypes;\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL==*outarr) {\n PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");\n return -1;\n }\n /* Create Output arrays */\n for (i=0; i < nout; i++) {\n /* Get type */\n if ((type_num = type_from_char(otypes[i]))==-1) {\n\tcleanup_arrays(*outarr,i);\n\tfree(*outarr);\n\treturn -1;\n }\n /* Create array */\n (*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n if (NULL == (*outarr)[i]) {\n\tcleanup_arrays(*outarr,i);\n\tfree(*outarr);\n\treturn -1;\n }\n } \n } \n return nout;\n}\n\n\n/* Corresponding dimensions are assumed to match, check before calling. */\n/* No rank-0 arrays (make them rank-1 arrays) */\n\n/* This replicates the standard Ufunc broadcasting rule that if the\n dimension length is one, incrementing does not occur for that dimension. \n\n This is currently done by setting the stride in that dimension to\n zero during input array setup.\n\n The purpose of this function is to perform a for loop over arbitrary\n discontiguous N-D arrays, call the Python function for each set of \n corresponding elements and place the results in the output_array.\n*/ \n#define INCREMENT(ret_ind, nd, max_ind) \\\n{ \\\n int k; \\\n k = (nd) - 1; \\\n if (++(ret_ind)[k] >= (max_ind)[k]) { \\\n while (k >= 0 && ((ret_ind)[k] >= (max_ind)[k]-1)) \\\n (ret_ind)[k--] = 0; \\\n if (k >= 0) (ret_ind)[k]++; \\\n else (ret_ind)[0] = (max_ind)[0]; \\\n } \\\n}\n\n#define CALCINDEX(indx, nd_index, strides, ndim) \\\n{ \\\n int i; \\\n \\\n indx = 0; \\\n for (i=0; i < (ndim); i++) \\\n indx += (nd_index)[i]*(strides)[i]; \\\n} \n\nstatic int loop_over_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject **outarr, int nout)\n{\n int i, loop_index;\n int *nd_index, indx_in, indx_out;\n PyArrayObject *in, *out, *tmparr;\n PyObject *result, *tmpobj, *arglist;\n\n in = inarr[0]; /* For any shape information needed */\n out = outarr[0];\n /* Allocate the N-D index initalized to zero. */\n nd_index = (int *)calloc(in->nd,sizeof(int));\n if (NULL == nd_index) {\n PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for arrays.\");\n return -1;\n }\n /* Build argument list */\n if ((arglist = PyTuple_New(nin)) == NULL) {\n free(nd_index);\n return -1;\n }\n\n loop_index = PyArray_Size((PyObject *)in); /* Total number of Python function calls */\n\n while(loop_index--) { \n /* Create input argument list with current element from the input\n arrays \n */\n for (i=0; i < nin; i++) {\n tmparr = inarr[i];\n /* Find linear index into this input array */\n CALCINDEX(indx_in,nd_index,tmparr->strides,in->nd);\n /* Get object at this index */\n tmpobj = tmparr->descr->getitem((void *)(tmparr->data+indx_in));\n if (NULL == tmpobj) {\n\tPy_DECREF(arglist);\n\tfree(nd_index);\n\treturn -1;\n }\n /* This steals reference of tmpobj */\n PyTuple_SET_ITEM(arglist, i, tmpobj); \n }\n /* Call Python Function for this set of inputs */\n if ((result=PyEval_CallObject(func, arglist))==NULL) {\n Py_DECREF(arglist);\n free(nd_index);\n return -1;\n } \n\n /* Find index into (all) output arrays */\n CALCINDEX(indx_out,nd_index,out->strides,out->nd);\n\n /* Copy the results to the output arrays */\n if (1==nout) {\n if ((outarr[0]->descr->setitem(result,(outarr[0]->data+indx_out)))==-1) {\n\tfree(nd_index);\n\tPy_DECREF(arglist);\n\tPy_DECREF(result);\n\treturn -1;\n }\n }\n else if (PyTuple_Check(result)) {\n for (i=0; idescr->setitem(PyTuple_GET_ITEM(result,i),(outarr[i]->data+indx_out)))==-1) {\n\t free(nd_index);\n\t Py_DECREF(arglist);\n\t Py_DECREF(result);\n return -1;\n\t}\n }\n }\n else { \n PyErr_SetString(PyExc_ValueError,\"arraymap: Function output of incorrect type.\");\n free(nd_index);\n Py_DECREF(arglist);\n Py_DECREF(result);\n return -1;\n }\n\n /* Increment the index counter */\n INCREMENT(nd_index,in->nd,in->dimensions);\n Py_DECREF(result);\n\n }\n Py_DECREF(arglist);\n free(nd_index);\n return 0;\n} \n\nstatic PyObject *build_output(PyArrayObject **outarr,int nout)\n{\n int i;\n PyObject *out;\n\n if (1==nout) return PyArray_Return(outarr[0]);\n if ((out=PyTuple_New(nout))==NULL) return NULL;\n for (i=0; iob_type;", "", "\tmemcpy(&BackupPyArray_Type, obtype, sizeof(PyTypeObject));", "\tmemcpy(&backup_array_as_number, obtype->tp_as_number,", "\t sizeof(PyNumberMethods));", "\tmemcpy(&backup_array_as_sequence, obtype->tp_as_sequence,", "\t sizeof(PySequenceMethods));", "\tmemcpy(&backup_array_as_mapping, obtype->tp_as_mapping,", "\t sizeof(PyMappingMethods));", "\tmemcpy(&backup_array_as_buffer, obtype->tp_as_buffer,", "\t sizeof(PyBufferProcs));", "\tnumeric_stored = 1;", "\tPy_DECREF(temp);", " }", "", "}", "", "void scipy_numeric_restore() {", " PyArrayObject *temp=NULL;", " int mydims[1]={1};", " PyTypeObject *obtype;", "", " if (numeric_stored) {", "\ttemp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);", "\tif (temp==NULL) return;", "\tobtype = temp->ob_type;", "", "\tmemcpy(obtype, &BackupPyArray_Type, sizeof(PyTypeObject));", "\tmemcpy(obtype->tp_as_number, &backup_array_as_number,", "\t sizeof(PyNumberMethods));", "\tmemcpy(obtype->tp_as_sequence, &backup_array_as_sequence,", "\t sizeof(PySequenceMethods));", "\tmemcpy(obtype->tp_as_mapping, &backup_array_as_mapping,", "\t sizeof(PyMappingMethods));", "\tmemcpy(obtype->tp_as_buffer, &backup_array_as_buffer,", "\t sizeof(PyBufferProcs));", "\tPy_DECREF(temp);", " }", "}", "", "static const char *_scipystr = \"array (scipy)\";", "", "void scipy_numeric_alter() {", " PyArrayObject *temp=NULL;", " int mydims[1]={1};", " PyTypeObject *obtype;", "", "", " temp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);", " if (temp==NULL) return;", " obtype = temp->ob_type;", "", " obtype->tp_name = _scipystr;", "", " Py_DECREF(temp);", "}", "", "static char numeric_alter_doc[] = \"alter_numeric() update the behavior of Numeric objects.\\n\\n 1. Change coercion rules so that multiplying by a scalar does not upcast.\\n 2. Add index slicing capability to Numeric arrays.\\n 3. Speed up inner loops.\\n\\nThis call changes the behavior for ALL Numeric arrays currently defined\\n and to be defined in the future. The old behavior can be restored for ALL\\n arrays using numeric_restore().\";", "", "static PyObject *numeric_behavior_alter(PyObject *self, PyObject *args)", "{", "", " if (!PyArg_ParseTuple ( args, \"\")) return NULL;", "", " scipy_numeric_save();", " scipy_numeric_alter();", " Py_INCREF(Py_None);", " return Py_None;", "}", "", "static char numeric_restore_doc[] = \"restore_numeric() restore the default behavior of Numeric objects.\\n\\n SEE slter_numeric.\\n\";", "", "static PyObject *numeric_behavior_restore(PyObject *self, PyObject *args)", "{", "", " if (!PyArg_ParseTuple ( args, \"\")) return NULL;", "", " scipy_numeric_restore();", " Py_INCREF(Py_None);", " return Py_None;", "}", " {\"_unique\",\t (PyCFunction)base_unique, METH_VARARGS | METH_KEYWORDS,", " doc_base_unique},", " {\"_insert\",\t (PyCFunction)base_insert, METH_VARARGS | METH_KEYWORDS,", " doc_base_insert},", " {\"alter_numeric\", numeric_behavior_alter, METH_VARARGS,", " numeric_alter_doc},", " {\"restore_numeric\", numeric_behavior_restore, METH_VARARGS,", " numeric_restore_doc},", "/* Initialization function for the module (*must* be called initArray) */", "" ], "deleted": [ "/* Initialization function for the module (*must* be called initArray) */", " {\"_unique\",\t (PyCFunction)base_unique, METH_VARARGS | METH_KEYWORDS, doc_base_unique},", " {\"_insert\",\t (PyCFunction)base_insert, METH_VARARGS | METH_KEYWORDS, doc_base_insert}," ] } }, { "old_path": "scipy_base/function_base.py", "new_path": "scipy_base/function_base.py", "filename": "function_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -13,7 +13,15 @@\n 'select','trim_zeros','amax','amin', 'alen', 'ptp','cumsum','take',\n 'copy', 'prod','cumprod','diff','angle','unwrap','sort_complex',\n 'disp','unique','extract','insert','nansum','nanmax','nanargmax',\n- 'nanargmin','nanmin','sum','vectorize','asarray_chkfinite']\n+ 'nanargmin','nanmin','sum','vectorize','asarray_chkfinite',\n+ 'alter_numeric', 'restore_numeric','isaltered']\n+\n+alter_numeric = _compiled_base.alter_numeric\n+restore_numeric = _compiled_base.restore_numeric\n+\n+def isaltered():\n+ val = str(type(array([1])))\n+ return 'scipy' in val\n \n round = Numeric.around\n \n", "added_lines": 9, "deleted_lines": 1, "source_code": "\nimport types\nimport Numeric\nfrom Numeric import ravel, nonzero, array, choose, ones, zeros, \\\n sometrue, alltrue, reshape\nfrom type_check import ScalarType, isscalar, asarray\nfrom shape_base import squeeze, atleast_1d\nfrom fastumath import PINF as inf\nfrom fastumath import *\nimport _compiled_base\n\n__all__ = ['round','any','all','logspace','linspace','fix','mod',\n 'select','trim_zeros','amax','amin', 'alen', 'ptp','cumsum','take',\n 'copy', 'prod','cumprod','diff','angle','unwrap','sort_complex',\n 'disp','unique','extract','insert','nansum','nanmax','nanargmax',\n 'nanargmin','nanmin','sum','vectorize','asarray_chkfinite',\n 'alter_numeric', 'restore_numeric','isaltered']\n\nalter_numeric = _compiled_base.alter_numeric\nrestore_numeric = _compiled_base.restore_numeric\n\ndef isaltered():\n val = str(type(array([1])))\n return 'scipy' in val\n\nround = Numeric.around\n\ndef asarray_chkfinite(x):\n \"\"\"Like asarray except it checks to be sure no NaNs or Infs are present.\n \"\"\"\n x = asarray(x)\n if not all(isfinite(x)):\n raise ValueError, \"Array must not contain infs or nans.\"\n return x \n\ndef any(x):\n \"\"\"Return true if any elements of x are true: sometrue(ravel(x))\n \"\"\"\n return sometrue(ravel(x))\n\n\ndef all(x):\n \"\"\"Return true if all elements of x are true: alltrue(ravel(x))\n \"\"\"\n return alltrue(ravel(x))\n\n# Need this to change array type for low precision values\ndef sum(x,axis=0): # could change default axis here\n x = asarray(x)\n if x.typecode() in ['1','s','b','w']:\n x = x.astype('l')\n return Numeric.sum(x,axis)\n \n\ndef logspace(start,stop,num=50,endpoint=1):\n \"\"\" Evenly spaced samples on a logarithmic scale.\n\n Return num evenly spaced samples from 10**start to 10**stop. If\n endpoint=1 then last sample is 10**stop.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start\n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n return Numeric.power(10.0,y)\n\ndef linspace(start,stop,num=50,endpoint=1,retstep=0):\n \"\"\" Evenly spaced samples.\n \n Return num evenly spaced samples from start to stop. If endpoint=1 then\n last sample is stop. If retstep is 1 then return the step value used.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start \n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n if retstep:\n return y, step\n else:\n return y\n\ndef fix(x):\n \"\"\" Round x to nearest integer towards zero.\n \"\"\"\n x = asarray(x)\n y = Numeric.floor(x)\n return Numeric.where(x<0,y+1,y)\n\ndef mod(x,y):\n \"\"\" x - y*floor(x/y)\n \n For numeric arrays, x % y has the same sign as x while\n mod(x,y) has the same sign as y.\n \"\"\"\n return x - y*Numeric.floor(x*1.0/y)\n\ndef select(condlist, choicelist, default=0):\n \"\"\" Returns an array comprised from different elements of choicelist\n depending on the list of conditions.\n\n condlist is a list of condition arrays containing ones or zeros\n \n choicelist is a list of choice matrices (of the \"same\" size as the\n arrays in condlist). The result array has the \"same\" size as the\n arrays in choicelist. If condlist is [c0,...,cN-1] then choicelist\n must be of length N. The elements of the choicelist can then be\n represented as [v0,...,vN-1]. The default choice if none of the\n conditions are met is given as the default argument. \n \n The conditions are tested in order and the first one statisfied is\n used to select the choice. In other words, the elements of the\n output array are found from the following tree (notice the order of\n the conditions matters):\n \n if c0: v0\n elif c1: v1\n elif c2: v2\n ...\n elif cN-1: vN-1\n else: default\n \n Note, that one of the condition arrays must be large enough to handle\n the largest array in the choice list.\n \"\"\"\n n = len(condlist)\n n2 = len(choicelist)\n if n2 != n:\n raise ValueError, \"List of cases, must be same length as the list of conditions.\"\n choicelist.insert(0,default) \n S = 0\n pfac = 1\n for k in range(1,n+1):\n S += k * pfac * asarray(condlist[k-1])\n if k < n:\n pfac *= (1-asarray(condlist[k-1]))\n # handle special case of a 1-element condition but\n # a multi-element choice\n if type(S) in ScalarType or max(asarray(S).shape)==1:\n pfac = asarray(1)\n for k in range(n2+1):\n pfac = pfac + asarray(choicelist[k]) \n S = S*ones(asarray(pfac).shape)\n return choose(S, tuple(choicelist))\n\ndef _asarray1d(arr):\n \"\"\"Ensure 1d array for one array.\n \"\"\"\n m = asarray(arr)\n if len(m.shape)==0:\n m = reshape(m,(1,))\n return m\n\ndef copy(a):\n \"\"\"Return an array copy of the object.\n \"\"\"\n return array(a,copy=1)\n\ndef take(a, indices, axis=0):\n \"\"\"Selects the elements in indices from array a along given axis.\n \"\"\"\n try:\n a = Numeric.take(a,indices,axis)\n except ValueError: # a is scalar\n pass\n return a\n \n# Basic operations\ndef amax(m,axis=-1):\n \"\"\"Returns the maximum of m along dimension axis. \n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = _asarray1d(m)\n return maximum.reduce(m,axis)\n\ndef amin(m,axis=-1):\n \"\"\"Returns the minimum of m along dimension axis.\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else: \n m = _asarray1d(m)\n return minimum.reduce(m,axis)\n\ndef alen(m):\n \"\"\"Returns the length of a Python object interpreted as an array\n \"\"\"\n return len(asarray(m))\n\n# Actually from Basis, but it fits in so naturally here...\n\ndef ptp(m,axis=-1):\n \"\"\"Returns the maximum - minimum along the the given dimension\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = _asarray1d(m)\n return amax(m,axis)-amin(m,axis)\n\ndef cumsum(m,axis=-1):\n \"\"\"Returns the cumulative sum of the elements along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = _asarray1d(m)\n return add.accumulate(m,axis)\n\ndef prod(m,axis=-1):\n \"\"\"Returns the product of the elements along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = _asarray1d(m)\n return multiply.reduce(m,axis)\n\ndef cumprod(m,axis=-1):\n \"\"\"Returns the cumulative product of the elments along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = _asarray1d(m)\n return multiply.accumulate(m,axis)\n\ndef diff(x, n=1,axis=-1):\n \"\"\"Calculates the nth order, discrete difference along given axis.\n \"\"\"\n x = _asarray1d(x)\n nd = len(x.shape)\n slice1 = [slice(None)]*nd\n slice2 = [slice(None)]*nd\n slice1[axis] = slice(1,None)\n slice2[axis] = slice(None,-1)\n if n > 1:\n return diff(x[slice1]-x[slice2], n-1, axis=axis)\n else:\n return x[slice1]-x[slice2]\n\n \ndef angle(z,deg=0):\n \"\"\"Return the angle of complex argument z.\"\"\"\n if deg:\n fact = 180/pi\n else:\n fact = 1.0\n z = asarray(z)\n if z.typecode() in ['D','F']:\n zimag = z.imag\n zreal = z.real\n else:\n zimag = 0\n zreal = z\n return arctan2(zimag,zreal) * fact\n\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwraps radian phase p by changing absolute jumps greater than\n discont to their 2*pi complement along the given axis.\n \"\"\"\n p = asarray(p)\n nd = len(p.shape)\n dd = diff(p,axis=axis)\n slice1 = [slice(None,None)]*nd # full slices\n slice1[axis] = slice(1,None)\n ddmod = mod(dd+pi,2*pi)-pi\n Numeric.putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n Numeric.putmask(ph_correct,abs(dd)>> import scipy\n >>> a = array((0,0,0,1,2,3,2,1,0))\n >>> scipy.trim_zeros(a)\n array([1, 2, 3, 2, 1])\n \"\"\"\n first = 0\n if 'f' in trim or 'F' in trim:\n for i in filt:\n if i != 0.: break\n else: first = first + 1\n last = len(filt)\n if 'b' in trim or 'B' in trim:\n for i in filt[::-1]:\n if i != 0.: break\n else: last = last - 1\n return filt[first:last]\n\ndef unique(inseq):\n \"\"\"Returns unique items in 1-dimensional sequence.\n \"\"\"\n set = {}\n for item in inseq:\n set[item] = None\n return asarray(set.keys())\n\ndef where(condition,x=None,y=None):\n \"\"\"If x and y are both None, then return the (1-d equivalent) indices\n where condition is true. Otherwise, return an array shaped like\n condition with elements of x and y in the places where condition is\n true or false respectively.\n \"\"\"\n if (x is None) and (y is None):\n # Needs work for multidimensional arrays\n return nonzero(ravel(condition))\n else:\n return choose(not_equal(condition, 0), (y,x))\n \ndef extract(condition, arr):\n \"\"\"Elements of ravel(condition) where ravel(condition) is true (1-d)\n\n Equivalent of compress(ravel(condition), ravel(arr))\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(condition)))\n\ndef insert(arr, mask, vals):\n \"\"\"Similar to putmask arr[mask] = vals but 1d array vals has the\n same number of elements as the non-zero values of mask. Inverse of extract.\n \"\"\"\n return _compiled_base._insert(arr, mask, vals)\n\ndef nansum(x,axis=-1):\n \"\"\"Sum the array over the given axis treating nans as missing values.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),0)\n return Numeric.sum(x,axis)\n\ndef nanmin(x,axis=-1):\n \"\"\"Find the minimium over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return amin(x,axis)\n\ndef nanargmin(x,axis=-1):\n \"\"\"Find the indices of the minimium over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return argmin(x,axis)\n \n\ndef nanmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return amax(x,axis)\n\ndef nanargmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return argmax(x,axis)\n\ndef disp(mesg, device=None, linefeed=1):\n \"\"\"Display a message to device (default is sys.stdout) with(out) linefeed.\n \"\"\"\n if device is None:\n import sys\n device = sys.stdout\n if linefeed:\n device.write('%s\\n' % mesg)\n else:\n device.write('%s' % mesg)\n device.flush()\n return\n\nfrom _compiled_base import arraymap\nclass vectorize:\n \"\"\"\n vectorize(somefunction) Generalized Function class.\n\n Description:\n \n Define a vectorized function which takes nested sequence\n objects or Numeric arrays as inputs and returns a\n Numeric array as output, evaluating the function over successive\n tuples of the input arrays like the python map function except it uses\n the broadcasting rules of Numeric Python.\n\n Input:\n\n somefunction -- a Python function or method\n\n Example:\n\n def myfunc(a,b):\n if a > b:\n return a-b\n else\n return a+b\n\n vfunc = vectorize(myfunc)\n\n >>> vfunc([1,2,3,4],2)\n array([3,4,1,2])\n\n \"\"\"\n def __init__(self,pyfunc,otypes=None,doc=None):\n if not callable(pyfunc) or type(pyfunc) is types.ClassType:\n raise TypeError, \"Object is not a callable Python object.\"\n self.thefunc = pyfunc\n if doc is None:\n self.__doc__ = pyfunc.__doc__\n else:\n self.__doc__ = doc\n if otypes is None:\n self.otypes=''\n else:\n if isinstance(otypes,types.StringType):\n self.otypes=otypes\n else:\n raise ValueError, \"Output types must be a string.\"\n\n def __call__(self,*args):\n try:\n return squeeze(arraymap(self.thefunc,args,self.otypes))\n except IndexError:\n return self.zerocall(*args)\n\n def zerocall(self,*args):\n # one of the args was a zeros array\n # return zeros for each output\n # first --- find number of outputs\n # get it from self.otypes if possible\n # otherwise evaluate function at 0.9\n N = len(self.otypes)\n if N==1:\n return zeros((0,),'d')\n elif N !=0:\n return (zeros((0,),'d'),)*N\n newargs = []\n args = atleast_1d(args)\n for arg in args:\n if arg.typecode() != 'O':\n newargs.append(0.9)\n else:\n newargs.append(arg[0])\n newargs = tuple(newargs)\n try:\n res = self.thefunc(*newargs)\n except:\n raise ValueError, \"Zerocall is failing. \"\\\n \"Try using otypes in vectorize.\"\n if isscalar(res):\n return zeros((0,),'d')\n else:\n return (zeros((0,),'d'),)*len(res)\n\n", "source_code_before": "\nimport types\nimport Numeric\nfrom Numeric import ravel, nonzero, array, choose, ones, zeros, \\\n sometrue, alltrue, reshape\nfrom type_check import ScalarType, isscalar, asarray\nfrom shape_base import squeeze, atleast_1d\nfrom fastumath import PINF as inf\nfrom fastumath import *\nimport _compiled_base\n\n__all__ = ['round','any','all','logspace','linspace','fix','mod',\n 'select','trim_zeros','amax','amin', 'alen', 'ptp','cumsum','take',\n 'copy', 'prod','cumprod','diff','angle','unwrap','sort_complex',\n 'disp','unique','extract','insert','nansum','nanmax','nanargmax',\n 'nanargmin','nanmin','sum','vectorize','asarray_chkfinite']\n\nround = Numeric.around\n\ndef asarray_chkfinite(x):\n \"\"\"Like asarray except it checks to be sure no NaNs or Infs are present.\n \"\"\"\n x = asarray(x)\n if not all(isfinite(x)):\n raise ValueError, \"Array must not contain infs or nans.\"\n return x \n\ndef any(x):\n \"\"\"Return true if any elements of x are true: sometrue(ravel(x))\n \"\"\"\n return sometrue(ravel(x))\n\n\ndef all(x):\n \"\"\"Return true if all elements of x are true: alltrue(ravel(x))\n \"\"\"\n return alltrue(ravel(x))\n\n# Need this to change array type for low precision values\ndef sum(x,axis=0): # could change default axis here\n x = asarray(x)\n if x.typecode() in ['1','s','b','w']:\n x = x.astype('l')\n return Numeric.sum(x,axis)\n \n\ndef logspace(start,stop,num=50,endpoint=1):\n \"\"\" Evenly spaced samples on a logarithmic scale.\n\n Return num evenly spaced samples from 10**start to 10**stop. If\n endpoint=1 then last sample is 10**stop.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start\n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n return Numeric.power(10.0,y)\n\ndef linspace(start,stop,num=50,endpoint=1,retstep=0):\n \"\"\" Evenly spaced samples.\n \n Return num evenly spaced samples from start to stop. If endpoint=1 then\n last sample is stop. If retstep is 1 then return the step value used.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start \n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n if retstep:\n return y, step\n else:\n return y\n\ndef fix(x):\n \"\"\" Round x to nearest integer towards zero.\n \"\"\"\n x = asarray(x)\n y = Numeric.floor(x)\n return Numeric.where(x<0,y+1,y)\n\ndef mod(x,y):\n \"\"\" x - y*floor(x/y)\n \n For numeric arrays, x % y has the same sign as x while\n mod(x,y) has the same sign as y.\n \"\"\"\n return x - y*Numeric.floor(x*1.0/y)\n\ndef select(condlist, choicelist, default=0):\n \"\"\" Returns an array comprised from different elements of choicelist\n depending on the list of conditions.\n\n condlist is a list of condition arrays containing ones or zeros\n \n choicelist is a list of choice matrices (of the \"same\" size as the\n arrays in condlist). The result array has the \"same\" size as the\n arrays in choicelist. If condlist is [c0,...,cN-1] then choicelist\n must be of length N. The elements of the choicelist can then be\n represented as [v0,...,vN-1]. The default choice if none of the\n conditions are met is given as the default argument. \n \n The conditions are tested in order and the first one statisfied is\n used to select the choice. In other words, the elements of the\n output array are found from the following tree (notice the order of\n the conditions matters):\n \n if c0: v0\n elif c1: v1\n elif c2: v2\n ...\n elif cN-1: vN-1\n else: default\n \n Note, that one of the condition arrays must be large enough to handle\n the largest array in the choice list.\n \"\"\"\n n = len(condlist)\n n2 = len(choicelist)\n if n2 != n:\n raise ValueError, \"List of cases, must be same length as the list of conditions.\"\n choicelist.insert(0,default) \n S = 0\n pfac = 1\n for k in range(1,n+1):\n S += k * pfac * asarray(condlist[k-1])\n if k < n:\n pfac *= (1-asarray(condlist[k-1]))\n # handle special case of a 1-element condition but\n # a multi-element choice\n if type(S) in ScalarType or max(asarray(S).shape)==1:\n pfac = asarray(1)\n for k in range(n2+1):\n pfac = pfac + asarray(choicelist[k]) \n S = S*ones(asarray(pfac).shape)\n return choose(S, tuple(choicelist))\n\ndef _asarray1d(arr):\n \"\"\"Ensure 1d array for one array.\n \"\"\"\n m = asarray(arr)\n if len(m.shape)==0:\n m = reshape(m,(1,))\n return m\n\ndef copy(a):\n \"\"\"Return an array copy of the object.\n \"\"\"\n return array(a,copy=1)\n\ndef take(a, indices, axis=0):\n \"\"\"Selects the elements in indices from array a along given axis.\n \"\"\"\n try:\n a = Numeric.take(a,indices,axis)\n except ValueError: # a is scalar\n pass\n return a\n \n# Basic operations\ndef amax(m,axis=-1):\n \"\"\"Returns the maximum of m along dimension axis. \n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = _asarray1d(m)\n return maximum.reduce(m,axis)\n\ndef amin(m,axis=-1):\n \"\"\"Returns the minimum of m along dimension axis.\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else: \n m = _asarray1d(m)\n return minimum.reduce(m,axis)\n\ndef alen(m):\n \"\"\"Returns the length of a Python object interpreted as an array\n \"\"\"\n return len(asarray(m))\n\n# Actually from Basis, but it fits in so naturally here...\n\ndef ptp(m,axis=-1):\n \"\"\"Returns the maximum - minimum along the the given dimension\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = _asarray1d(m)\n return amax(m,axis)-amin(m,axis)\n\ndef cumsum(m,axis=-1):\n \"\"\"Returns the cumulative sum of the elements along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = _asarray1d(m)\n return add.accumulate(m,axis)\n\ndef prod(m,axis=-1):\n \"\"\"Returns the product of the elements along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = _asarray1d(m)\n return multiply.reduce(m,axis)\n\ndef cumprod(m,axis=-1):\n \"\"\"Returns the cumulative product of the elments along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = _asarray1d(m)\n return multiply.accumulate(m,axis)\n\ndef diff(x, n=1,axis=-1):\n \"\"\"Calculates the nth order, discrete difference along given axis.\n \"\"\"\n x = _asarray1d(x)\n nd = len(x.shape)\n slice1 = [slice(None)]*nd\n slice2 = [slice(None)]*nd\n slice1[axis] = slice(1,None)\n slice2[axis] = slice(None,-1)\n if n > 1:\n return diff(x[slice1]-x[slice2], n-1, axis=axis)\n else:\n return x[slice1]-x[slice2]\n\n \ndef angle(z,deg=0):\n \"\"\"Return the angle of complex argument z.\"\"\"\n if deg:\n fact = 180/pi\n else:\n fact = 1.0\n z = asarray(z)\n if z.typecode() in ['D','F']:\n zimag = z.imag\n zreal = z.real\n else:\n zimag = 0\n zreal = z\n return arctan2(zimag,zreal) * fact\n\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwraps radian phase p by changing absolute jumps greater than\n discont to their 2*pi complement along the given axis.\n \"\"\"\n p = asarray(p)\n nd = len(p.shape)\n dd = diff(p,axis=axis)\n slice1 = [slice(None,None)]*nd # full slices\n slice1[axis] = slice(1,None)\n ddmod = mod(dd+pi,2*pi)-pi\n Numeric.putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n Numeric.putmask(ph_correct,abs(dd)>> import scipy\n >>> a = array((0,0,0,1,2,3,2,1,0))\n >>> scipy.trim_zeros(a)\n array([1, 2, 3, 2, 1])\n \"\"\"\n first = 0\n if 'f' in trim or 'F' in trim:\n for i in filt:\n if i != 0.: break\n else: first = first + 1\n last = len(filt)\n if 'b' in trim or 'B' in trim:\n for i in filt[::-1]:\n if i != 0.: break\n else: last = last - 1\n return filt[first:last]\n\ndef unique(inseq):\n \"\"\"Returns unique items in 1-dimensional sequence.\n \"\"\"\n set = {}\n for item in inseq:\n set[item] = None\n return asarray(set.keys())\n\ndef where(condition,x=None,y=None):\n \"\"\"If x and y are both None, then return the (1-d equivalent) indices\n where condition is true. Otherwise, return an array shaped like\n condition with elements of x and y in the places where condition is\n true or false respectively.\n \"\"\"\n if (x is None) and (y is None):\n # Needs work for multidimensional arrays\n return nonzero(ravel(condition))\n else:\n return choose(not_equal(condition, 0), (y,x))\n \ndef extract(condition, arr):\n \"\"\"Elements of ravel(condition) where ravel(condition) is true (1-d)\n\n Equivalent of compress(ravel(condition), ravel(arr))\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(condition)))\n\ndef insert(arr, mask, vals):\n \"\"\"Similar to putmask arr[mask] = vals but 1d array vals has the\n same number of elements as the non-zero values of mask. Inverse of extract.\n \"\"\"\n return _compiled_base._insert(arr, mask, vals)\n\ndef nansum(x,axis=-1):\n \"\"\"Sum the array over the given axis treating nans as missing values.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),0)\n return Numeric.sum(x,axis)\n\ndef nanmin(x,axis=-1):\n \"\"\"Find the minimium over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return amin(x,axis)\n\ndef nanargmin(x,axis=-1):\n \"\"\"Find the indices of the minimium over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return argmin(x,axis)\n \n\ndef nanmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return amax(x,axis)\n\ndef nanargmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return argmax(x,axis)\n\ndef disp(mesg, device=None, linefeed=1):\n \"\"\"Display a message to device (default is sys.stdout) with(out) linefeed.\n \"\"\"\n if device is None:\n import sys\n device = sys.stdout\n if linefeed:\n device.write('%s\\n' % mesg)\n else:\n device.write('%s' % mesg)\n device.flush()\n return\n\nfrom _compiled_base import arraymap\nclass vectorize:\n \"\"\"\n vectorize(somefunction) Generalized Function class.\n\n Description:\n \n Define a vectorized function which takes nested sequence\n objects or Numeric arrays as inputs and returns a\n Numeric array as output, evaluating the function over successive\n tuples of the input arrays like the python map function except it uses\n the broadcasting rules of Numeric Python.\n\n Input:\n\n somefunction -- a Python function or method\n\n Example:\n\n def myfunc(a,b):\n if a > b:\n return a-b\n else\n return a+b\n\n vfunc = vectorize(myfunc)\n\n >>> vfunc([1,2,3,4],2)\n array([3,4,1,2])\n\n \"\"\"\n def __init__(self,pyfunc,otypes=None,doc=None):\n if not callable(pyfunc) or type(pyfunc) is types.ClassType:\n raise TypeError, \"Object is not a callable Python object.\"\n self.thefunc = pyfunc\n if doc is None:\n self.__doc__ = pyfunc.__doc__\n else:\n self.__doc__ = doc\n if otypes is None:\n self.otypes=''\n else:\n if isinstance(otypes,types.StringType):\n self.otypes=otypes\n else:\n raise ValueError, \"Output types must be a string.\"\n\n def __call__(self,*args):\n try:\n return squeeze(arraymap(self.thefunc,args,self.otypes))\n except IndexError:\n return self.zerocall(*args)\n\n def zerocall(self,*args):\n # one of the args was a zeros array\n # return zeros for each output\n # first --- find number of outputs\n # get it from self.otypes if possible\n # otherwise evaluate function at 0.9\n N = len(self.otypes)\n if N==1:\n return zeros((0,),'d')\n elif N !=0:\n return (zeros((0,),'d'),)*N\n newargs = []\n args = atleast_1d(args)\n for arg in args:\n if arg.typecode() != 'O':\n newargs.append(0.9)\n else:\n newargs.append(arg[0])\n newargs = tuple(newargs)\n try:\n res = self.thefunc(*newargs)\n except:\n raise ValueError, \"Zerocall is failing. \"\\\n \"Try using otypes in vectorize.\"\n if isscalar(res):\n return zeros((0,),'d')\n else:\n return (zeros((0,),'d'),)*len(res)\n\n", "methods": [ { "name": "isaltered", "long_name": "isaltered( )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [], "start_line": 22, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "asarray_chkfinite", "long_name": "asarray_chkfinite( x )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [ "x" ], "start_line": 28, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "any", "long_name": "any( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 36, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "all", "long_name": "all( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 42, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 48, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "logspace", "long_name": "logspace( start , stop , num = 50 , endpoint = 1 )", "filename": "function_base.py", "nloc": 9, "complexity": 3, "token_count": 99, "parameters": [ "start", "stop", "num", "endpoint" ], "start_line": 55, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "linspace", "long_name": "linspace( start , stop , num = 50 , endpoint = 1 , retstep = 0 )", "filename": "function_base.py", "nloc": 12, "complexity": 4, "token_count": 103, "parameters": [ "start", "stop", "num", "endpoint", "retstep" ], "start_line": 70, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "fix", "long_name": "fix( x )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 35, "parameters": [ "x" ], "start_line": 88, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "mod", "long_name": "mod( x , y )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "x", "y" ], "start_line": 95, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "select", "long_name": "select( condlist , choicelist , default = 0 )", "filename": "function_base.py", "nloc": 18, "complexity": 7, "token_count": 165, "parameters": [ "condlist", "choicelist", "default" ], "start_line": 103, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_asarray1d", "long_name": "_asarray1d( arr )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "arr" ], "start_line": 151, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "copy", "long_name": "copy( a )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 159, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "take", "long_name": "take( a , indices , axis = 0 )", "filename": "function_base.py", "nloc": 6, "complexity": 2, "token_count": 32, "parameters": [ "a", "indices", "axis" ], "start_line": 164, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "amax", "long_name": "amax( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 174, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "amin", "long_name": "amin( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 184, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "alen", "long_name": "alen( m )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "m" ], "start_line": 194, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "ptp", "long_name": "ptp( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "m", "axis" ], "start_line": 201, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "cumsum", "long_name": "cumsum( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 211, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "prod", "long_name": "prod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 221, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "cumprod", "long_name": "cumprod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 231, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "diff", "long_name": "diff( x , n = 1 , axis = - 1 )", "filename": "function_base.py", "nloc": 11, "complexity": 2, "token_count": 110, "parameters": [ "x", "n", "axis" ], "start_line": 241, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "angle", "long_name": "angle( z , deg = 0 )", "filename": "function_base.py", "nloc": 13, "complexity": 3, "token_count": 71, "parameters": [ "z", "deg" ], "start_line": 256, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "unwrap", "long_name": "unwrap( p , discont = pi , axis = - 1 )", "filename": "function_base.py", "nloc": 13, "complexity": 1, "token_count": 150, "parameters": [ "p", "discont", "axis" ], "start_line": 271, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "sort_complex.complex_cmp", "long_name": "sort_complex.complex_cmp( x , y )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 38, "parameters": [ "x", "y" ], "start_line": 292, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "sort_complex", "long_name": "sort_complex( a )", "filename": "function_base.py", "nloc": 6, "complexity": 1, "token_count": 44, "parameters": [ "a" ], "start_line": 288, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "trim_zeros", "long_name": "trim_zeros( filt , trim = 'fb' )", "filename": "function_base.py", "nloc": 12, "complexity": 9, "token_count": 87, "parameters": [ "filt", "trim" ], "start_line": 301, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "unique", "long_name": "unique( inseq )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 30, "parameters": [ "inseq" ], "start_line": 322, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "where", "long_name": "where( condition , x = None , y = None )", "filename": "function_base.py", "nloc": 5, "complexity": 3, "token_count": 53, "parameters": [ "condition", "x", "y" ], "start_line": 330, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( condition , arr )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "condition", "arr" ], "start_line": 342, "end_line": 347, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "insert", "long_name": "insert( arr , mask , vals )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "arr", "mask", "vals" ], "start_line": 349, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "nansum", "long_name": "nansum( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "x", "axis" ], "start_line": 355, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmin", "long_name": "nanmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "x", "axis" ], "start_line": 362, "end_line": 367, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmin", "long_name": "nanargmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "x", "axis" ], "start_line": 369, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmax", "long_name": "nanmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 377, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmax", "long_name": "nanargmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 384, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "disp", "long_name": "disp( mesg , device = None , linefeed = 1 )", "filename": "function_base.py", "nloc": 10, "complexity": 3, "token_count": 53, "parameters": [ "mesg", "device", "linefeed" ], "start_line": 391, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = None , doc = None )", "filename": "function_base.py", "nloc": 15, "complexity": 6, "token_count": 92, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 435, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "args" ], "start_line": 451, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "zerocall", "long_name": "zerocall( self , * args )", "filename": "function_base.py", "nloc": 23, "complexity": 7, "token_count": 155, "parameters": [ "self", "args" ], "start_line": 457, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 } ], "methods_before": [ { "name": "asarray_chkfinite", "long_name": "asarray_chkfinite( x )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [ "x" ], "start_line": 20, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "any", "long_name": "any( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 28, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "all", "long_name": "all( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 34, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 40, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "logspace", "long_name": "logspace( start , stop , num = 50 , endpoint = 1 )", "filename": "function_base.py", "nloc": 9, "complexity": 3, "token_count": 99, "parameters": [ "start", "stop", "num", "endpoint" ], "start_line": 47, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "linspace", "long_name": "linspace( start , stop , num = 50 , endpoint = 1 , retstep = 0 )", "filename": "function_base.py", "nloc": 12, "complexity": 4, "token_count": 103, "parameters": [ "start", "stop", "num", "endpoint", "retstep" ], "start_line": 62, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "fix", "long_name": "fix( x )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 35, "parameters": [ "x" ], "start_line": 80, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "mod", "long_name": "mod( x , y )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "x", "y" ], "start_line": 87, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "select", "long_name": "select( condlist , choicelist , default = 0 )", "filename": "function_base.py", "nloc": 18, "complexity": 7, "token_count": 165, "parameters": [ "condlist", "choicelist", "default" ], "start_line": 95, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_asarray1d", "long_name": "_asarray1d( arr )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "arr" ], "start_line": 143, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "copy", "long_name": "copy( a )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 151, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "take", "long_name": "take( a , indices , axis = 0 )", "filename": "function_base.py", "nloc": 6, "complexity": 2, "token_count": 32, "parameters": [ "a", "indices", "axis" ], "start_line": 156, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "amax", "long_name": "amax( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 166, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "amin", "long_name": "amin( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 176, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "alen", "long_name": "alen( m )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "m" ], "start_line": 186, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "ptp", "long_name": "ptp( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "m", "axis" ], "start_line": 193, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "cumsum", "long_name": "cumsum( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 203, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "prod", "long_name": "prod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 213, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "cumprod", "long_name": "cumprod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 223, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "diff", "long_name": "diff( x , n = 1 , axis = - 1 )", "filename": "function_base.py", "nloc": 11, "complexity": 2, "token_count": 110, "parameters": [ "x", "n", "axis" ], "start_line": 233, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "angle", "long_name": "angle( z , deg = 0 )", "filename": "function_base.py", "nloc": 13, "complexity": 3, "token_count": 71, "parameters": [ "z", "deg" ], "start_line": 248, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "unwrap", "long_name": "unwrap( p , discont = pi , axis = - 1 )", "filename": "function_base.py", "nloc": 13, "complexity": 1, "token_count": 150, "parameters": [ "p", "discont", "axis" ], "start_line": 263, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "sort_complex.complex_cmp", "long_name": "sort_complex.complex_cmp( x , y )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 38, "parameters": [ "x", "y" ], "start_line": 284, "end_line": 288, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "sort_complex", "long_name": "sort_complex( a )", "filename": "function_base.py", "nloc": 6, "complexity": 1, "token_count": 44, "parameters": [ "a" ], "start_line": 280, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "trim_zeros", "long_name": "trim_zeros( filt , trim = 'fb' )", "filename": "function_base.py", "nloc": 12, "complexity": 9, "token_count": 87, "parameters": [ "filt", "trim" ], "start_line": 293, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "unique", "long_name": "unique( inseq )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 30, "parameters": [ "inseq" ], "start_line": 314, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "where", "long_name": "where( condition , x = None , y = None )", "filename": "function_base.py", "nloc": 5, "complexity": 3, "token_count": 53, "parameters": [ "condition", "x", "y" ], "start_line": 322, "end_line": 332, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( condition , arr )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "condition", "arr" ], "start_line": 334, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "insert", "long_name": "insert( arr , mask , vals )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "arr", "mask", "vals" ], "start_line": 341, "end_line": 345, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "nansum", "long_name": "nansum( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "x", "axis" ], "start_line": 347, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmin", "long_name": "nanmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "x", "axis" ], "start_line": 354, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmin", "long_name": "nanargmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "x", "axis" ], "start_line": 361, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmax", "long_name": "nanmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 369, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmax", "long_name": "nanargmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 376, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "disp", "long_name": "disp( mesg , device = None , linefeed = 1 )", "filename": "function_base.py", "nloc": 10, "complexity": 3, "token_count": 53, "parameters": [ "mesg", "device", "linefeed" ], "start_line": 383, "end_line": 394, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = None , doc = None )", "filename": "function_base.py", "nloc": 15, "complexity": 6, "token_count": 92, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 427, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "args" ], "start_line": 443, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "zerocall", "long_name": "zerocall( self , * args )", "filename": "function_base.py", "nloc": 23, "complexity": 7, "token_count": 155, "parameters": [ "self", "args" ], "start_line": 449, "end_line": 476, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "isaltered", "long_name": "isaltered( )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [], "start_line": 22, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 314, "complexity": 89, "token_count": 2271, "diff_parsed": { "added": [ " 'nanargmin','nanmin','sum','vectorize','asarray_chkfinite',", " 'alter_numeric', 'restore_numeric','isaltered']", "", "alter_numeric = _compiled_base.alter_numeric", "restore_numeric = _compiled_base.restore_numeric", "", "def isaltered():", " val = str(type(array([1])))", " return 'scipy' in val" ], "deleted": [ " 'nanargmin','nanmin','sum','vectorize','asarray_chkfinite']" ] } } ] }, { "hash": "0d9e6cd3d9f35efb3a1694a4c5da78f926b452c0", "msg": "Only backup part of PyArray_Type array to avoid occasional garbage-collection-related segfault on Python cleanup.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2004-02-03T21:14:45+00:00", "author_timezone": 0, "committer_date": "2004-02-03T21:14:45+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "d82b5a62e22ccef47d5fd4b739cfac20046c7adc" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 39, "insertions": 14, "lines": 53, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_base/_compiled_base.c", "new_path": "scipy_base/_compiled_base.c", "filename": "_compiled_base.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -694,68 +694,43 @@ static int numeric_stored = 0;\n /* make sure memory copy is going on with this */\n void scipy_numeric_save() {\n \n- PyArrayObject *temp=NULL;\n- int mydims[1]={1};\n- PyTypeObject *obtype;\n-\n+ /* we just save copies of things we may alter. */\n if (!numeric_stored) {\n-\ttemp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);\n-\tif (temp==NULL) return;\n-\tobtype = temp->ob_type;\n-\n-\tmemcpy(&BackupPyArray_Type, obtype, sizeof(PyTypeObject));\n-\tmemcpy(&backup_array_as_number, obtype->tp_as_number,\n+\tBackupPyArray_Type.tp_name = (PyArray_Type).tp_name;\n+\tmemcpy(&backup_array_as_number, (PyArray_Type).tp_as_number,\n \t sizeof(PyNumberMethods));\n-\tmemcpy(&backup_array_as_sequence, obtype->tp_as_sequence,\n+\tmemcpy(&backup_array_as_sequence, (PyArray_Type).tp_as_sequence,\n \t sizeof(PySequenceMethods));\n-\tmemcpy(&backup_array_as_mapping, obtype->tp_as_mapping,\n+\tmemcpy(&backup_array_as_mapping, (PyArray_Type).tp_as_mapping,\n \t sizeof(PyMappingMethods));\n-\tmemcpy(&backup_array_as_buffer, obtype->tp_as_buffer,\n+\tmemcpy(&backup_array_as_buffer, (PyArray_Type).tp_as_buffer,\n \t sizeof(PyBufferProcs));\n \tnumeric_stored = 1;\n-\tPy_DECREF(temp);\n }\n-\n }\n \n void scipy_numeric_restore() {\n- PyArrayObject *temp=NULL;\n- int mydims[1]={1};\n- PyTypeObject *obtype;\n \n- if (numeric_stored) {\n-\ttemp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);\n-\tif (temp==NULL) return;\n-\tobtype = temp->ob_type;\n-\n-\tmemcpy(obtype, &BackupPyArray_Type, sizeof(PyTypeObject));\n-\tmemcpy(obtype->tp_as_number, &backup_array_as_number, \n+ /* restore only what was copied */\n+ if (numeric_stored) { \n+\t(PyArray_Type).tp_name = BackupPyArray_Type.tp_name;\n+\tmemcpy((PyArray_Type).tp_as_number, &backup_array_as_number, \n \t sizeof(PyNumberMethods));\n-\tmemcpy(obtype->tp_as_sequence, &backup_array_as_sequence, \n+\tmemcpy((PyArray_Type).tp_as_sequence, &backup_array_as_sequence, \n \t sizeof(PySequenceMethods));\n-\tmemcpy(obtype->tp_as_mapping, &backup_array_as_mapping,\n+\tmemcpy((PyArray_Type).tp_as_mapping, &backup_array_as_mapping,\n \t sizeof(PyMappingMethods));\n-\tmemcpy(obtype->tp_as_buffer, &backup_array_as_buffer,\n+\tmemcpy((PyArray_Type).tp_as_buffer, &backup_array_as_buffer,\n \t sizeof(PyBufferProcs));\n-\tPy_DECREF(temp);\n }\n }\n \n static const char *_scipystr = \"array (scipy)\";\n \n void scipy_numeric_alter() {\n- PyArrayObject *temp=NULL;\n- int mydims[1]={1};\n- PyTypeObject *obtype;\n- \n-\n- temp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);\n- if (temp==NULL) return;\n- obtype = temp->ob_type; \n \n- obtype->tp_name = _scipystr;\n+ (PyArray_Type).tp_name = _scipystr;\n \n- Py_DECREF(temp);\n }\n \n static char numeric_alter_doc[] = \"alter_numeric() update the behavior of Numeric objects.\\n\\n 1. Change coercion rules so that multiplying by a scalar does not upcast.\\n 2. Add index slicing capability to Numeric arrays.\\n 3. Speed up inner loops.\\n\\nThis call changes the behavior for ALL Numeric arrays currently defined\\n and to be defined in the future. The old behavior can be restored for ALL\\n arrays using numeric_restore().\";\n", "added_lines": 14, "deleted_lines": 39, "source_code": "\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n\n\nstatic char doc_base_unique[] = \"Return the unique elements of a 1-D sequence.\";\n\nstatic PyObject *base_unique(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns a 1-D array containing the unique elements of a 1-D sequence.\n */\n\n void *new_mem=NULL;\n PyArrayObject *ainput=NULL, *aoutput=NULL;\n int asize, abytes, new;\n int copied=0, nd;\n int instride=0, elsize, k, j, dims[1];\n char *ip, *op; /* Current memory buffer */\n char *op2;\n \n static char *kwlist[] = {\"input\", NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!\", kwlist, &PyArray_Type, &ainput)) \n return NULL;\n \n if (ainput->nd > 1) {\n PyErr_SetString(PyExc_ValueError, \"Input array must be < 1 dimensional\");\n return NULL;\n }\n asize = PyArray_SIZE(ainput);\n elsize = ainput->descr->elsize;\n abytes = asize * elsize;\n nd = ainput->nd;\n if (nd > 0) {\n instride = ainput->strides[0];\n }\n\n new_mem = (void *)PyMem_Malloc((size_t) abytes);\n if (new_mem == NULL) {\n return PyErr_NoMemory();\n }\n \n ip = ainput->data;\n op = new_mem;\n for (k=0; k < asize; k++,ip+=instride) {\n new = 1; /* Assume it is new */\n op2 = new_mem;\n for (j=0; j < copied; j++,op2+=elsize) {\n if (memcmp(op2,ip,elsize) == 0) { /* Is a match found? */\n new = 0;\n break;\n }\n }\n /* No match found, copy this one over */\n if (new) {\n memcpy(op,ip,elsize);\n copied += 1;\n op += elsize; /* Get ready to put next match */\n }\n }\n\n dims[0] = copied;\n /* Make output array */\n if ((aoutput = (PyArrayObject *)PyArray_FromDims(nd, \n dims, ainput->descr->type_num))==NULL) goto fail;\n\n memcpy(aoutput->data,new_mem,elsize*copied);\n /* Reallocate memory to new-size */\n PyMem_Free(new_mem);\n return PyArray_Return(aoutput); \n \n fail:\n if (new_mem != NULL) PyMem_Free(new_mem);\n Py_XDECREF(aoutput);\n return NULL;\n}\n\n\nstatic char doc_base_insert[] = \"Insert vals sequenctially into equivalent 1-d positions indicated by mask.\";\n\nstatic PyObject *base_insert(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns input array with values inserted sequentially into places \n indicated by the mask\n */\n\n PyObject *mask=NULL, *vals=NULL;\n PyArrayObject *ainput=NULL, *amask=NULL, *avals=NULL, *avalscast=NULL, *tmp=NULL;\n int numvals, totmask, sameshape;\n char *input_data, *mptr, *vptr, *zero;\n int melsize, delsize, copied, nd;\n int *instrides, *inshape;\n int mindx, rem_indx, indx, i, k, objarray;\n \n static char *kwlist[] = {\"input\",\"mask\",\"vals\",NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!OO\", kwlist, &PyArray_Type, &ainput, &mask, &vals))\n return NULL;\n\n /* Fixed problem with OBJECT ARRAYS\n if (ainput->descr->type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"Not currently supported for Object arrays.\");\n return NULL;\n }\n */\n\n amask = (PyArrayObject *)PyArray_ContiguousFromObject(mask, PyArray_NOTYPE, 0, 0);\n if (amask == NULL) return NULL;\n /* Cast an object array */\n if (amask->descr->type_num == PyArray_OBJECT) {\n tmp = (PyArrayObject *)PyArray_Cast(amask, PyArray_LONG);\n if (tmp == NULL) goto fail;\n Py_DECREF(amask);\n amask = tmp;\n }\n\n sameshape = 1;\n if (amask->nd == ainput->nd) {\n for (k=0; k < amask->nd; k++) \n if (amask->dimensions[k] != ainput->dimensions[k])\n sameshape = 0;\n }\n else { /* Test to see if amask is 1d */\n if (amask->nd != 1) sameshape = 0;\n else if ((PyArray_SIZE(ainput)) != PyArray_SIZE(amask)) sameshape = 0;\n }\n if (!sameshape) {\n PyErr_SetString(PyExc_ValueError, \"Mask array must be 1D or same shape as input array.\");\n goto fail;\n }\n\n avals = (PyArrayObject *)PyArray_FromObject(vals, PyArray_NOTYPE, 0, 1);\n if (avals == NULL) goto fail;\n avalscast = (PyArrayObject *)PyArray_Cast(avals, ainput->descr->type_num);\n if (avalscast == NULL) goto fail;\n Py_DECREF(avals);\n\n numvals = PyArray_SIZE(avalscast);\n nd = ainput->nd;\n input_data = ainput->data;\n mptr = amask->data;\n melsize = amask->descr->elsize;\n vptr = avalscast->data;\n delsize = avalscast->descr->elsize;\n zero = amask->descr->zero;\n objarray = (ainput->descr->type_num == PyArray_OBJECT);\n \n /* Handle zero-dimensional case separately */\n if (nd == 0) {\n if (memcmp(mptr,zero,melsize) != 0) {\n /* Copy value element over to input array */\n memcpy(input_data,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n }\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n /* Walk through mask array, when non-zero is encountered\n copy next value in the vals array to the input array.\n If we get through the value array, repeat it as necessary. \n */\n totmask = PyArray_SIZE(amask);\n copied = 0;\n instrides = ainput->strides;\n inshape = ainput->dimensions;\n for (mindx = 0; mindx < totmask; mindx++) { \n if (memcmp(mptr,zero,melsize) != 0) { \n /* compute indx into input array \n */\n rem_indx = mindx;\n indx = 0;\n for(i=nd-1; i > 0; --i) {\n indx += (rem_indx % inshape[i]) * instrides[i];\n rem_indx /= inshape[i];\n }\n indx += rem_indx * instrides[0];\n /* fprintf(stderr, \"mindx = %d, indx=%d\\n\", mindx, indx); */\n /* Copy value element over to input array */\n memcpy(input_data+indx,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n vptr += delsize;\n copied += 1;\n /* If we move past value data. Reset */\n if (copied >= numvals) vptr = avalscast->data;\n }\n mptr += melsize;\n }\n\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n \n fail:\n Py_XDECREF(amask);\n Py_XDECREF(avals);\n Py_XDECREF(avalscast);\n return NULL;\n}\n\n\n/* Decrement the reference count of all objects in **arrays. */\nstatic void cleanup_arrays(PyArrayObject **arrays, int number)\n{\n int k;\n for (k=0; k < number; k++)\n Py_XDECREF((PyObject *)arrays[k]);\n return;\n}\n\n/* All rank-0 arrays are converted to rank-1 arrays */\n/* The number of dimensions of each array with rank less than\n the rank of the array with the most dimensions is increased by \n prepending with a dimenson length of one so that all arrays have\n the same rank. */\n/* Dimensions are checked and unmatched dimensions triggers an error */\n/* Strides for dimensions whose real length is one is set to zero but the dimension\n length is set to the maximum dimensions for the collection of inputs */\nstatic int setup_input_arrays(PyTupleObject *inputs, PyArrayObject **inputarrays, int nin)\n{\n int i, k;\n int maxrank=1;\n int *maxdims;\n PyObject *inputobj;\n PyArrayObject *ain, *tmparray;\n\n /* Convert nested sequences to arrays or just increase reference count\n if already an array */\n for (i=0; i < nin; i++) {\n ain = NULL;\n inputobj = PyTuple_GET_ITEM(inputs,i);\n ain = (PyArrayObject *)PyArray_FromObject(inputobj,PyArray_ObjectType(inputobj,0),0,0);\n if (NULL == ain) {\n cleanup_arrays(inputarrays,i);\n return -1;\n }\n if (PyArray_SIZE(ain)==0) {\n cleanup_arrays(inputarrays,i);\n PyErr_SetString(PyExc_IndexError,\"arraymap: Input arrays of zero-dimensions not supported.\");\n return -1;\n }\n if (ain->nd > maxrank) maxrank = ain->nd;\n if (ain->nd == 0) { /* turn into 1-d array */\n /* convert to rank-1 array */\n if ((ain->dimensions = (int *)malloc(sizeof(int))) == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,i);\n return -1;\n }\n if ((ain->strides = (int *)malloc(sizeof(int))) == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,i);\n free(ain->dimensions);\n return -1;\n }\n ain->nd = 1;\n ain->dimensions[0] = 1;\n ain->strides[0] = ain->descr->elsize;\n }\n inputarrays[i] = ain;\n }\n\n maxdims = (int*)malloc(2*sizeof(int)*maxrank);\n if (NULL == maxdims) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,nin);\n return -1;\n }\n\n\n /* Reshape all arrays so they have the same rank (pre-pend with length 1 dimensions) */\n /* We want to replace the header information without copying the data. \n Keeping the reference count correct can be tricky.\n We want to make a new array object with a different header and decrease the \n reference count of the old one without deallocating the data section */\n for (i=0; i < nin; i++) {\n ain = inputarrays[i];\n\n /* Initialize all dimensions to 1 */\n /* Change array shape */\n for (k=0; k < maxrank; k++) \n maxdims[k] = 1; \n for (k=maxrank-ain->nd; k< maxrank; k++) \n maxdims[k] = ain->dimensions[k-maxrank+ain->nd];\n\n tmparray = (PyArrayObject *)PyArray_FromDimsAndData(maxrank,maxdims,ain->descr->type,ain->data);\n if (NULL == tmparray) {\n free(maxdims);\n cleanup_arrays(inputarrays,nin);\n return -1;\n }\n memmove(tmparray->strides,ain->strides,sizeof(int)*tmparray->nd);\n tmparray->base = (PyObject *)ain; /* When tmparray is deallocated ain will be too */\n inputarrays[i] = tmparray; /* tmparray is new array */\n }\n\n /* Find dimension length for the output arrays (maximum length for each\n dimension) */\n for (k=0; k < maxrank; k++) { \n maxdims[k] = 1;\n for (i=0; i < nin; i++) \n if (inputarrays[i]->dimensions[k] > maxdims[k])\n\tmaxdims[k] = inputarrays[i]->dimensions[k];\n }\n\n /* Now set all lengths for input array dimensions to maxdims \n and make strides equal to zero for arrays whose\n real length is 1 for a particular dimension\n */\n\n for (i=0; idimensions[k]) {\n\tain->strides[k] = 0;\n\tain->dimensions[k] = maxdims[k];\n }\n else if (ain->dimensions[k] != maxdims[k]) {\n\tPyErr_SetString(PyExc_ValueError,\"arraymap: Frames are not aligned (mismatched dimensions).\");\n\tcleanup_arrays(inputarrays,nin);\n\tfree(maxdims);\n\treturn -1;\n }\n }\n }\n\n free(maxdims);\n return 0;\n\n}\n\nstatic int type_from_object(PyObject *obj)\n{\n if (PyArray_Check(obj))\n return ((PyArrayObject *)obj)->descr->type_num;\n if (PyComplex_Check(obj)) return PyArray_CDOUBLE;\n if (PyFloat_Check(obj)) return PyArray_DOUBLE;\n if (PyInt_Check(obj) || PyLong_Check(obj)) return PyArray_LONG;\n PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for output array.\");\n return -1;\n}\n\nstatic int type_from_char(char typechar)\n{\n switch(typechar) {\n case 'c': return PyArray_CHAR;\n case 'b': return PyArray_UBYTE;\n case '1': return PyArray_SBYTE;\n case 's': return PyArray_SHORT;\n case 'i': return PyArray_INT;\n#ifdef PyArray_UNSIGNED_TYPES\n case 'w': return PyArray_USHORT;\n case 'u': return PyArray_UINT;\n#endif\n case 'l': return PyArray_LONG;\n case 'f': return PyArray_FLOAT;\n case 'd': return PyArray_DOUBLE;\n case 'F': return PyArray_CFLOAT;\n case 'D': return PyArray_CDOUBLE;\n default:\n PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for array\");\n return -1;\n }\n}\n\n\n\n/* This sets up the output arrays by calling the function with arguments \n the first element of each input arrays. If otypes is NULL, the\n returned value type is used to establish the type of the output\n arrays, otherwise the characters in otypes determine the\n output types */\nstatic int setup_output_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject ***outarr, char *otypes, int numtypes)\n{\n PyObject *arglist, *result;\n PyObject *tmpobject;\n PyArrayObject *tmparr;\n int i, nout;\n int nd, *dimensions, type_num;\n\n nd = inarr[0]->nd;\n dimensions = inarr[0]->dimensions;\n\n if ((numtypes == 0) || (otypes == NULL)) { \n /* Call function to get number of outputs */\n\n /* Build argument list */\n if ((arglist = PyTuple_New(nin)) == NULL) {\n return -1;\n }\n /* Construct input argument by creating a tuple with an element\n from each input array (cast to an appropriate Python Object) */\n for (i=0; i < nin; i++) {\n tmparr = inarr[i];\n /* Get first data point */\n tmpobject = tmparr->descr->getitem((void *)tmparr->data);\n if (NULL == tmpobject) {\n\tPy_DECREF(arglist);\n\treturn -1;\n }\n PyTuple_SET_ITEM(arglist, i, tmpobject); /* arg1 owns reference to tmpobj now */\n } \n /* Call Python Function */\n if ((result=PyEval_CallObject(func, arglist))==NULL) {\n Py_DECREF(arglist);\n return -1;\n }\n\n Py_DECREF(arglist);\n\n /* If result is a tuple, create output_arrays according \n to output. */\n if (PyTuple_Check(result)) {\n nout = PyTuple_GET_SIZE(result);\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL == *outarr) {\n\tPyErr_SetString(PyExc_MemoryError, \"arraymap: Cannot allocate memory for output arrays.\");\n\tPy_DECREF(result);\n\treturn -1;\n }\n /* Create nout output arrays */\n for (i=0; i < nout; i++) {\n\t/* Determine type */\n\tif ((type_num=type_from_object(PyTuple_GET_ITEM(result, i)))==-1) {\n\t cleanup_arrays(*outarr,i);\n\t Py_DECREF(result);\n\t free(*outarr);\n\t return -1;\n\t}\n\t/* Create output array */\n\t(*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n\tif (NULL == (*outarr)[i]) {\n\t cleanup_arrays(*outarr,i);\n\t Py_DECREF(result);\n\t free(*outarr);\n\t return -1;\n\t}\n }\n }\n else { /* Only a single output result */\n nout = 1;\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL==*outarr) {\n\tPyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");\n\tPy_DECREF(result);\n\treturn -1;\n }\n if ((type_num = type_from_object(result))==-1) {\n\tPy_DECREF(result);\n\tfree(*outarr);\n\treturn -1;\n }\n (*outarr)[0] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n if (NULL == (*outarr)[0]) {\n\tPy_DECREF(result);\n\tfree(*outarr);\n\treturn -1;\n }\n }\n Py_DECREF(result);\n }\n\n else { /* Character output types entered */\n nout = numtypes;\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL==*outarr) {\n PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");\n return -1;\n }\n /* Create Output arrays */\n for (i=0; i < nout; i++) {\n /* Get type */\n if ((type_num = type_from_char(otypes[i]))==-1) {\n\tcleanup_arrays(*outarr,i);\n\tfree(*outarr);\n\treturn -1;\n }\n /* Create array */\n (*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n if (NULL == (*outarr)[i]) {\n\tcleanup_arrays(*outarr,i);\n\tfree(*outarr);\n\treturn -1;\n }\n } \n } \n return nout;\n}\n\n\n/* Corresponding dimensions are assumed to match, check before calling. */\n/* No rank-0 arrays (make them rank-1 arrays) */\n\n/* This replicates the standard Ufunc broadcasting rule that if the\n dimension length is one, incrementing does not occur for that dimension. \n\n This is currently done by setting the stride in that dimension to\n zero during input array setup.\n\n The purpose of this function is to perform a for loop over arbitrary\n discontiguous N-D arrays, call the Python function for each set of \n corresponding elements and place the results in the output_array.\n*/ \n#define INCREMENT(ret_ind, nd, max_ind) \\\n{ \\\n int k; \\\n k = (nd) - 1; \\\n if (++(ret_ind)[k] >= (max_ind)[k]) { \\\n while (k >= 0 && ((ret_ind)[k] >= (max_ind)[k]-1)) \\\n (ret_ind)[k--] = 0; \\\n if (k >= 0) (ret_ind)[k]++; \\\n else (ret_ind)[0] = (max_ind)[0]; \\\n } \\\n}\n\n#define CALCINDEX(indx, nd_index, strides, ndim) \\\n{ \\\n int i; \\\n \\\n indx = 0; \\\n for (i=0; i < (ndim); i++) \\\n indx += (nd_index)[i]*(strides)[i]; \\\n} \n\nstatic int loop_over_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject **outarr, int nout)\n{\n int i, loop_index;\n int *nd_index, indx_in, indx_out;\n PyArrayObject *in, *out, *tmparr;\n PyObject *result, *tmpobj, *arglist;\n\n in = inarr[0]; /* For any shape information needed */\n out = outarr[0];\n /* Allocate the N-D index initalized to zero. */\n nd_index = (int *)calloc(in->nd,sizeof(int));\n if (NULL == nd_index) {\n PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for arrays.\");\n return -1;\n }\n /* Build argument list */\n if ((arglist = PyTuple_New(nin)) == NULL) {\n free(nd_index);\n return -1;\n }\n\n loop_index = PyArray_Size((PyObject *)in); /* Total number of Python function calls */\n\n while(loop_index--) { \n /* Create input argument list with current element from the input\n arrays \n */\n for (i=0; i < nin; i++) {\n tmparr = inarr[i];\n /* Find linear index into this input array */\n CALCINDEX(indx_in,nd_index,tmparr->strides,in->nd);\n /* Get object at this index */\n tmpobj = tmparr->descr->getitem((void *)(tmparr->data+indx_in));\n if (NULL == tmpobj) {\n\tPy_DECREF(arglist);\n\tfree(nd_index);\n\treturn -1;\n }\n /* This steals reference of tmpobj */\n PyTuple_SET_ITEM(arglist, i, tmpobj); \n }\n /* Call Python Function for this set of inputs */\n if ((result=PyEval_CallObject(func, arglist))==NULL) {\n Py_DECREF(arglist);\n free(nd_index);\n return -1;\n } \n\n /* Find index into (all) output arrays */\n CALCINDEX(indx_out,nd_index,out->strides,out->nd);\n\n /* Copy the results to the output arrays */\n if (1==nout) {\n if ((outarr[0]->descr->setitem(result,(outarr[0]->data+indx_out)))==-1) {\n\tfree(nd_index);\n\tPy_DECREF(arglist);\n\tPy_DECREF(result);\n\treturn -1;\n }\n }\n else if (PyTuple_Check(result)) {\n for (i=0; idescr->setitem(PyTuple_GET_ITEM(result,i),(outarr[i]->data+indx_out)))==-1) {\n\t free(nd_index);\n\t Py_DECREF(arglist);\n\t Py_DECREF(result);\n return -1;\n\t}\n }\n }\n else { \n PyErr_SetString(PyExc_ValueError,\"arraymap: Function output of incorrect type.\");\n free(nd_index);\n Py_DECREF(arglist);\n Py_DECREF(result);\n return -1;\n }\n\n /* Increment the index counter */\n INCREMENT(nd_index,in->nd,in->dimensions);\n Py_DECREF(result);\n\n }\n Py_DECREF(arglist);\n free(nd_index);\n return 0;\n} \n\nstatic PyObject *build_output(PyArrayObject **outarr,int nout)\n{\n int i;\n PyObject *out;\n\n if (1==nout) return PyArray_Return(outarr[0]);\n if ((out=PyTuple_New(nout))==NULL) return NULL;\n for (i=0; ind > 1) {\n PyErr_SetString(PyExc_ValueError, \"Input array must be < 1 dimensional\");\n return NULL;\n }\n asize = PyArray_SIZE(ainput);\n elsize = ainput->descr->elsize;\n abytes = asize * elsize;\n nd = ainput->nd;\n if (nd > 0) {\n instride = ainput->strides[0];\n }\n\n new_mem = (void *)PyMem_Malloc((size_t) abytes);\n if (new_mem == NULL) {\n return PyErr_NoMemory();\n }\n \n ip = ainput->data;\n op = new_mem;\n for (k=0; k < asize; k++,ip+=instride) {\n new = 1; /* Assume it is new */\n op2 = new_mem;\n for (j=0; j < copied; j++,op2+=elsize) {\n if (memcmp(op2,ip,elsize) == 0) { /* Is a match found? */\n new = 0;\n break;\n }\n }\n /* No match found, copy this one over */\n if (new) {\n memcpy(op,ip,elsize);\n copied += 1;\n op += elsize; /* Get ready to put next match */\n }\n }\n\n dims[0] = copied;\n /* Make output array */\n if ((aoutput = (PyArrayObject *)PyArray_FromDims(nd, \n dims, ainput->descr->type_num))==NULL) goto fail;\n\n memcpy(aoutput->data,new_mem,elsize*copied);\n /* Reallocate memory to new-size */\n PyMem_Free(new_mem);\n return PyArray_Return(aoutput); \n \n fail:\n if (new_mem != NULL) PyMem_Free(new_mem);\n Py_XDECREF(aoutput);\n return NULL;\n}\n\n\nstatic char doc_base_insert[] = \"Insert vals sequenctially into equivalent 1-d positions indicated by mask.\";\n\nstatic PyObject *base_insert(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns input array with values inserted sequentially into places \n indicated by the mask\n */\n\n PyObject *mask=NULL, *vals=NULL;\n PyArrayObject *ainput=NULL, *amask=NULL, *avals=NULL, *avalscast=NULL, *tmp=NULL;\n int numvals, totmask, sameshape;\n char *input_data, *mptr, *vptr, *zero;\n int melsize, delsize, copied, nd;\n int *instrides, *inshape;\n int mindx, rem_indx, indx, i, k, objarray;\n \n static char *kwlist[] = {\"input\",\"mask\",\"vals\",NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!OO\", kwlist, &PyArray_Type, &ainput, &mask, &vals))\n return NULL;\n\n /* Fixed problem with OBJECT ARRAYS\n if (ainput->descr->type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"Not currently supported for Object arrays.\");\n return NULL;\n }\n */\n\n amask = (PyArrayObject *)PyArray_ContiguousFromObject(mask, PyArray_NOTYPE, 0, 0);\n if (amask == NULL) return NULL;\n /* Cast an object array */\n if (amask->descr->type_num == PyArray_OBJECT) {\n tmp = (PyArrayObject *)PyArray_Cast(amask, PyArray_LONG);\n if (tmp == NULL) goto fail;\n Py_DECREF(amask);\n amask = tmp;\n }\n\n sameshape = 1;\n if (amask->nd == ainput->nd) {\n for (k=0; k < amask->nd; k++) \n if (amask->dimensions[k] != ainput->dimensions[k])\n sameshape = 0;\n }\n else { /* Test to see if amask is 1d */\n if (amask->nd != 1) sameshape = 0;\n else if ((PyArray_SIZE(ainput)) != PyArray_SIZE(amask)) sameshape = 0;\n }\n if (!sameshape) {\n PyErr_SetString(PyExc_ValueError, \"Mask array must be 1D or same shape as input array.\");\n goto fail;\n }\n\n avals = (PyArrayObject *)PyArray_FromObject(vals, PyArray_NOTYPE, 0, 1);\n if (avals == NULL) goto fail;\n avalscast = (PyArrayObject *)PyArray_Cast(avals, ainput->descr->type_num);\n if (avalscast == NULL) goto fail;\n Py_DECREF(avals);\n\n numvals = PyArray_SIZE(avalscast);\n nd = ainput->nd;\n input_data = ainput->data;\n mptr = amask->data;\n melsize = amask->descr->elsize;\n vptr = avalscast->data;\n delsize = avalscast->descr->elsize;\n zero = amask->descr->zero;\n objarray = (ainput->descr->type_num == PyArray_OBJECT);\n \n /* Handle zero-dimensional case separately */\n if (nd == 0) {\n if (memcmp(mptr,zero,melsize) != 0) {\n /* Copy value element over to input array */\n memcpy(input_data,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n }\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n /* Walk through mask array, when non-zero is encountered\n copy next value in the vals array to the input array.\n If we get through the value array, repeat it as necessary. \n */\n totmask = PyArray_SIZE(amask);\n copied = 0;\n instrides = ainput->strides;\n inshape = ainput->dimensions;\n for (mindx = 0; mindx < totmask; mindx++) { \n if (memcmp(mptr,zero,melsize) != 0) { \n /* compute indx into input array \n */\n rem_indx = mindx;\n indx = 0;\n for(i=nd-1; i > 0; --i) {\n indx += (rem_indx % inshape[i]) * instrides[i];\n rem_indx /= inshape[i];\n }\n indx += rem_indx * instrides[0];\n /* fprintf(stderr, \"mindx = %d, indx=%d\\n\", mindx, indx); */\n /* Copy value element over to input array */\n memcpy(input_data+indx,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n vptr += delsize;\n copied += 1;\n /* If we move past value data. Reset */\n if (copied >= numvals) vptr = avalscast->data;\n }\n mptr += melsize;\n }\n\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n \n fail:\n Py_XDECREF(amask);\n Py_XDECREF(avals);\n Py_XDECREF(avalscast);\n return NULL;\n}\n\n\n/* Decrement the reference count of all objects in **arrays. */\nstatic void cleanup_arrays(PyArrayObject **arrays, int number)\n{\n int k;\n for (k=0; k < number; k++)\n Py_XDECREF((PyObject *)arrays[k]);\n return;\n}\n\n/* All rank-0 arrays are converted to rank-1 arrays */\n/* The number of dimensions of each array with rank less than\n the rank of the array with the most dimensions is increased by \n prepending with a dimenson length of one so that all arrays have\n the same rank. */\n/* Dimensions are checked and unmatched dimensions triggers an error */\n/* Strides for dimensions whose real length is one is set to zero but the dimension\n length is set to the maximum dimensions for the collection of inputs */\nstatic int setup_input_arrays(PyTupleObject *inputs, PyArrayObject **inputarrays, int nin)\n{\n int i, k;\n int maxrank=1;\n int *maxdims;\n PyObject *inputobj;\n PyArrayObject *ain, *tmparray;\n\n /* Convert nested sequences to arrays or just increase reference count\n if already an array */\n for (i=0; i < nin; i++) {\n ain = NULL;\n inputobj = PyTuple_GET_ITEM(inputs,i);\n ain = (PyArrayObject *)PyArray_FromObject(inputobj,PyArray_ObjectType(inputobj,0),0,0);\n if (NULL == ain) {\n cleanup_arrays(inputarrays,i);\n return -1;\n }\n if (PyArray_SIZE(ain)==0) {\n cleanup_arrays(inputarrays,i);\n PyErr_SetString(PyExc_IndexError,\"arraymap: Input arrays of zero-dimensions not supported.\");\n return -1;\n }\n if (ain->nd > maxrank) maxrank = ain->nd;\n if (ain->nd == 0) { /* turn into 1-d array */\n /* convert to rank-1 array */\n if ((ain->dimensions = (int *)malloc(sizeof(int))) == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,i);\n return -1;\n }\n if ((ain->strides = (int *)malloc(sizeof(int))) == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,i);\n free(ain->dimensions);\n return -1;\n }\n ain->nd = 1;\n ain->dimensions[0] = 1;\n ain->strides[0] = ain->descr->elsize;\n }\n inputarrays[i] = ain;\n }\n\n maxdims = (int*)malloc(2*sizeof(int)*maxrank);\n if (NULL == maxdims) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,nin);\n return -1;\n }\n\n\n /* Reshape all arrays so they have the same rank (pre-pend with length 1 dimensions) */\n /* We want to replace the header information without copying the data. \n Keeping the reference count correct can be tricky.\n We want to make a new array object with a different header and decrease the \n reference count of the old one without deallocating the data section */\n for (i=0; i < nin; i++) {\n ain = inputarrays[i];\n\n /* Initialize all dimensions to 1 */\n /* Change array shape */\n for (k=0; k < maxrank; k++) \n maxdims[k] = 1; \n for (k=maxrank-ain->nd; k< maxrank; k++) \n maxdims[k] = ain->dimensions[k-maxrank+ain->nd];\n\n tmparray = (PyArrayObject *)PyArray_FromDimsAndData(maxrank,maxdims,ain->descr->type,ain->data);\n if (NULL == tmparray) {\n free(maxdims);\n cleanup_arrays(inputarrays,nin);\n return -1;\n }\n memmove(tmparray->strides,ain->strides,sizeof(int)*tmparray->nd);\n tmparray->base = (PyObject *)ain; /* When tmparray is deallocated ain will be too */\n inputarrays[i] = tmparray; /* tmparray is new array */\n }\n\n /* Find dimension length for the output arrays (maximum length for each\n dimension) */\n for (k=0; k < maxrank; k++) { \n maxdims[k] = 1;\n for (i=0; i < nin; i++) \n if (inputarrays[i]->dimensions[k] > maxdims[k])\n\tmaxdims[k] = inputarrays[i]->dimensions[k];\n }\n\n /* Now set all lengths for input array dimensions to maxdims \n and make strides equal to zero for arrays whose\n real length is 1 for a particular dimension\n */\n\n for (i=0; idimensions[k]) {\n\tain->strides[k] = 0;\n\tain->dimensions[k] = maxdims[k];\n }\n else if (ain->dimensions[k] != maxdims[k]) {\n\tPyErr_SetString(PyExc_ValueError,\"arraymap: Frames are not aligned (mismatched dimensions).\");\n\tcleanup_arrays(inputarrays,nin);\n\tfree(maxdims);\n\treturn -1;\n }\n }\n }\n\n free(maxdims);\n return 0;\n\n}\n\nstatic int type_from_object(PyObject *obj)\n{\n if (PyArray_Check(obj))\n return ((PyArrayObject *)obj)->descr->type_num;\n if (PyComplex_Check(obj)) return PyArray_CDOUBLE;\n if (PyFloat_Check(obj)) return PyArray_DOUBLE;\n if (PyInt_Check(obj) || PyLong_Check(obj)) return PyArray_LONG;\n PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for output array.\");\n return -1;\n}\n\nstatic int type_from_char(char typechar)\n{\n switch(typechar) {\n case 'c': return PyArray_CHAR;\n case 'b': return PyArray_UBYTE;\n case '1': return PyArray_SBYTE;\n case 's': return PyArray_SHORT;\n case 'i': return PyArray_INT;\n#ifdef PyArray_UNSIGNED_TYPES\n case 'w': return PyArray_USHORT;\n case 'u': return PyArray_UINT;\n#endif\n case 'l': return PyArray_LONG;\n case 'f': return PyArray_FLOAT;\n case 'd': return PyArray_DOUBLE;\n case 'F': return PyArray_CFLOAT;\n case 'D': return PyArray_CDOUBLE;\n default:\n PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for array\");\n return -1;\n }\n}\n\n\n\n/* This sets up the output arrays by calling the function with arguments \n the first element of each input arrays. If otypes is NULL, the\n returned value type is used to establish the type of the output\n arrays, otherwise the characters in otypes determine the\n output types */\nstatic int setup_output_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject ***outarr, char *otypes, int numtypes)\n{\n PyObject *arglist, *result;\n PyObject *tmpobject;\n PyArrayObject *tmparr;\n int i, nout;\n int nd, *dimensions, type_num;\n\n nd = inarr[0]->nd;\n dimensions = inarr[0]->dimensions;\n\n if ((numtypes == 0) || (otypes == NULL)) { \n /* Call function to get number of outputs */\n\n /* Build argument list */\n if ((arglist = PyTuple_New(nin)) == NULL) {\n return -1;\n }\n /* Construct input argument by creating a tuple with an element\n from each input array (cast to an appropriate Python Object) */\n for (i=0; i < nin; i++) {\n tmparr = inarr[i];\n /* Get first data point */\n tmpobject = tmparr->descr->getitem((void *)tmparr->data);\n if (NULL == tmpobject) {\n\tPy_DECREF(arglist);\n\treturn -1;\n }\n PyTuple_SET_ITEM(arglist, i, tmpobject); /* arg1 owns reference to tmpobj now */\n } \n /* Call Python Function */\n if ((result=PyEval_CallObject(func, arglist))==NULL) {\n Py_DECREF(arglist);\n return -1;\n }\n\n Py_DECREF(arglist);\n\n /* If result is a tuple, create output_arrays according \n to output. */\n if (PyTuple_Check(result)) {\n nout = PyTuple_GET_SIZE(result);\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL == *outarr) {\n\tPyErr_SetString(PyExc_MemoryError, \"arraymap: Cannot allocate memory for output arrays.\");\n\tPy_DECREF(result);\n\treturn -1;\n }\n /* Create nout output arrays */\n for (i=0; i < nout; i++) {\n\t/* Determine type */\n\tif ((type_num=type_from_object(PyTuple_GET_ITEM(result, i)))==-1) {\n\t cleanup_arrays(*outarr,i);\n\t Py_DECREF(result);\n\t free(*outarr);\n\t return -1;\n\t}\n\t/* Create output array */\n\t(*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n\tif (NULL == (*outarr)[i]) {\n\t cleanup_arrays(*outarr,i);\n\t Py_DECREF(result);\n\t free(*outarr);\n\t return -1;\n\t}\n }\n }\n else { /* Only a single output result */\n nout = 1;\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL==*outarr) {\n\tPyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");\n\tPy_DECREF(result);\n\treturn -1;\n }\n if ((type_num = type_from_object(result))==-1) {\n\tPy_DECREF(result);\n\tfree(*outarr);\n\treturn -1;\n }\n (*outarr)[0] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n if (NULL == (*outarr)[0]) {\n\tPy_DECREF(result);\n\tfree(*outarr);\n\treturn -1;\n }\n }\n Py_DECREF(result);\n }\n\n else { /* Character output types entered */\n nout = numtypes;\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL==*outarr) {\n PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");\n return -1;\n }\n /* Create Output arrays */\n for (i=0; i < nout; i++) {\n /* Get type */\n if ((type_num = type_from_char(otypes[i]))==-1) {\n\tcleanup_arrays(*outarr,i);\n\tfree(*outarr);\n\treturn -1;\n }\n /* Create array */\n (*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n if (NULL == (*outarr)[i]) {\n\tcleanup_arrays(*outarr,i);\n\tfree(*outarr);\n\treturn -1;\n }\n } \n } \n return nout;\n}\n\n\n/* Corresponding dimensions are assumed to match, check before calling. */\n/* No rank-0 arrays (make them rank-1 arrays) */\n\n/* This replicates the standard Ufunc broadcasting rule that if the\n dimension length is one, incrementing does not occur for that dimension. \n\n This is currently done by setting the stride in that dimension to\n zero during input array setup.\n\n The purpose of this function is to perform a for loop over arbitrary\n discontiguous N-D arrays, call the Python function for each set of \n corresponding elements and place the results in the output_array.\n*/ \n#define INCREMENT(ret_ind, nd, max_ind) \\\n{ \\\n int k; \\\n k = (nd) - 1; \\\n if (++(ret_ind)[k] >= (max_ind)[k]) { \\\n while (k >= 0 && ((ret_ind)[k] >= (max_ind)[k]-1)) \\\n (ret_ind)[k--] = 0; \\\n if (k >= 0) (ret_ind)[k]++; \\\n else (ret_ind)[0] = (max_ind)[0]; \\\n } \\\n}\n\n#define CALCINDEX(indx, nd_index, strides, ndim) \\\n{ \\\n int i; \\\n \\\n indx = 0; \\\n for (i=0; i < (ndim); i++) \\\n indx += (nd_index)[i]*(strides)[i]; \\\n} \n\nstatic int loop_over_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject **outarr, int nout)\n{\n int i, loop_index;\n int *nd_index, indx_in, indx_out;\n PyArrayObject *in, *out, *tmparr;\n PyObject *result, *tmpobj, *arglist;\n\n in = inarr[0]; /* For any shape information needed */\n out = outarr[0];\n /* Allocate the N-D index initalized to zero. */\n nd_index = (int *)calloc(in->nd,sizeof(int));\n if (NULL == nd_index) {\n PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for arrays.\");\n return -1;\n }\n /* Build argument list */\n if ((arglist = PyTuple_New(nin)) == NULL) {\n free(nd_index);\n return -1;\n }\n\n loop_index = PyArray_Size((PyObject *)in); /* Total number of Python function calls */\n\n while(loop_index--) { \n /* Create input argument list with current element from the input\n arrays \n */\n for (i=0; i < nin; i++) {\n tmparr = inarr[i];\n /* Find linear index into this input array */\n CALCINDEX(indx_in,nd_index,tmparr->strides,in->nd);\n /* Get object at this index */\n tmpobj = tmparr->descr->getitem((void *)(tmparr->data+indx_in));\n if (NULL == tmpobj) {\n\tPy_DECREF(arglist);\n\tfree(nd_index);\n\treturn -1;\n }\n /* This steals reference of tmpobj */\n PyTuple_SET_ITEM(arglist, i, tmpobj); \n }\n /* Call Python Function for this set of inputs */\n if ((result=PyEval_CallObject(func, arglist))==NULL) {\n Py_DECREF(arglist);\n free(nd_index);\n return -1;\n } \n\n /* Find index into (all) output arrays */\n CALCINDEX(indx_out,nd_index,out->strides,out->nd);\n\n /* Copy the results to the output arrays */\n if (1==nout) {\n if ((outarr[0]->descr->setitem(result,(outarr[0]->data+indx_out)))==-1) {\n\tfree(nd_index);\n\tPy_DECREF(arglist);\n\tPy_DECREF(result);\n\treturn -1;\n }\n }\n else if (PyTuple_Check(result)) {\n for (i=0; idescr->setitem(PyTuple_GET_ITEM(result,i),(outarr[i]->data+indx_out)))==-1) {\n\t free(nd_index);\n\t Py_DECREF(arglist);\n\t Py_DECREF(result);\n return -1;\n\t}\n }\n }\n else { \n PyErr_SetString(PyExc_ValueError,\"arraymap: Function output of incorrect type.\");\n free(nd_index);\n Py_DECREF(arglist);\n Py_DECREF(result);\n return -1;\n }\n\n /* Increment the index counter */\n INCREMENT(nd_index,in->nd,in->dimensions);\n Py_DECREF(result);\n\n }\n Py_DECREF(arglist);\n free(nd_index);\n return 0;\n} \n\nstatic PyObject *build_output(PyArrayObject **outarr,int nout)\n{\n int i;\n PyObject *out;\n\n if (1==nout) return PyArray_Return(outarr[0]);\n if ((out=PyTuple_New(nout))==NULL) return NULL;\n for (i=0; iob_type;\n\n\tmemcpy(&BackupPyArray_Type, obtype, sizeof(PyTypeObject));\n\tmemcpy(&backup_array_as_number, obtype->tp_as_number,\n\t sizeof(PyNumberMethods));\n\tmemcpy(&backup_array_as_sequence, obtype->tp_as_sequence,\n\t sizeof(PySequenceMethods));\n\tmemcpy(&backup_array_as_mapping, obtype->tp_as_mapping,\n\t sizeof(PyMappingMethods));\n\tmemcpy(&backup_array_as_buffer, obtype->tp_as_buffer,\n\t sizeof(PyBufferProcs));\n\tnumeric_stored = 1;\n\tPy_DECREF(temp);\n }\n\n}\n\nvoid scipy_numeric_restore() {\n PyArrayObject *temp=NULL;\n int mydims[1]={1};\n PyTypeObject *obtype;\n\n if (numeric_stored) {\n\ttemp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);\n\tif (temp==NULL) return;\n\tobtype = temp->ob_type;\n\n\tmemcpy(obtype, &BackupPyArray_Type, sizeof(PyTypeObject));\n\tmemcpy(obtype->tp_as_number, &backup_array_as_number, \n\t sizeof(PyNumberMethods));\n\tmemcpy(obtype->tp_as_sequence, &backup_array_as_sequence, \n\t sizeof(PySequenceMethods));\n\tmemcpy(obtype->tp_as_mapping, &backup_array_as_mapping,\n\t sizeof(PyMappingMethods));\n\tmemcpy(obtype->tp_as_buffer, &backup_array_as_buffer,\n\t sizeof(PyBufferProcs));\n\tPy_DECREF(temp);\n }\n}\n\nstatic const char *_scipystr = \"array (scipy)\";\n\nvoid scipy_numeric_alter() {\n PyArrayObject *temp=NULL;\n int mydims[1]={1};\n PyTypeObject *obtype;\n \n\n temp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);\n if (temp==NULL) return;\n obtype = temp->ob_type; \n \n obtype->tp_name = _scipystr;\n\n Py_DECREF(temp);\n}\n\nstatic char numeric_alter_doc[] = \"alter_numeric() update the behavior of Numeric objects.\\n\\n 1. Change coercion rules so that multiplying by a scalar does not upcast.\\n 2. Add index slicing capability to Numeric arrays.\\n 3. Speed up inner loops.\\n\\nThis call changes the behavior for ALL Numeric arrays currently defined\\n and to be defined in the future. The old behavior can be restored for ALL\\n arrays using numeric_restore().\";\n\nstatic PyObject *numeric_behavior_alter(PyObject *self, PyObject *args)\n{\n\n if (!PyArg_ParseTuple ( args, \"\")) return NULL;\n\n scipy_numeric_save();\n scipy_numeric_alter();\n Py_INCREF(Py_None);\n return Py_None;\n}\n\nstatic char numeric_restore_doc[] = \"restore_numeric() restore the default behavior of Numeric objects.\\n\\n SEE slter_numeric.\\n\";\n\nstatic PyObject *numeric_behavior_restore(PyObject *self, PyObject *args)\n{\n\n if (!PyArg_ParseTuple ( args, \"\")) return NULL;\n \n scipy_numeric_restore();\n Py_INCREF(Py_None);\n return Py_None;\n}\n\n\nstatic struct PyMethodDef methods[] = {\n {\"arraymap\", map_PyFunc, METH_VARARGS, arraymap_doc},\n {\"_unique\",\t (PyCFunction)base_unique, METH_VARARGS | METH_KEYWORDS, \n doc_base_unique},\n {\"_insert\",\t (PyCFunction)base_insert, METH_VARARGS | METH_KEYWORDS, \n doc_base_insert},\n {\"alter_numeric\", numeric_behavior_alter, METH_VARARGS, \n numeric_alter_doc},\n {\"restore_numeric\", numeric_behavior_restore, METH_VARARGS, \n numeric_restore_doc},\n {NULL, NULL} /* sentinel */\n};\n\n/* Initialization function for the module (*must* be called initArray) */\n\nDL_EXPORT(void) init_compiled_base(void) {\n PyObject *m, *d, *s;\n \n /* Create the module and add the functions */\n m = Py_InitModule(\"_compiled_base\", methods); \n\n /* Import the array and ufunc objects */\n import_array();\n\n /* Add some symbolic constants to the module */\n d = PyModule_GetDict(m);\n\n s = PyString_FromString(\"0.2\");\n PyDict_SetItemString(d, \"__version__\", s);\n Py_DECREF(s);\n\n /* Check for errors */\n if (PyErr_Occurred())\n\tPy_FatalError(\"can't initialize module _compiled_base\");\n}\n\n", "methods": [ { "name": "base_unique", "long_name": "base_unique( PyObject * self , PyObject * args , PyObject * kwdict)", "filename": "_compiled_base.c", "nloc": 55, "complexity": 11, "token_count": 381, "parameters": [ "self", "args", "kwdict" ], "start_line": 8, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "base_insert", "long_name": "base_insert( PyObject * self , PyObject * args , PyObject * kwdict)", "filename": "_compiled_base.c", "nloc": 89, "complexity": 21, "token_count": 709, "parameters": [ "self", "args", "kwdict" ], "start_line": 81, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 122, "top_nesting_level": 0 }, { "name": "cleanup_arrays", "long_name": "cleanup_arrays( PyArrayObject ** arrays , int number)", "filename": "_compiled_base.c", "nloc": 7, "complexity": 2, "token_count": 41, "parameters": [ "arrays", "number" ], "start_line": 206, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "setup_input_arrays", "long_name": "setup_input_arrays( PyTupleObject * inputs , PyArrayObject ** inputarrays , int nin)", "filename": "_compiled_base.c", "nloc": 85, "complexity": 20, "token_count": 679, "parameters": [ "inputs", "inputarrays", "nin" ], "start_line": 222, "end_line": 333, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 112, "top_nesting_level": 0 }, { "name": "type_from_object", "long_name": "type_from_object( PyObject * obj)", "filename": "_compiled_base.c", "nloc": 10, "complexity": 6, "token_count": 74, "parameters": [ "obj" ], "start_line": 335, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "type_from_char", "long_name": "type_from_char( char typechar)", "filename": "_compiled_base.c", "nloc": 20, "complexity": 14, "token_count": 98, "parameters": [ "typechar" ], "start_line": 346, "end_line": 367, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "setup_output_arrays", "long_name": "setup_output_arrays( PyObject * func , PyArrayObject ** inarr , int nin , PyArrayObject ** * outarr , char * otypes , int numtypes)", "filename": "_compiled_base.c", "nloc": 96, "complexity": 19, "token_count": 669, "parameters": [ "func", "inarr", "nin", "outarr", "otypes", "numtypes" ], "start_line": 376, "end_line": 491, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 }, { "name": "loop_over_arrays", "long_name": "loop_over_arrays( PyObject * func , PyArrayObject ** inarr , int nin , PyArrayObject ** outarr , int nout)", "filename": "_compiled_base.c", "nloc": 68, "complexity": 12, "token_count": 483, "parameters": [ "func", "inarr", "nin", "outarr", "nout" ], "start_line": 528, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 87, "top_nesting_level": 0 }, { "name": "build_output", "long_name": "build_output( PyArrayObject ** outarr , int nout)", "filename": "_compiled_base.c", "nloc": 9, "complexity": 4, "token_count": 83, "parameters": [ "outarr", "nout" ], "start_line": 616, "end_line": 625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "map_PyFunc", "long_name": "map_PyFunc( PyObject * self , PyObject * args)", "filename": "_compiled_base.c", "nloc": 44, "complexity": 8, "token_count": 300, "parameters": [ "self", "args" ], "start_line": 629, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "scipy_numeric_save", "long_name": "scipy_numeric_save()", "filename": "_compiled_base.c", "nloc": 14, "complexity": 2, "token_count": 94, "parameters": [], "start_line": 695, "end_line": 710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "scipy_numeric_restore", "long_name": "scipy_numeric_restore()", "filename": "_compiled_base.c", "nloc": 13, "complexity": 2, "token_count": 89, "parameters": [], "start_line": 712, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "scipy_numeric_alter", "long_name": "scipy_numeric_alter()", "filename": "_compiled_base.c", "nloc": 3, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 730, "end_line": 734, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "numeric_behavior_alter", "long_name": "numeric_behavior_alter( PyObject * self , PyObject * args)", "filename": "_compiled_base.c", "nloc": 8, "complexity": 2, "token_count": 41, "parameters": [ "self", "args" ], "start_line": 738, "end_line": 747, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "numeric_behavior_restore", "long_name": "numeric_behavior_restore( PyObject * self , PyObject * args)", "filename": "_compiled_base.c", "nloc": 7, "complexity": 2, "token_count": 37, "parameters": [ "self", "args" ], "start_line": 751, "end_line": 759, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "init_compiled_base", "long_name": "init_compiled_base()", "filename": "_compiled_base.c", "nloc": 11, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 777, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 } ], "methods_before": [ { "name": "base_unique", "long_name": "base_unique( PyObject * self , PyObject * args , PyObject * kwdict)", "filename": "_compiled_base.c", "nloc": 55, "complexity": 11, "token_count": 381, "parameters": [ "self", "args", "kwdict" ], "start_line": 8, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "base_insert", "long_name": "base_insert( PyObject * self , PyObject * args , PyObject * kwdict)", "filename": "_compiled_base.c", "nloc": 89, "complexity": 21, "token_count": 709, "parameters": [ "self", "args", "kwdict" ], "start_line": 81, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 122, "top_nesting_level": 0 }, { "name": "cleanup_arrays", "long_name": "cleanup_arrays( PyArrayObject ** arrays , int number)", "filename": "_compiled_base.c", "nloc": 7, "complexity": 2, "token_count": 41, "parameters": [ "arrays", "number" ], "start_line": 206, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "setup_input_arrays", "long_name": "setup_input_arrays( PyTupleObject * inputs , PyArrayObject ** inputarrays , int nin)", "filename": "_compiled_base.c", "nloc": 85, "complexity": 20, "token_count": 679, "parameters": [ "inputs", "inputarrays", "nin" ], "start_line": 222, "end_line": 333, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 112, "top_nesting_level": 0 }, { "name": "type_from_object", "long_name": "type_from_object( PyObject * obj)", "filename": "_compiled_base.c", "nloc": 10, "complexity": 6, "token_count": 74, "parameters": [ "obj" ], "start_line": 335, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "type_from_char", "long_name": "type_from_char( char typechar)", "filename": "_compiled_base.c", "nloc": 20, "complexity": 14, "token_count": 98, "parameters": [ "typechar" ], "start_line": 346, "end_line": 367, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "setup_output_arrays", "long_name": "setup_output_arrays( PyObject * func , PyArrayObject ** inarr , int nin , PyArrayObject ** * outarr , char * otypes , int numtypes)", "filename": "_compiled_base.c", "nloc": 96, "complexity": 19, "token_count": 669, "parameters": [ "func", "inarr", "nin", "outarr", "otypes", "numtypes" ], "start_line": 376, "end_line": 491, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 }, { "name": "loop_over_arrays", "long_name": "loop_over_arrays( PyObject * func , PyArrayObject ** inarr , int nin , PyArrayObject ** outarr , int nout)", "filename": "_compiled_base.c", "nloc": 68, "complexity": 12, "token_count": 483, "parameters": [ "func", "inarr", "nin", "outarr", "nout" ], "start_line": 528, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 87, "top_nesting_level": 0 }, { "name": "build_output", "long_name": "build_output( PyArrayObject ** outarr , int nout)", "filename": "_compiled_base.c", "nloc": 9, "complexity": 4, "token_count": 83, "parameters": [ "outarr", "nout" ], "start_line": 616, "end_line": 625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "map_PyFunc", "long_name": "map_PyFunc( PyObject * self , PyObject * args)", "filename": "_compiled_base.c", "nloc": 44, "complexity": 8, "token_count": 300, "parameters": [ "self", "args" ], "start_line": 629, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "scipy_numeric_save", "long_name": "scipy_numeric_save()", "filename": "_compiled_base.c", "nloc": 21, "complexity": 3, "token_count": 143, "parameters": [], "start_line": 695, "end_line": 719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "scipy_numeric_restore", "long_name": "scipy_numeric_restore()", "filename": "_compiled_base.c", "nloc": 20, "complexity": 3, "token_count": 138, "parameters": [], "start_line": 721, "end_line": 742, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "scipy_numeric_alter", "long_name": "scipy_numeric_alter()", "filename": "_compiled_base.c", "nloc": 10, "complexity": 2, "token_count": 65, "parameters": [], "start_line": 746, "end_line": 759, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "numeric_behavior_alter", "long_name": "numeric_behavior_alter( PyObject * self , PyObject * args)", "filename": "_compiled_base.c", "nloc": 8, "complexity": 2, "token_count": 41, "parameters": [ "self", "args" ], "start_line": 763, "end_line": 772, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "numeric_behavior_restore", "long_name": "numeric_behavior_restore( PyObject * self , PyObject * args)", "filename": "_compiled_base.c", "nloc": 7, "complexity": 2, "token_count": 37, "parameters": [ "self", "args" ], "start_line": 776, "end_line": 784, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "init_compiled_base", "long_name": "init_compiled_base()", "filename": "_compiled_base.c", "nloc": 11, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 802, "end_line": 821, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "scipy_numeric_restore", "long_name": "scipy_numeric_restore()", "filename": "_compiled_base.c", "nloc": 13, "complexity": 2, "token_count": 89, "parameters": [], "start_line": 712, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "scipy_numeric_alter", "long_name": "scipy_numeric_alter()", "filename": "_compiled_base.c", "nloc": 3, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 730, "end_line": 734, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "scipy_numeric_save", "long_name": "scipy_numeric_save()", "filename": "_compiled_base.c", "nloc": 14, "complexity": 2, "token_count": 94, "parameters": [], "start_line": 695, "end_line": 710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 } ], "nloc": 565, "complexity": 128, "token_count": 4049, "diff_parsed": { "added": [ " /* we just save copies of things we may alter. */", "\tBackupPyArray_Type.tp_name = (PyArray_Type).tp_name;", "\tmemcpy(&backup_array_as_number, (PyArray_Type).tp_as_number,", "\tmemcpy(&backup_array_as_sequence, (PyArray_Type).tp_as_sequence,", "\tmemcpy(&backup_array_as_mapping, (PyArray_Type).tp_as_mapping,", "\tmemcpy(&backup_array_as_buffer, (PyArray_Type).tp_as_buffer,", " /* restore only what was copied */", " if (numeric_stored) {", "\t(PyArray_Type).tp_name = BackupPyArray_Type.tp_name;", "\tmemcpy((PyArray_Type).tp_as_number, &backup_array_as_number,", "\tmemcpy((PyArray_Type).tp_as_sequence, &backup_array_as_sequence,", "\tmemcpy((PyArray_Type).tp_as_mapping, &backup_array_as_mapping,", "\tmemcpy((PyArray_Type).tp_as_buffer, &backup_array_as_buffer,", " (PyArray_Type).tp_name = _scipystr;" ], "deleted": [ " PyArrayObject *temp=NULL;", " int mydims[1]={1};", " PyTypeObject *obtype;", "", "\ttemp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);", "\tif (temp==NULL) return;", "\tobtype = temp->ob_type;", "", "\tmemcpy(&BackupPyArray_Type, obtype, sizeof(PyTypeObject));", "\tmemcpy(&backup_array_as_number, obtype->tp_as_number,", "\tmemcpy(&backup_array_as_sequence, obtype->tp_as_sequence,", "\tmemcpy(&backup_array_as_mapping, obtype->tp_as_mapping,", "\tmemcpy(&backup_array_as_buffer, obtype->tp_as_buffer,", "\tPy_DECREF(temp);", "", " PyArrayObject *temp=NULL;", " int mydims[1]={1};", " PyTypeObject *obtype;", " if (numeric_stored) {", "\ttemp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);", "\tif (temp==NULL) return;", "\tobtype = temp->ob_type;", "", "\tmemcpy(obtype, &BackupPyArray_Type, sizeof(PyTypeObject));", "\tmemcpy(obtype->tp_as_number, &backup_array_as_number,", "\tmemcpy(obtype->tp_as_sequence, &backup_array_as_sequence,", "\tmemcpy(obtype->tp_as_mapping, &backup_array_as_mapping,", "\tmemcpy(obtype->tp_as_buffer, &backup_array_as_buffer,", "\tPy_DECREF(temp);", " PyArrayObject *temp=NULL;", " int mydims[1]={1};", " PyTypeObject *obtype;", "", "", " temp = (PyArrayObject *)PyArray_FromDims(1,mydims,PyArray_SHORT);", " if (temp==NULL) return;", " obtype = temp->ob_type;", " obtype->tp_name = _scipystr;", " Py_DECREF(temp);" ] } } ] }, { "hash": "aa6fd3365a968a4c322dff8850466aabb96a1c53", "msg": "Got scipy_core to build on win32 with new build_src hooks", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-04T14:30:06+00:00", "author_timezone": 0, "committer_date": "2004-02-04T14:30:06+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "da3e21058bbbac8c8f53037c8932ca4e05ddb7b1" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 232, "insertions": 285, "lines": 517, "files": 6, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/__init__.py", "new_path": "scipy_distutils/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -7,3 +7,12 @@\n # Need to do something here to get distutils subsumed...\n \n from scipy_distutils_version import scipy_distutils_version as __version__\n+\n+import sys\n+\n+# Replace distutils.ccompiler with scipy_distutils.ccompiler\n+assert not sys.modules.has_key('distutils.ccompiler'),\\\n+ 'distutils has been imported before scipy_distutils'\n+import ccompiler\n+sys.modules['distutils.ccompiler'] = ccompiler\n+\n", "added_lines": 9, "deleted_lines": 0, "source_code": "\"\"\"scipy_distutils\n\n Modified version of distutils to handle fortran source code, f2py,\n and other issues in the scipy build process.\n\"\"\"\n\n# Need to do something here to get distutils subsumed...\n\nfrom scipy_distutils_version import scipy_distutils_version as __version__\n\nimport sys\n\n# Replace distutils.ccompiler with scipy_distutils.ccompiler\nassert not sys.modules.has_key('distutils.ccompiler'),\\\n 'distutils has been imported before scipy_distutils'\nimport ccompiler\nsys.modules['distutils.ccompiler'] = ccompiler\n\n", "source_code_before": "\"\"\"scipy_distutils\n\n Modified version of distutils to handle fortran source code, f2py,\n and other issues in the scipy build process.\n\"\"\"\n\n# Need to do something here to get distutils subsumed...\n\nfrom scipy_distutils_version import scipy_distutils_version as __version__\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 11, "complexity": 0, "token_count": 32, "diff_parsed": { "added": [ "", "import sys", "", "# Replace distutils.ccompiler with scipy_distutils.ccompiler", "assert not sys.modules.has_key('distutils.ccompiler'),\\", " 'distutils has been imported before scipy_distutils'", "import ccompiler", "sys.modules['distutils.ccompiler'] = ccompiler", "" ], "deleted": [] } }, { "old_path": null, "new_path": "scipy_distutils/ccompiler.py", "filename": "ccompiler.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,63 @@\n+\n+import re\n+import os\n+import sys\n+\n+from distutils.ccompiler import *\n+from distutils import ccompiler\n+\n+import log\n+\n+if sys.platform == 'win32':\n+ compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler',\n+ \"Mingw32 port of GNU C Compiler for Win32\"\\\n+ \"(for MSC built Python)\")\n+ if os.environ.get('OSTYPE','')=='msys':\n+ # On windows platforms, we want to default to mingw32 (gcc)\n+ # because msvc can't build blitz stuff.\n+ log.info('Setting mingw32 as default compiler for nt.')\n+ ccompiler._default_compilers = (('nt', 'mingw32'),) \\\n+ + ccompiler._default_compilers\n+\n+_distutils_new_compiler = new_compiler\n+def new_compiler (plat=None,\n+ compiler=None,\n+ verbose=0,\n+ dry_run=0,\n+ force=0):\n+ # Try first C compilers from scipy_distutils.\n+ if plat is None:\n+ plat = os.name\n+ try:\n+ if compiler is None:\n+ compiler = get_default_compiler(plat)\n+ (module_name, class_name, long_description) = compiler_class[compiler]\n+ except KeyError:\n+ msg = \"don't know how to compile C/C++ code on platform '%s'\" % plat\n+ if compiler is not None:\n+ msg = msg + \" with '%s' compiler\" % compiler\n+ raise DistutilsPlatformError, msg\n+\n+ module_name = \"scipy_distutils.\" + module_name\n+ try:\n+ __import__ (module_name)\n+ except ImportError, msg:\n+ print msg\n+ module_name = module_name[6:]\n+ try:\n+ __import__(module_name)\n+ except ImportError:\n+ raise DistutilsModuleError, \\\n+ \"can't compile C/C++ code: unable to load module '%s'\" % \\\n+ module_name\n+ try:\n+ module = sys.modules[module_name]\n+ klass = vars(module)[class_name]\n+ except KeyError:\n+ raise DistutilsModuleError, \\\n+ (\"can't compile C/C++ code: unable to find class '%s' \" +\n+ \"in module '%s'\") % (class_name, module_name)\n+ print '*'*80\n+ print module_name,klass\n+ print '*'*80\n+ return klass(None, dry_run, force)\n", "added_lines": 63, "deleted_lines": 0, "source_code": "\nimport re\nimport os\nimport sys\n\nfrom distutils.ccompiler import *\nfrom distutils import ccompiler\n\nimport log\n\nif sys.platform == 'win32':\n compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler',\n \"Mingw32 port of GNU C Compiler for Win32\"\\\n \"(for MSC built Python)\")\n if os.environ.get('OSTYPE','')=='msys':\n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n log.info('Setting mingw32 as default compiler for nt.')\n ccompiler._default_compilers = (('nt', 'mingw32'),) \\\n + ccompiler._default_compilers\n\n_distutils_new_compiler = new_compiler\ndef new_compiler (plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n # Try first C compilers from scipy_distutils.\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_compiler(plat)\n (module_name, class_name, long_description) = compiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile C/C++ code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler\" % compiler\n raise DistutilsPlatformError, msg\n\n module_name = \"scipy_distutils.\" + module_name\n try:\n __import__ (module_name)\n except ImportError, msg:\n print msg\n module_name = module_name[6:]\n try:\n __import__(module_name)\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile C/C++ code: unable to load module '%s'\" % \\\n module_name\n try:\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile C/C++ code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n print '*'*80\n print module_name,klass\n print '*'*80\n return klass(None, dry_run, force)\n", "source_code_before": null, "methods": [ { "name": "new_compiler", "long_name": "new_compiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "ccompiler.py", "nloc": 39, "complexity": 8, "token_count": 183, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 23, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "new_compiler", "long_name": "new_compiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "ccompiler.py", "nloc": 39, "complexity": 8, "token_count": 183, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 23, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 } ], "nloc": 54, "complexity": 8, "token_count": 263, "diff_parsed": { "added": [ "", "import re", "import os", "import sys", "", "from distutils.ccompiler import *", "from distutils import ccompiler", "", "import log", "", "if sys.platform == 'win32':", " compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler',", " \"Mingw32 port of GNU C Compiler for Win32\"\\", " \"(for MSC built Python)\")", " if os.environ.get('OSTYPE','')=='msys':", " # On windows platforms, we want to default to mingw32 (gcc)", " # because msvc can't build blitz stuff.", " log.info('Setting mingw32 as default compiler for nt.')", " ccompiler._default_compilers = (('nt', 'mingw32'),) \\", " + ccompiler._default_compilers", "", "_distutils_new_compiler = new_compiler", "def new_compiler (plat=None,", " compiler=None,", " verbose=0,", " dry_run=0,", " force=0):", " # Try first C compilers from scipy_distutils.", " if plat is None:", " plat = os.name", " try:", " if compiler is None:", " compiler = get_default_compiler(plat)", " (module_name, class_name, long_description) = compiler_class[compiler]", " except KeyError:", " msg = \"don't know how to compile C/C++ code on platform '%s'\" % plat", " if compiler is not None:", " msg = msg + \" with '%s' compiler\" % compiler", " raise DistutilsPlatformError, msg", "", " module_name = \"scipy_distutils.\" + module_name", " try:", " __import__ (module_name)", " except ImportError, msg:", " print msg", " module_name = module_name[6:]", " try:", " __import__(module_name)", " except ImportError:", " raise DistutilsModuleError, \\", " \"can't compile C/C++ code: unable to load module '%s'\" % \\", " module_name", " try:", " module = sys.modules[module_name]", " klass = vars(module)[class_name]", " except KeyError:", " raise DistutilsModuleError, \\", " (\"can't compile C/C++ code: unable to find class '%s' \" +", " \"in module '%s'\") % (class_name, module_name)", " print '*'*80", " print module_name,klass", " print '*'*80", " return klass(None, dry_run, force)" ], "deleted": [] } }, { "old_path": "scipy_distutils/mingw32_support.py", "new_path": null, "filename": "mingw32_support.py", "extension": "py", "change_type": "DELETE", "diff": "@@ -1,228 +0,0 @@\n-\"\"\"\n-Support code for building Python extensions on Windows.\n-\n- # NT stuff\n- # 1. Make sure libpython.a exists for gcc. If not, build it.\n- # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n- # 3. Force windows to use g77\n-\n-\"\"\"\n-\n-import os, sys\n-import distutils.ccompiler\n-\n-# I'd really like to pull this out of scipy and make it part of distutils...\n-import scipy_distutils.command.build_flib as build_flib\n-\n-\n-if sys.platform == 'win32':\n- # NT stuff\n- # 1. Make sure libpython.a exists for gcc. If not, build it.\n- # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n- # 3. Force windows to use g77\n- \n- # 1. Build libpython from .lib and .dll if they don't exist. \n- import distutils.cygwinccompiler\n- from distutils.version import StrictVersion\n- from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n- from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n- \n- from distutils.unixccompiler import UnixCCompiler \n- \n- # the same as cygwin plus some additional parameters\n- class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n- \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n- \n- \"\"\"\n- \n- compiler_type = 'mingw32'\n- \n- def __init__ (self,\n- verbose=0,\n- dry_run=0,\n- force=0):\n- \n- distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n- verbose,dry_run, force)\n- \n- # we need to support 3.2 which doesn't match the standard\n- # get_versions methods regex\n- if self.gcc_version is None:\n- import re\n- out = os.popen('gcc' + ' -dumpversion','r')\n- out_string = out.read()\n- out.close()\n- result = re.search('(\\d+\\.\\d+)',out_string)\n- if result:\n- self.gcc_version = StrictVersion(result.group(1)) \n-\n- # A real mingw32 doesn't need to specify a different entry point,\n- # but cygwin 2.91.57 in no-cygwin-mode needs it.\n- if self.gcc_version <= \"2.91.57\":\n- entry_point = '--entry _DllMain@12'\n- else:\n- entry_point = ''\n- if self.linker_dll == 'dllwrap':\n- self.linker = 'dllwrap' + ' --driver-name g++'\n- elif self.linker_dll == 'gcc':\n- self.linker = 'g++' \n-\n- # **changes: eric jones 4/11/01\n- # 1. Check for import library on Windows. Build if it doesn't exist.\n- if not import_library_exists():\n- build_import_library()\n- \n- # **changes: eric jones 4/11/01\n- # 2. increased optimization and turned off all warnings\n- # 3. also added --driver-name g++\n- #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n- # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n- # linker_exe='gcc -mno-cygwin',\n- # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n- # % (self.linker, entry_point))\n- if self.gcc_version <= \"3.0.0\":\n- self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n- compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n- linker_exe='g++ -mno-cygwin',\n- linker_so='%s -mno-cygwin -mdll -static %s' \n- % (self.linker, entry_point))\n- else: \n- self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n- compiler_so='gcc -O2 -w -Wstrict-prototypes',\n- linker_exe='g++ ',\n- linker_so='g++ -shared')\n- # added for python2.3 support\n- # we can't pass it through set_executables because pre 2.2 would fail\n- self.compiler_cxx = ['g++']\n- \n- # Maybe we should also append -mthreads, but then the finished\n- # dlls need another dll (mingwm10.dll see Mingw32 docs)\n- # (-mthreads: Support thread-safe exception handling on `Mingw32') \n- \n- # no additional libraries needed \n- self.dll_libraries=[]\n- \n- # __init__ ()\n-\n- def link(self,\n- target_desc,\n- objects,\n- output_filename,\n- output_dir,\n- libraries,\n- library_dirs,\n- runtime_library_dirs,\n- export_symbols = None,\n- debug=0,\n- extra_preargs=None,\n- extra_postargs=None,\n- build_temp=None,\n- target_lang=None):\n- args = (self,\n- target_desc,\n- objects,\n- output_filename,\n- output_dir,\n- libraries,\n- library_dirs,\n- runtime_library_dirs,\n- None, #export_symbols, we do this in our def-file\n- debug,\n- extra_preargs,\n- extra_postargs,\n- build_temp,\n- target_lang)\n- if self.gcc_version < \"3.0.0\":\n- func = distutils.cygwinccompiler.CygwinCCompiler.link\n- else:\n- func = UnixCCompiler.link\n- func(*args[:func.im_func.func_code.co_argcount])\n-\n- def object_filenames (self,\n- source_filenames,\n- strip_dir=0,\n- output_dir=''):\n- if output_dir is None: output_dir = ''\n- print 'cygiwn_output_dir:', output_dir\n- obj_names = []\n- for src_name in source_filenames:\n- # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n- (base, ext) = os.path.splitext (os.path.normcase(src_name))\n- \n- # added these lines to strip off windows drive letters\n- # without it, .o files are placed next to .c files\n- # instead of the build directory\n- drv,base = os.path.splitdrive(base)\n- if drv:\n- base = base[1:]\n- \n- if ext not in (self.src_extensions + ['.rc','.res']):\n- raise UnknownFileError, \\\n- \"unknown file type '%s' (from '%s')\" % \\\n- (ext, src_name)\n- if strip_dir:\n- base = os.path.basename (base)\n- if ext == '.res' or ext == '.rc':\n- # these need to be compiled to object files\n- obj_names.append (os.path.join (output_dir,\n- base + ext + self.obj_extension))\n- else:\n- print 'here', os.path.join (output_dir,\n- base + self.obj_extension)\n- print '...:', output_dir, base + self.obj_extension \n- obj_names.append (os.path.join (output_dir,\n- base + self.obj_extension))\n- return obj_names\n- \n- # object_filenames ()\n-\n- \n- # On windows platforms, we want to default to mingw32 (gcc)\n- # because msvc can't build blitz stuff.\n- # We should also check the version of gcc available...\n- #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n- distutils.ccompiler._default_compilers = (('nt', 'mingw32'),) + \\\n- distutils.ccompiler._default_compilers\n- # reset the Mingw32 compiler in distutils to the one defined above\n- distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n- \n- def import_library_exists():\n- \"\"\" on windows platforms, make sure a gcc import library exists\n- \"\"\"\n- if os.name == 'nt':\n- lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n- full_path = os.path.join(sys.prefix,'libs',lib_name)\n- if not os.path.exists(full_path):\n- return 0\n- return 1\n- \n- def build_import_library():\n- \"\"\" Build the import libraries for Mingw32-gcc on Windows\n- \"\"\"\n- from scipy_distutils import lib2def\n- #libfile, deffile = parse_cmd()\n- #if deffile is None:\n- # deffile = sys.stdout\n- #else:\n- # deffile = open(deffile, 'w')\n- lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n- lib_file = os.path.join(sys.prefix,'libs',lib_name)\n- def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n- def_file = os.path.join(sys.prefix,'libs',def_name)\n- nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n- nm_output = lib2def.getnm(nm_cmd)\n- dlist, flist = lib2def.parse_nm(nm_output)\n- lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n- \n- out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n- out_file = os.path.join(sys.prefix,'libs',out_name)\n- dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n- args = (dll_name,def_file,out_file)\n- cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n- success = not os.system(cmd)\n- # for now, fail silently\n- if not success:\n- print 'WARNING: failed to build import library for gcc. Linking will fail.'\n- #if not success:\n- # msg = \"Couldn't find import library, and failed to build it.\"\n- # raise DistutilsPlatformError, msg\n", "added_lines": 0, "deleted_lines": 228, "source_code": null, "source_code_before": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os, sys\nimport distutils.ccompiler\n\n# I'd really like to pull this out of scipy and make it part of distutils...\nimport scipy_distutils.command.build_flib as build_flib\n\n\nif sys.platform == 'win32':\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = ['g++']\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None,\n target_lang=None):\n args = (self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, #export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n if self.gcc_version < \"3.0.0\":\n func = distutils.cygwinccompiler.CygwinCCompiler.link\n else:\n func = UnixCCompiler.link\n func(*args[:func.im_func.func_code.co_argcount])\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n print 'here', os.path.join (output_dir,\n base + self.obj_extension)\n print '...:', output_dir, base + self.obj_extension \n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n \n # object_filenames ()\n\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n distutils.ccompiler._default_compilers = (('nt', 'mingw32'),) + \\\n distutils.ccompiler._default_compilers\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n", "methods": [], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 212, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32_support.py", "nloc": 33, "complexity": 2, "token_count": 112, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 107, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 2 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32_support.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 141, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 189, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 199, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 189, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 212, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32_support.py", "nloc": 33, "complexity": 2, "token_count": 112, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 107, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 2 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32_support.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 141, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 2 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 199, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 } ], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "\"\"\"", "Support code for building Python extensions on Windows.", "", " # NT stuff", " # 1. Make sure libpython.a exists for gcc. If not, build it.", " # 2. Force windows to use gcc (we're struggling with MSVC and g77 support)", " # 3. Force windows to use g77", "", "\"\"\"", "", "import os, sys", "import distutils.ccompiler", "", "# I'd really like to pull this out of scipy and make it part of distutils...", "import scipy_distutils.command.build_flib as build_flib", "", "", "if sys.platform == 'win32':", " # NT stuff", " # 1. Make sure libpython.a exists for gcc. If not, build it.", " # 2. Force windows to use gcc (we're struggling with MSVC and g77 support)", " # 3. Force windows to use g77", "", " # 1. Build libpython from .lib and .dll if they don't exist.", " import distutils.cygwinccompiler", " from distutils.version import StrictVersion", " from distutils.ccompiler import gen_preprocess_options, gen_lib_options", " from distutils.errors import DistutilsExecError, CompileError, UnknownFileError", "", " from distutils.unixccompiler import UnixCCompiler", "", " # the same as cygwin plus some additional parameters", " class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):", " \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.", "", " \"\"\"", "", " compiler_type = 'mingw32'", "", " def __init__ (self,", " verbose=0,", " dry_run=0,", " force=0):", "", " distutils.cygwinccompiler.CygwinCCompiler.__init__ (self,", " verbose,dry_run, force)", "", " # we need to support 3.2 which doesn't match the standard", " # get_versions methods regex", " if self.gcc_version is None:", " import re", " out = os.popen('gcc' + ' -dumpversion','r')", " out_string = out.read()", " out.close()", " result = re.search('(\\d+\\.\\d+)',out_string)", " if result:", " self.gcc_version = StrictVersion(result.group(1))", "", " # A real mingw32 doesn't need to specify a different entry point,", " # but cygwin 2.91.57 in no-cygwin-mode needs it.", " if self.gcc_version <= \"2.91.57\":", " entry_point = '--entry _DllMain@12'", " else:", " entry_point = ''", " if self.linker_dll == 'dllwrap':", " self.linker = 'dllwrap' + ' --driver-name g++'", " elif self.linker_dll == 'gcc':", " self.linker = 'g++'", "", " # **changes: eric jones 4/11/01", " # 1. Check for import library on Windows. Build if it doesn't exist.", " if not import_library_exists():", " build_import_library()", "", " # **changes: eric jones 4/11/01", " # 2. increased optimization and turned off all warnings", " # 3. also added --driver-name g++", " #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',", " # compiler_so='gcc -mno-cygwin -mdll -O2 -w',", " # linker_exe='gcc -mno-cygwin',", " # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s'", " # % (self.linker, entry_point))", " if self.gcc_version <= \"3.0.0\":", " self.set_executables(compiler='gcc -mno-cygwin -O2 -w',", " compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',", " linker_exe='g++ -mno-cygwin',", " linker_so='%s -mno-cygwin -mdll -static %s'", " % (self.linker, entry_point))", " else:", " self.set_executables(compiler='gcc -mno-cygwin -O2 -w',", " compiler_so='gcc -O2 -w -Wstrict-prototypes',", " linker_exe='g++ ',", " linker_so='g++ -shared')", " # added for python2.3 support", " # we can't pass it through set_executables because pre 2.2 would fail", " self.compiler_cxx = ['g++']", "", " # Maybe we should also append -mthreads, but then the finished", " # dlls need another dll (mingwm10.dll see Mingw32 docs)", " # (-mthreads: Support thread-safe exception handling on `Mingw32')", "", " # no additional libraries needed", " self.dll_libraries=[]", "", " # __init__ ()", "", " def link(self,", " target_desc,", " objects,", " output_filename,", " output_dir,", " libraries,", " library_dirs,", " runtime_library_dirs,", " export_symbols = None,", " debug=0,", " extra_preargs=None,", " extra_postargs=None,", " build_temp=None,", " target_lang=None):", " args = (self,", " target_desc,", " objects,", " output_filename,", " output_dir,", " libraries,", " library_dirs,", " runtime_library_dirs,", " None, #export_symbols, we do this in our def-file", " debug,", " extra_preargs,", " extra_postargs,", " build_temp,", " target_lang)", " if self.gcc_version < \"3.0.0\":", " func = distutils.cygwinccompiler.CygwinCCompiler.link", " else:", " func = UnixCCompiler.link", " func(*args[:func.im_func.func_code.co_argcount])", "", " def object_filenames (self,", " source_filenames,", " strip_dir=0,", " output_dir=''):", " if output_dir is None: output_dir = ''", " print 'cygiwn_output_dir:', output_dir", " obj_names = []", " for src_name in source_filenames:", " # use normcase to make sure '.rc' is really '.rc' and not '.RC'", " (base, ext) = os.path.splitext (os.path.normcase(src_name))", "", " # 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)", " if drv:", " base = base[1:]", "", " if ext not in (self.src_extensions + ['.rc','.res']):", " raise UnknownFileError, \\", " \"unknown file type '%s' (from '%s')\" % \\", " (ext, src_name)", " if strip_dir:", " base = os.path.basename (base)", " if ext == '.res' or ext == '.rc':", " # these need to be compiled to object files", " obj_names.append (os.path.join (output_dir,", " base + ext + self.obj_extension))", " else:", " print 'here', os.path.join (output_dir,", " base + self.obj_extension)", " print '...:', output_dir, base + self.obj_extension", " obj_names.append (os.path.join (output_dir,", " base + self.obj_extension))", " return obj_names", "", " # object_filenames ()", "", "", " # On windows platforms, we want to default to mingw32 (gcc)", " # because msvc can't build blitz stuff.", " # We should also check the version of gcc available...", " #distutils.ccompiler._default_compilers['nt'] = 'mingw32'", " distutils.ccompiler._default_compilers = (('nt', 'mingw32'),) + \\", " distutils.ccompiler._default_compilers", " # reset the Mingw32 compiler in distutils to the one defined above", " distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler", "", " def import_library_exists():", " \"\"\" on windows platforms, make sure a gcc import library exists", " \"\"\"", " if os.name == 'nt':", " lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])", " full_path = os.path.join(sys.prefix,'libs',lib_name)", " if not os.path.exists(full_path):", " return 0", " return 1", "", " def build_import_library():", " \"\"\" Build the import libraries for Mingw32-gcc on Windows", " \"\"\"", " from scipy_distutils import lib2def", " #libfile, deffile = parse_cmd()", " #if deffile is None:", " # deffile = sys.stdout", " #else:", " # deffile = open(deffile, 'w')", " lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2])", " lib_file = os.path.join(sys.prefix,'libs',lib_name)", " def_name = \"python%d%d.def\" % tuple(sys.version_info[:2])", " 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'))", "", " out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])", " out_file = os.path.join(sys.prefix,'libs',out_name)", " dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])", " args = (dll_name,def_file,out_file)", " cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args", " success = not os.system(cmd)", " # for now, fail silently", " if not success:", " print 'WARNING: failed to build import library for gcc. Linking will fail.'", " #if not success:", " # msg = \"Couldn't find import library, and failed to build it.\"", " # raise DistutilsPlatformError, msg" ] } }, { "old_path": null, "new_path": "scipy_distutils/mingw32ccompiler.py", "filename": "mingw32ccompiler.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,211 @@\n+\"\"\"\n+Support code for building Python extensions on Windows.\n+\n+ # NT stuff\n+ # 1. Make sure libpython.a exists for gcc. If not, build it.\n+ # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n+ # 3. Force windows to use g77\n+\n+\"\"\"\n+\n+import os\n+import sys\n+import log\n+\n+import scipy_distutils.ccompiler\n+\n+# NT stuff\n+# 1. Make sure libpython.a exists for gcc. If not, build it.\n+# 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n+# 3. Force windows to use g77\n+\n+# 1. Build libpython from .lib and .dll if they don't exist. \n+import distutils.cygwinccompiler\n+from distutils.version import StrictVersion\n+from scipy_distutils.ccompiler import gen_preprocess_options, gen_lib_options\n+from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n+\n+from distutils.unixccompiler import UnixCCompiler \n+ \n+# the same as cygwin plus some additional parameters\n+class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n+ \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n+ \n+ \"\"\"\n+ \n+ compiler_type = 'mingw32'\n+ \n+ def __init__ (self,\n+ verbose=0,\n+ dry_run=0,\n+ force=0):\n+ \n+ distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n+ verbose,dry_run, force)\n+ \n+ # we need to support 3.2 which doesn't match the standard\n+ # get_versions methods regex\n+ if self.gcc_version is None:\n+ import re\n+ out = os.popen('gcc' + ' -dumpversion','r')\n+ out_string = out.read()\n+ out.close()\n+ result = re.search('(\\d+\\.\\d+)',out_string)\n+ if result:\n+ self.gcc_version = StrictVersion(result.group(1)) \n+\n+ # A real mingw32 doesn't need to specify a different entry point,\n+ # but cygwin 2.91.57 in no-cygwin-mode needs it.\n+ if self.gcc_version <= \"2.91.57\":\n+ entry_point = '--entry _DllMain@12'\n+ else:\n+ entry_point = ''\n+\n+ if self.linker_dll == 'dllwrap':\n+ self.linker = 'dllwrap --driver-name g++'\n+ elif self.linker_dll == 'gcc':\n+ self.linker = 'g++' \n+\n+ # **changes: eric jones 4/11/01\n+ # 1. Check for import library on Windows. Build if it doesn't exist.\n+\n+ build_import_library()\n+\n+ # **changes: eric jones 4/11/01\n+ # 2. increased optimization and turned off all warnings\n+ # 3. also added --driver-name g++\n+ #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n+ # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n+ # linker_exe='gcc -mno-cygwin',\n+ # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n+ # % (self.linker, entry_point))\n+ if self.gcc_version <= \"3.0.0\":\n+ self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n+ compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n+ linker_exe='g++ -mno-cygwin',\n+ linker_so='%s -mno-cygwin -mdll -static %s' \n+ % (self.linker, entry_point))\n+ else: \n+ self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n+ compiler_so='gcc -O2 -w -Wstrict-prototypes',\n+ linker_exe='g++ ',\n+ linker_so='g++ -shared')\n+ # added for python2.3 support\n+ # we can't pass it through set_executables because pre 2.2 would fail\n+ self.compiler_cxx = ['g++']\n+ \n+ # Maybe we should also append -mthreads, but then the finished\n+ # dlls need another dll (mingwm10.dll see Mingw32 docs)\n+ # (-mthreads: Support thread-safe exception handling on `Mingw32') \n+ \n+ # no additional libraries needed \n+ self.dll_libraries=[]\n+ \n+ # __init__ ()\n+\n+ def link(self,\n+ target_desc,\n+ objects,\n+ output_filename,\n+ output_dir,\n+ libraries,\n+ library_dirs,\n+ runtime_library_dirs,\n+ export_symbols = None,\n+ debug=0,\n+ extra_preargs=None,\n+ extra_postargs=None,\n+ build_temp=None,\n+ target_lang=None):\n+ args = (self,\n+ target_desc,\n+ objects,\n+ output_filename,\n+ output_dir,\n+ libraries,\n+ library_dirs,\n+ runtime_library_dirs,\n+ None, #export_symbols, we do this in our def-file\n+ debug,\n+ extra_preargs,\n+ extra_postargs,\n+ build_temp,\n+ target_lang)\n+ if self.gcc_version < \"3.0.0\":\n+ func = distutils.cygwinccompiler.CygwinCCompiler.link\n+ else:\n+ func = UnixCCompiler.link\n+ func(*args[:func.im_func.func_code.co_argcount])\n+\n+ def object_filenames (self,\n+ source_filenames,\n+ strip_dir=0,\n+ output_dir=''):\n+ if output_dir is None: output_dir = ''\n+ print 'cygiwn_output_dir:', output_dir\n+ obj_names = []\n+ for src_name in source_filenames:\n+ # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n+ (base, ext) = os.path.splitext (os.path.normcase(src_name))\n+ \n+ # added these lines to strip off windows drive letters\n+ # without it, .o files are placed next to .c files\n+ # instead of the build directory\n+ drv,base = os.path.splitdrive(base)\n+ if drv:\n+ base = base[1:]\n+ \n+ if ext not in (self.src_extensions + ['.rc','.res']):\n+ raise UnknownFileError, \\\n+ \"unknown file type '%s' (from '%s')\" % \\\n+ (ext, src_name)\n+ if strip_dir:\n+ base = os.path.basename (base)\n+ if ext == '.res' or ext == '.rc':\n+ # these need to be compiled to object files\n+ obj_names.append (os.path.join (output_dir,\n+ base + ext + self.obj_extension))\n+ else:\n+ print 'here', os.path.join (output_dir,\n+ base + self.obj_extension)\n+ print '...:', output_dir, base + self.obj_extension \n+ obj_names.append (os.path.join (output_dir,\n+ base + self.obj_extension))\n+ return obj_names\n+ \n+ # object_filenames ()\n+\n+ \n+def build_import_library():\n+ \"\"\" Build the import libraries for Mingw32-gcc on Windows\n+ \"\"\"\n+ if os.name != 'nt':\n+ return\n+ lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n+ lib_file = os.path.join(sys.prefix,'libs',lib_name)\n+ if os.path.isfile(lib_file):\n+ log.info('Skip building import library \"%s\"' % (lib_file))\n+ return\n+ log.info('Building import library \"%s\"' % (lib_file))\n+\n+ from scipy_distutils import lib2def\n+\n+ def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n+ def_file = os.path.join(sys.prefix,'libs',def_name)\n+ nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n+ nm_output = lib2def.getnm(nm_cmd)\n+ dlist, flist = lib2def.parse_nm(nm_output)\n+ lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n+ \n+ out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n+ out_file = os.path.join(sys.prefix,'libs',out_name)\n+ dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n+ args = (dll_name,def_file,out_file)\n+ cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n+ success = not os.system(cmd)\n+ # for now, fail silently\n+ if not success:\n+ print 'WARNING: failed to build import library for gcc. Linking will fail.'\n+ #if not success:\n+ # msg = \"Couldn't find import library, and failed to build it.\"\n+ # raise DistutilsPlatformError, msg\n", "added_lines": 211, "deleted_lines": 0, "source_code": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os\nimport sys\nimport log\n\nimport scipy_distutils.ccompiler\n\n# NT stuff\n# 1. Make sure libpython.a exists for gcc. If not, build it.\n# 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n# 3. Force windows to use g77\n\n# 1. Build libpython from .lib and .dll if they don't exist. \nimport distutils.cygwinccompiler\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import gen_preprocess_options, gen_lib_options\nfrom distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n\nfrom distutils.unixccompiler import UnixCCompiler \n \n# the same as cygwin plus some additional parameters\nclass Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n\n build_import_library()\n\n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = ['g++']\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None,\n target_lang=None):\n args = (self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, #export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n if self.gcc_version < \"3.0.0\":\n func = distutils.cygwinccompiler.CygwinCCompiler.link\n else:\n func = UnixCCompiler.link\n func(*args[:func.im_func.func_code.co_argcount])\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n print 'here', os.path.join (output_dir,\n base + self.obj_extension)\n print '...:', output_dir, base + self.obj_extension \n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n \n # object_filenames ()\n\n \ndef build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n if os.name != 'nt':\n return\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n if os.path.isfile(lib_file):\n log.info('Skip building import library \"%s\"' % (lib_file))\n return\n log.info('Building import library \"%s\"' % (lib_file))\n\n from scipy_distutils import lib2def\n\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n", "source_code_before": null, "methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32ccompiler.py", "nloc": 36, "complexity": 7, "token_count": 204, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 38, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 1 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32ccompiler.py", "nloc": 33, "complexity": 2, "token_count": 112, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 106, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32ccompiler.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 140, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32ccompiler.py", "nloc": 24, "complexity": 4, "token_count": 229, "parameters": [], "start_line": 179, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32ccompiler.py", "nloc": 36, "complexity": 7, "token_count": 204, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 38, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 1 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32ccompiler.py", "nloc": 33, "complexity": 2, "token_count": 112, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 106, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32ccompiler.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 140, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32ccompiler.py", "nloc": 24, "complexity": 4, "token_count": 229, "parameters": [], "start_line": 179, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 } ], "nloc": 144, "complexity": 21, "token_count": 808, "diff_parsed": { "added": [ "\"\"\"", "Support code for building Python extensions on Windows.", "", " # NT stuff", " # 1. Make sure libpython.a exists for gcc. If not, build it.", " # 2. Force windows to use gcc (we're struggling with MSVC and g77 support)", " # 3. Force windows to use g77", "", "\"\"\"", "", "import os", "import sys", "import log", "", "import scipy_distutils.ccompiler", "", "# NT stuff", "# 1. Make sure libpython.a exists for gcc. If not, build it.", "# 2. Force windows to use gcc (we're struggling with MSVC and g77 support)", "# 3. Force windows to use g77", "", "# 1. Build libpython from .lib and .dll if they don't exist.", "import distutils.cygwinccompiler", "from distutils.version import StrictVersion", "from scipy_distutils.ccompiler import gen_preprocess_options, gen_lib_options", "from distutils.errors import DistutilsExecError, CompileError, UnknownFileError", "", "from distutils.unixccompiler import UnixCCompiler", "", "# the same as cygwin plus some additional parameters", "class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):", " \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.", "", " \"\"\"", "", " compiler_type = 'mingw32'", "", " def __init__ (self,", " verbose=0,", " dry_run=0,", " force=0):", "", " distutils.cygwinccompiler.CygwinCCompiler.__init__ (self,", " verbose,dry_run, force)", "", " # we need to support 3.2 which doesn't match the standard", " # get_versions methods regex", " if self.gcc_version is None:", " import re", " out = os.popen('gcc' + ' -dumpversion','r')", " out_string = out.read()", " out.close()", " result = re.search('(\\d+\\.\\d+)',out_string)", " if result:", " self.gcc_version = StrictVersion(result.group(1))", "", " # A real mingw32 doesn't need to specify a different entry point,", " # but cygwin 2.91.57 in no-cygwin-mode needs it.", " if self.gcc_version <= \"2.91.57\":", " entry_point = '--entry _DllMain@12'", " else:", " entry_point = ''", "", " if self.linker_dll == 'dllwrap':", " self.linker = 'dllwrap --driver-name g++'", " elif self.linker_dll == 'gcc':", " self.linker = 'g++'", "", " # **changes: eric jones 4/11/01", " # 1. Check for import library on Windows. Build if it doesn't exist.", "", " build_import_library()", "", " # **changes: eric jones 4/11/01", " # 2. increased optimization and turned off all warnings", " # 3. also added --driver-name g++", " #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',", " # compiler_so='gcc -mno-cygwin -mdll -O2 -w',", " # linker_exe='gcc -mno-cygwin',", " # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s'", " # % (self.linker, entry_point))", " if self.gcc_version <= \"3.0.0\":", " self.set_executables(compiler='gcc -mno-cygwin -O2 -w',", " compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',", " linker_exe='g++ -mno-cygwin',", " linker_so='%s -mno-cygwin -mdll -static %s'", " % (self.linker, entry_point))", " else:", " self.set_executables(compiler='gcc -mno-cygwin -O2 -w',", " compiler_so='gcc -O2 -w -Wstrict-prototypes',", " linker_exe='g++ ',", " linker_so='g++ -shared')", " # added for python2.3 support", " # we can't pass it through set_executables because pre 2.2 would fail", " self.compiler_cxx = ['g++']", "", " # Maybe we should also append -mthreads, but then the finished", " # dlls need another dll (mingwm10.dll see Mingw32 docs)", " # (-mthreads: Support thread-safe exception handling on `Mingw32')", "", " # no additional libraries needed", " self.dll_libraries=[]", "", " # __init__ ()", "", " def link(self,", " target_desc,", " objects,", " output_filename,", " output_dir,", " libraries,", " library_dirs,", " runtime_library_dirs,", " export_symbols = None,", " debug=0,", " extra_preargs=None,", " extra_postargs=None,", " build_temp=None,", " target_lang=None):", " args = (self,", " target_desc,", " objects,", " output_filename,", " output_dir,", " libraries,", " library_dirs,", " runtime_library_dirs,", " None, #export_symbols, we do this in our def-file", " debug,", " extra_preargs,", " extra_postargs,", " build_temp,", " target_lang)", " if self.gcc_version < \"3.0.0\":", " func = distutils.cygwinccompiler.CygwinCCompiler.link", " else:", " func = UnixCCompiler.link", " func(*args[:func.im_func.func_code.co_argcount])", "", " def object_filenames (self,", " source_filenames,", " strip_dir=0,", " output_dir=''):", " if output_dir is None: output_dir = ''", " print 'cygiwn_output_dir:', output_dir", " obj_names = []", " for src_name in source_filenames:", " # use normcase to make sure '.rc' is really '.rc' and not '.RC'", " (base, ext) = os.path.splitext (os.path.normcase(src_name))", "", " # 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)", " if drv:", " base = base[1:]", "", " if ext not in (self.src_extensions + ['.rc','.res']):", " raise UnknownFileError, \\", " \"unknown file type '%s' (from '%s')\" % \\", " (ext, src_name)", " if strip_dir:", " base = os.path.basename (base)", " if ext == '.res' or ext == '.rc':", " # these need to be compiled to object files", " obj_names.append (os.path.join (output_dir,", " base + ext + self.obj_extension))", " else:", " print 'here', os.path.join (output_dir,", " base + self.obj_extension)", " print '...:', output_dir, base + self.obj_extension", " obj_names.append (os.path.join (output_dir,", " base + self.obj_extension))", " return obj_names", "", " # object_filenames ()", "", "", "def build_import_library():", " \"\"\" Build the import libraries for Mingw32-gcc on Windows", " \"\"\"", " if os.name != 'nt':", " return", " lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2])", " lib_file = os.path.join(sys.prefix,'libs',lib_name)", " if os.path.isfile(lib_file):", " log.info('Skip building import library \"%s\"' % (lib_file))", " return", " log.info('Building import library \"%s\"' % (lib_file))", "", " from scipy_distutils import lib2def", "", " def_name = \"python%d%d.def\" % tuple(sys.version_info[:2])", " 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'))", "", " out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])", " out_file = os.path.join(sys.prefix,'libs',out_name)", " dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])", " args = (dll_name,def_file,out_file)", " cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args", " success = not os.system(cmd)", " # for now, fail silently", " if not success:", " print 'WARNING: failed to build import library for gcc. Linking will fail.'", " #if not success:", " # msg = \"Couldn't find import library, and failed to build it.\"", " # raise DistutilsPlatformError, msg" ], "deleted": [] } }, { "old_path": "scipy_distutils/misc_util.py", "new_path": "scipy_distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -10,7 +10,7 @@\n # Hooks for colored terminal output.\n # See also http://www.livinglogic.de/Python/ansistyle\n def terminal_has_colors():\n- if sys.platform=='cygwin' and os.environ.has_key('NOCOLOR'):\n+ if sys.platform=='cygwin' and not os.environ.has_key('USE_COLOR'):\n # Avoid importing curses that causes illegal operation\n # with a message:\n # PYTHON2 caused an invalid page fault in\n", "added_lines": 1, "deleted_lines": 1, "source_code": "import os,sys,string\nimport re\nimport types\n\nif sys.version[:3]<='2.1':\n from distutils import util\n util_get_platform = util.get_platform\n util.get_platform = lambda : util_get_platform().replace(' ','_')\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if sys.platform=='cygwin' and not os.environ.has_key('USE_COLOR'):\n # Avoid importing curses that causes illegal operation\n # with a message:\n # PYTHON2 caused an invalid page fault in\n # module CYGNURSES7.DLL as 015f:18bbfc28\n # Details: Python 2.3.3 [GCC 3.3.1 (cygming special)]\n # ssh to Win32 machine from debian\n # curses.version is 2.2\n # CYGWIN_98-4.10, release 1.5.7(0.109/3/2))\n return 0\n if hasattr(sys.stdout,'isatty') and sys.stdout.isatty(): \n try:\n import curses\n curses.setupterm()\n if (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path is not None:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir']\n\ndef default_config_dict(name = None, parent_name = None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n test_path = os.path.join(local_path,'tests')\n if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n if os.path.exists(test_path):\n d['packages'].append(dot_join(full_name,'tests'))\n d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n name = d.get('name',None)\n if name is not None:\n result['name'] = name\n break\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ): #obsolete feature\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n\ndef get_environ_include_dirs(): #obsolete feature\n includes = []\n if os.environ.has_key('PYTHONINCLUDE'):\n includes = os.environ['PYTHONINCLUDE'].split(os.pathsep)\n return includes\n\ndef get_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\nclass SourceGenerator: #obsolete feature\n \"\"\" SourceGenerator\n func - creates target, arguments are (target,sources)+args\n sources - target source files\n args - extra arguments to func\n\n If func is None then target must exist and it is touched whenever\n sources are newer.\n \"\"\"\n def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target) and func is not None:\n g = sys._getframe(1).f_globals\n fn = g.get('__file__',g.get('__name__'))\n if fn=='__main__': fn = sys.argv[0]\n caller_dir = os.path.abspath(os.path.dirname(fn))\n prefix = os.path.commonprefix([caller_dir,os.getcwd()])\n target_dir = caller_dir[len(prefix)+1:]\n target = os.path.join(get_build_temp(),target_dir,target)\n self.func = func\n self.target = target\n self.sources = sources\n self.args = args\n def __str__(self):\n return str(self.target)\n def generate(self):\n from distutils import dep_util,dir_util\n if dep_util.newer_group(self.sources,self.target):\n print 'Running generate',self.target\n dir_util.mkpath(os.path.dirname(self.target),verbose=1)\n if self.func is None:\n # Touch target\n os.utime(self.target,None)\n else:\n self.func(self.target,self.sources,*self.args)\n assert os.path.exists(self.target),`self.target`\n return self.target\n def __call__(self, extension, src_dir):\n return self.generate()\n\nclass SourceFilter: #obsolete feature\n \"\"\" SourceFilter\n func - implements criteria to filter sources\n sources - source files\n args - extra arguments to func\n \"\"\"\n def __init__(self,func,sources,*args):\n self.func = func\n self.sources = sources\n self.args = args\n def filter(self):\n return self.func(self.sources,*self.args)\n def __call__(self, extension, src_dir):\n return self.filter()\n\n##\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return 1\n return 0\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return 1\n return 0\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source) \n return c_sources, cxx_sources, f_sources, fmodule_sources\n\nif __name__ == '__main__':\n print 'terminal_has_colors:',terminal_has_colors()\n print red_text(\"This is red text\")\n print yellow_text(\"This is yellow text\")\n", "source_code_before": "import os,sys,string\nimport re\nimport types\n\nif sys.version[:3]<='2.1':\n from distutils import util\n util_get_platform = util.get_platform\n util.get_platform = lambda : util_get_platform().replace(' ','_')\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if sys.platform=='cygwin' and os.environ.has_key('NOCOLOR'):\n # Avoid importing curses that causes illegal operation\n # with a message:\n # PYTHON2 caused an invalid page fault in\n # module CYGNURSES7.DLL as 015f:18bbfc28\n # Details: Python 2.3.3 [GCC 3.3.1 (cygming special)]\n # ssh to Win32 machine from debian\n # curses.version is 2.2\n # CYGWIN_98-4.10, release 1.5.7(0.109/3/2))\n return 0\n if hasattr(sys.stdout,'isatty') and sys.stdout.isatty(): \n try:\n import curses\n curses.setupterm()\n if (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path is not None:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir']\n\ndef default_config_dict(name = None, parent_name = None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n test_path = os.path.join(local_path,'tests')\n if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n if os.path.exists(test_path):\n d['packages'].append(dot_join(full_name,'tests'))\n d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n name = d.get('name',None)\n if name is not None:\n result['name'] = name\n break\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ): #obsolete feature\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n\ndef get_environ_include_dirs(): #obsolete feature\n includes = []\n if os.environ.has_key('PYTHONINCLUDE'):\n includes = os.environ['PYTHONINCLUDE'].split(os.pathsep)\n return includes\n\ndef get_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\nclass SourceGenerator: #obsolete feature\n \"\"\" SourceGenerator\n func - creates target, arguments are (target,sources)+args\n sources - target source files\n args - extra arguments to func\n\n If func is None then target must exist and it is touched whenever\n sources are newer.\n \"\"\"\n def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target) and func is not None:\n g = sys._getframe(1).f_globals\n fn = g.get('__file__',g.get('__name__'))\n if fn=='__main__': fn = sys.argv[0]\n caller_dir = os.path.abspath(os.path.dirname(fn))\n prefix = os.path.commonprefix([caller_dir,os.getcwd()])\n target_dir = caller_dir[len(prefix)+1:]\n target = os.path.join(get_build_temp(),target_dir,target)\n self.func = func\n self.target = target\n self.sources = sources\n self.args = args\n def __str__(self):\n return str(self.target)\n def generate(self):\n from distutils import dep_util,dir_util\n if dep_util.newer_group(self.sources,self.target):\n print 'Running generate',self.target\n dir_util.mkpath(os.path.dirname(self.target),verbose=1)\n if self.func is None:\n # Touch target\n os.utime(self.target,None)\n else:\n self.func(self.target,self.sources,*self.args)\n assert os.path.exists(self.target),`self.target`\n return self.target\n def __call__(self, extension, src_dir):\n return self.generate()\n\nclass SourceFilter: #obsolete feature\n \"\"\" SourceFilter\n func - implements criteria to filter sources\n sources - source files\n args - extra arguments to func\n \"\"\"\n def __init__(self,func,sources,*args):\n self.func = func\n self.sources = sources\n self.args = args\n def filter(self):\n return self.func(self.sources,*self.args)\n def __call__(self, extension, src_dir):\n return self.filter()\n\n##\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return 1\n return 0\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return 1\n return 0\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source) \n return c_sources, cxx_sources, f_sources, fmodule_sources\n\nif __name__ == '__main__':\n print 'terminal_has_colors:',terminal_has_colors()\n print red_text(\"This is red text\")\n print yellow_text(\"This is yellow text\")\n", "methods": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 18, "complexity": 13, "token_count": 137, "parameters": [], "start_line": 12, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 58, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 61, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 14, "complexity": 5, "token_count": 124, "parameters": [ "mod_name", "parent_path" ], "start_line": 64, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 89, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 94, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 97, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 113, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 125, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 144, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 184, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 13, "complexity": 6, "token_count": 89, "parameters": [ "config_list" ], "start_line": 193, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 207, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 214, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 217, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "get_environ_include_dirs", "long_name": "get_environ_include_dirs( )", "filename": "misc_util.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 234, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "get_build_temp", "long_name": "get_build_temp( )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [], "start_line": 240, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , func , target , sources = [ ] , * args )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 154, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 254, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 267, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate", "long_name": "generate( self )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 107, "parameters": [ "self" ], "start_line": 269, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , extension , src_dir )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "extension", "src_dir" ], "start_line": 281, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , func , sources , * args )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "func", "sources", "args" ], "start_line": 290, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "filter", "long_name": "filter( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 294, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , extension , src_dir )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "extension", "src_dir" ], "start_line": 296, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_f90_modules", "long_name": "get_f90_modules( source )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 77, "parameters": [ "source" ], "start_line": 306, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "has_f_sources", "long_name": "has_f_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 324, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 331, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "filter_sources", "long_name": "filter_sources( sources )", "filename": "misc_util.py", "nloc": 17, "complexity": 5, "token_count": 84, "parameters": [ "sources" ], "start_line": 338, "end_line": 358, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 } ], "methods_before": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 18, "complexity": 13, "token_count": 136, "parameters": [], "start_line": 12, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 58, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 61, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 14, "complexity": 5, "token_count": 124, "parameters": [ "mod_name", "parent_path" ], "start_line": 64, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 89, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 94, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 97, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 113, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 125, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 144, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 184, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 13, "complexity": 6, "token_count": 89, "parameters": [ "config_list" ], "start_line": 193, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 207, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 214, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 217, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "get_environ_include_dirs", "long_name": "get_environ_include_dirs( )", "filename": "misc_util.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 234, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "get_build_temp", "long_name": "get_build_temp( )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [], "start_line": 240, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , func , target , sources = [ ] , * args )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 154, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 254, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 267, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate", "long_name": "generate( self )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 107, "parameters": [ "self" ], "start_line": 269, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , extension , src_dir )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "extension", "src_dir" ], "start_line": 281, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , func , sources , * args )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "func", "sources", "args" ], "start_line": 290, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "filter", "long_name": "filter( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 294, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , extension , src_dir )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "extension", "src_dir" ], "start_line": 296, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_f90_modules", "long_name": "get_f90_modules( source )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 77, "parameters": [ "source" ], "start_line": 306, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "has_f_sources", "long_name": "has_f_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 324, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 331, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "filter_sources", "long_name": "filter_sources( sources )", "filename": "misc_util.py", "nloc": 17, "complexity": 5, "token_count": 84, "parameters": [ "sources" ], "start_line": 338, "end_line": 358, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 18, "complexity": 13, "token_count": 137, "parameters": [], "start_line": 12, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 } ], "nloc": 269, "complexity": 89, "token_count": 1977, "diff_parsed": { "added": [ " if sys.platform=='cygwin' and not os.environ.has_key('USE_COLOR'):" ], "deleted": [ " if sys.platform=='cygwin' and os.environ.has_key('NOCOLOR'):" ] } }, { "old_path": "scipy_distutils/system_info.py", "new_path": "scipy_distutils/system_info.py", "filename": "system_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -275,7 +275,7 @@ def get_info(self):\n \n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n- if os.environ.has_key(self.dir_env_var):\n+ if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n@@ -862,5 +862,3 @@ def show_all():\n \n if __name__ == \"__main__\":\n show_all()\n- print numpy_info().get_info()\n- print numarray_info().get_info()\n", "added_lines": 1, "deleted_lines": 3, "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n atlas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'atlas_threads':atlas_threads_info,\n 'lapack_atlas_threads':lapack_atlas_threads_info,\n 'lapack_atlas':lapack_atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n self.set_info(**info)\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32','cygwin']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n py_incl_dir = get_python_inc()\n include_dirs = [py_incl_dir]\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"%s\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n atlas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'atlas_threads':atlas_threads_info,\n 'lapack_atlas_threads':lapack_atlas_threads_info,\n 'lapack_atlas':lapack_atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n self.set_info(**info)\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32','cygwin']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n py_incl_dir = get_python_inc()\n include_dirs = [py_incl_dir]\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"%s\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n print numpy_info().get_info()\n print numarray_info().get_info()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 21, "complexity": 1, "token_count": 100, "parameters": [ "name" ], "start_line": 120, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 218, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 244, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 247, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 153, "parameters": [ "self" ], "start_line": 250, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 11, "complexity": 7, "token_count": 142, "parameters": [ "self", "section", "key" ], "start_line": 276, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 288, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 291, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 294, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 297, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 304, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 315, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 325, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 329, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 340, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 350, "end_line": 351, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 353, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 426, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 454, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 75, "complexity": 17, "token_count": 427, "parameters": [ "self" ], "start_line": 462, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 553, "end_line": 564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 570, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 577, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 668, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 685, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 692, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 732, "end_line": 735, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 116, "parameters": [ "self" ], "start_line": 737, "end_line": 756, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 762, "end_line": 772, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 774, "end_line": 802, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 817, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 843, "end_line": 851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 853, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 21, "complexity": 1, "token_count": 100, "parameters": [ "name" ], "start_line": 120, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 218, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 244, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 247, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 153, "parameters": [ "self" ], "start_line": 250, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 11, "complexity": 6, "token_count": 138, "parameters": [ "self", "section", "key" ], "start_line": 276, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 288, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 291, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 294, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 297, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 304, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 315, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 325, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 329, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 340, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 350, "end_line": 351, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 353, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 426, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 454, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 75, "complexity": 17, "token_count": 427, "parameters": [ "self" ], "start_line": 462, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 553, "end_line": 564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 570, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 577, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 668, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 685, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 692, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 732, "end_line": 735, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 116, "parameters": [ "self" ], "start_line": 737, "end_line": 756, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 762, "end_line": 772, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 774, "end_line": 802, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 817, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 843, "end_line": 851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 853, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 11, "complexity": 7, "token_count": 142, "parameters": [ "self", "section", "key" ], "start_line": 276, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "nloc": 753, "complexity": 150, "token_count": 3877, "diff_parsed": { "added": [ " if self.dir_env_var and os.environ.has_key(self.dir_env_var):" ], "deleted": [ " if os.environ.has_key(self.dir_env_var):", " print numpy_info().get_info()", " print numarray_info().get_info()" ] } } ] }, { "hash": "6425c5985e656d022d8d43684b737e93aab4f57d", "msg": "Scipy builds under cygwin with build_src branch.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-05T12:02:04+00:00", "author_timezone": 0, "committer_date": "2004-02-05T12:02:04+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "aa6fd3365a968a4c322dff8850466aabb96a1c53" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 9, "insertions": 29, "lines": 38, "files": 4, "dmm_unit_size": 0.2727272727272727, "dmm_unit_complexity": 0.2727272727272727, "dmm_unit_interfacing": 0.7272727272727273, "modified_files": [ { "old_path": "scipy_distutils/ccompiler.py", "new_path": "scipy_distutils/ccompiler.py", "filename": "ccompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -7,6 +7,7 @@\n from distutils import ccompiler\n \n import log\n+from exec_command import exec_command\n \n if sys.platform == 'win32':\n compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler',\n@@ -58,6 +59,7 @@ def new_compiler (plat=None,\n (\"can't compile C/C++ code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n print '*'*80\n- print module_name,klass\n+ print klass\n print '*'*80\n return klass(None, dry_run, force)\n+\n", "added_lines": 3, "deleted_lines": 1, "source_code": "\nimport re\nimport os\nimport sys\n\nfrom distutils.ccompiler import *\nfrom distutils import ccompiler\n\nimport log\nfrom exec_command import exec_command\n\nif sys.platform == 'win32':\n compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler',\n \"Mingw32 port of GNU C Compiler for Win32\"\\\n \"(for MSC built Python)\")\n if os.environ.get('OSTYPE','')=='msys':\n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n log.info('Setting mingw32 as default compiler for nt.')\n ccompiler._default_compilers = (('nt', 'mingw32'),) \\\n + ccompiler._default_compilers\n\n_distutils_new_compiler = new_compiler\ndef new_compiler (plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n # Try first C compilers from scipy_distutils.\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_compiler(plat)\n (module_name, class_name, long_description) = compiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile C/C++ code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler\" % compiler\n raise DistutilsPlatformError, msg\n\n module_name = \"scipy_distutils.\" + module_name\n try:\n __import__ (module_name)\n except ImportError, msg:\n print msg\n module_name = module_name[6:]\n try:\n __import__(module_name)\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile C/C++ code: unable to load module '%s'\" % \\\n module_name\n try:\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile C/C++ code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n print '*'*80\n print klass\n print '*'*80\n return klass(None, dry_run, force)\n\n", "source_code_before": "\nimport re\nimport os\nimport sys\n\nfrom distutils.ccompiler import *\nfrom distutils import ccompiler\n\nimport log\n\nif sys.platform == 'win32':\n compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler',\n \"Mingw32 port of GNU C Compiler for Win32\"\\\n \"(for MSC built Python)\")\n if os.environ.get('OSTYPE','')=='msys':\n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n log.info('Setting mingw32 as default compiler for nt.')\n ccompiler._default_compilers = (('nt', 'mingw32'),) \\\n + ccompiler._default_compilers\n\n_distutils_new_compiler = new_compiler\ndef new_compiler (plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n # Try first C compilers from scipy_distutils.\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_compiler(plat)\n (module_name, class_name, long_description) = compiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile C/C++ code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler\" % compiler\n raise DistutilsPlatformError, msg\n\n module_name = \"scipy_distutils.\" + module_name\n try:\n __import__ (module_name)\n except ImportError, msg:\n print msg\n module_name = module_name[6:]\n try:\n __import__(module_name)\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile C/C++ code: unable to load module '%s'\" % \\\n module_name\n try:\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile C/C++ code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n print '*'*80\n print module_name,klass\n print '*'*80\n return klass(None, dry_run, force)\n", "methods": [ { "name": "new_compiler", "long_name": "new_compiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "ccompiler.py", "nloc": 39, "complexity": 8, "token_count": 181, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 24, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 } ], "methods_before": [ { "name": "new_compiler", "long_name": "new_compiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "ccompiler.py", "nloc": 39, "complexity": 8, "token_count": 183, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 23, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "new_compiler", "long_name": "new_compiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "ccompiler.py", "nloc": 39, "complexity": 8, "token_count": 181, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 24, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 } ], "nloc": 55, "complexity": 8, "token_count": 265, "diff_parsed": { "added": [ "from exec_command import exec_command", " print klass", "" ], "deleted": [ " print module_name,klass" ] } }, { "old_path": "scipy_distutils/command/build_ext.py", "new_path": "scipy_distutils/command/build_ext.py", "filename": "build_ext.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -218,6 +218,8 @@ def build_extension(self, ext):\n old_linker_so_0 = self.compiler.linker_so[0]\n \n use_fortran_linker = 0\n+ c_libraries = []\n+ c_library_dirs = []\n if f_sources:\n use_fortran_linker = 1\n elif self.distribution.has_c_libraries(): \n@@ -226,6 +228,11 @@ def build_extension(self, ext):\n for (lib_name, build_info) in build_clib.libraries:\n if has_f_sources(build_info.get('sources',[])):\n f_libs.append(lib_name)\n+ if lib_name in ext.libraries:\n+ # XXX: how to determine if c_libraries contain\n+ # fortran compiled sources?\n+ c_libraries.extend(build_info.get('libraries',[]))\n+ c_library_dirs.extend(build_info.get('library_dirs',[]))\n for l in ext.libraries:\n if l in f_libs:\n use_fortran_linker = 1\n@@ -250,9 +257,10 @@ def build_extension(self, ext):\n kws = {'target_lang':language}\n else:\n kws = {}\n+\n link(objects, ext_filename,\n- libraries=self.get_libraries(ext),\n- library_dirs=ext.library_dirs,\n+ libraries=self.get_libraries(ext) + c_libraries,\n+ library_dirs=ext.library_dirs + c_library_dirs,\n runtime_library_dirs=ext.runtime_library_dirs,\n extra_postargs=extra_args,\n export_symbols=self.get_export_symbols(ext),\n", "added_lines": 10, "deleted_lines": 2, "source_code": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os\nimport string\nimport sys\nfrom glob import glob\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util, log\nfrom scipy_distutils.misc_util import filter_sources, has_f_sources, has_cxx_sources\n\nclass build_ext (old_build_ext):\n\n description = \"build C/C++/F extensions (compile/link to build directory)\"\n\n user_options = old_build_ext.user_options + [\n ('fcompiler=', None,\n \"specify the Fortran compiler type\"),\n ]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.fcompiler = None\n return\n\n def run(self):\n if not self.extensions:\n return\n\n if self.distribution.has_c_libraries():\n build_clib = self.get_finalized_command('build_clib')\n self.library_dirs.append(build_clib.build_clib)\n else:\n build_clib = None\n\n # Not including C libraries to the list of\n # extension libraries automatically to prevent\n # bogus linking commands. Extensions must\n # explicitly specify the C libraries that they use.\n\n save_mth = self.distribution.has_c_libraries\n self.distribution.has_c_libraries = self.distribution.return_false\n old_build_ext.run(self) # sets self.compiler\n self.distribution.has_c_libraries = save_mth\n \n # Determine if Fortran compiler is needed.\n if build_clib and build_clib.fcompiler is not None:\n need_f_compiler = 1\n else:\n need_f_compiler = 0\n for ext in self.extensions:\n if has_f_sources(ext.sources):\n need_f_compiler = 1\n break\n\n # Determine if C++ compiler is needed.\n need_cxx_compiler = 0\n for ext in self.extensions:\n if has_cxx_sources(ext.sources):\n need_cxx_compiler = 1\n break\n\n # Initialize Fortran/C++ compilers if needed.\n if need_f_compiler:\n from scipy_distutils.fcompiler import new_fcompiler\n self.fcompiler = new_fcompiler(compiler=self.fcompiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n self.fcompiler.customize(self.distribution)\n self.fcompiler.customize_cmd(self)\n if need_cxx_compiler:\n c = self.compiler\n if c.compiler[0].find('gcc')>=0:\n if sys.version[:3]>='2.3':\n if not c.compiler_cxx:\n c.compiler_cxx = [c.compiler[0].replace('gcc','g++')]\\\n + c.compiler[1:]\n else:\n c.compiler_cxx = [c.compiler[0].replace('gcc','g++')]\\\n + c.compiler[1:]\n else:\n print 'XXX: Fix compiler_cxx for',c.__class__.__name__\n\n # Build extensions\n self.build_extensions2()\n return\n\n def build_extensions(self):\n # Hold on building extensions in old_build_ext.run()\n # until Fortran/C++ compilers are set. Building will be\n # carried out in build_extensions2()\n return\n\n def build_extensions2(self):\n old_build_ext.build_extensions(self)\n return\n\n def swig_sources(self, sources):\n # Do nothing. Swig sources have beed handled in build_src command.\n return sources\n\n def build_extension(self, ext):\n sources = ext.sources\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'ext_modules' option (extension '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % ext.name\n sources = list(sources)\n\n fullname = self.get_ext_fullname(ext.name)\n if self.inplace:\n modpath = string.split(fullname, '.')\n package = string.join(modpath[0:-1], '.')\n base = modpath[-1]\n\n build_py = self.get_finalized_command('build_py')\n package_dir = build_py.get_package_dir(package)\n ext_filename = os.path.join(package_dir,\n self.get_ext_filename(base))\n else:\n ext_filename = os.path.join(self.build_lib,\n self.get_ext_filename(fullname))\n depends = sources + ext.depends\n\n if not (self.force or newer_group(depends, ext_filename, 'newer')):\n log.debug(\"skipping '%s' extension (up-to-date)\", ext.name)\n return\n else:\n log.info(\"building '%s' extension\", ext.name)\n\n extra_args = ext.extra_compile_args or []\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n c_sources, cxx_sources, f_sources, fmodule_sources = filter_sources(ext.sources)\n\n if sys.version[:3]>='2.3':\n kws = {'depends':ext.depends}\n else:\n kws = {}\n\n c_objects = self.compiler.compile(c_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=ext.include_dirs,\n debug=self.debug,\n extra_postargs=extra_args,\n **kws)\n if cxx_sources:\n old_compiler = self.compiler.compiler_so[0]\n self.compiler.compiler_so[0] = self.compiler.compiler_cxx[0]\n c_objects += self.compiler.compile(cxx_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=ext.include_dirs,\n debug=self.debug,\n extra_postargs=extra_args,\n **kws)\n self.compiler.compiler_so[0] = old_compiler\n\n check_for_f90_modules = not not fmodule_sources\n\n if f_sources or fmodule_sources:\n extra_postargs = []\n include_dirs = ext.include_dirs[:]\n module_dirs = [] # XXX Figure out how users could change this?\n\n if check_for_f90_modules:\n module_build_dir = os.path.join(\\\n self.build_temp,os.path.dirname(\\\n self.get_ext_filename(fullname)))\n\n self.mkpath(module_build_dir)\n if self.fcompiler.module_dir_switch is None:\n existing_modules = glob('*.mod')\n extra_postargs += self.fcompiler.module_options(\\\n module_dirs,module_build_dir)\n\n f_objects = self.fcompiler.compile(fmodule_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs,\n depends=ext.depends)\n\n if check_for_f90_modules \\\n and self.fcompiler.module_dir_switch is None:\n for f in glob('*.mod'):\n if f in existing_modules:\n continue\n self.move_file(f, module_build_dir)\n\n f_objects += self.fcompiler.compile(f_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs,\n depends=ext.depends)\n else:\n f_objects = []\n\n objects = c_objects + f_objects\n\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n old_linker_so_0 = self.compiler.linker_so[0]\n\n use_fortran_linker = 0\n c_libraries = []\n c_library_dirs = []\n if f_sources:\n use_fortran_linker = 1\n elif self.distribution.has_c_libraries(): \n build_clib = self.get_finalized_command('build_clib')\n f_libs = []\n for (lib_name, build_info) in build_clib.libraries:\n if has_f_sources(build_info.get('sources',[])):\n f_libs.append(lib_name)\n if lib_name in ext.libraries:\n # XXX: how to determine if c_libraries contain\n # fortran compiled sources?\n c_libraries.extend(build_info.get('libraries',[]))\n c_library_dirs.extend(build_info.get('library_dirs',[]))\n for l in ext.libraries:\n if l in f_libs:\n use_fortran_linker = 1\n break\n\n if use_fortran_linker:\n if cxx_sources:\n # XXX: Which linker should be used, Fortran or C++?\n log.warn('mixing Fortran and C++ is untested')\n link = self.fcompiler.link_shared_object\n language = ext.language or self.fcompiler.detect_language(f_sources)\n else:\n link = self.compiler.link_shared_object\n if sys.version[:3]>='2.3':\n language = ext.language or self.compiler.detect_language(sources)\n else:\n language = ext.language\n if cxx_sources:\n self.compiler.linker_so[0] = self.compiler.compiler_cxx[0]\n\n if sys.version[:3]>='2.3':\n kws = {'target_lang':language}\n else:\n kws = {}\n\n link(objects, ext_filename,\n libraries=self.get_libraries(ext) + c_libraries,\n library_dirs=ext.library_dirs + c_library_dirs,\n runtime_library_dirs=ext.runtime_library_dirs,\n extra_postargs=extra_args,\n export_symbols=self.get_export_symbols(ext),\n debug=self.debug,\n build_temp=self.build_temp,**kws)\n\n self.compiler.linker_so[0] = old_linker_so_0\n return\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n def visit_func(filenames,dirname,names):\n if os.path.basename(dirname)=='CVS':\n return\n for name in names:\n fullname = os.path.join(dirname,name)\n if os.path.isfile(fullname):\n filenames.append(fullname)\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n sources = filter(lambda s:type(s) is StringType,ext.sources)\n filenames.extend(sources)\n filenames.extend(get_headers(get_directories(sources)))\n for d in ext.depends:\n if is_local_src_dir(d):\n os.path.walk(d,visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return 0\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os\nimport string\nimport sys\nfrom glob import glob\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util, log\nfrom scipy_distutils.misc_util import filter_sources, has_f_sources, has_cxx_sources\n\nclass build_ext (old_build_ext):\n\n description = \"build C/C++/F extensions (compile/link to build directory)\"\n\n user_options = old_build_ext.user_options + [\n ('fcompiler=', None,\n \"specify the Fortran compiler type\"),\n ]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.fcompiler = None\n return\n\n def run(self):\n if not self.extensions:\n return\n\n if self.distribution.has_c_libraries():\n build_clib = self.get_finalized_command('build_clib')\n self.library_dirs.append(build_clib.build_clib)\n else:\n build_clib = None\n\n # Not including C libraries to the list of\n # extension libraries automatically to prevent\n # bogus linking commands. Extensions must\n # explicitly specify the C libraries that they use.\n\n save_mth = self.distribution.has_c_libraries\n self.distribution.has_c_libraries = self.distribution.return_false\n old_build_ext.run(self) # sets self.compiler\n self.distribution.has_c_libraries = save_mth\n \n # Determine if Fortran compiler is needed.\n if build_clib and build_clib.fcompiler is not None:\n need_f_compiler = 1\n else:\n need_f_compiler = 0\n for ext in self.extensions:\n if has_f_sources(ext.sources):\n need_f_compiler = 1\n break\n\n # Determine if C++ compiler is needed.\n need_cxx_compiler = 0\n for ext in self.extensions:\n if has_cxx_sources(ext.sources):\n need_cxx_compiler = 1\n break\n\n # Initialize Fortran/C++ compilers if needed.\n if need_f_compiler:\n from scipy_distutils.fcompiler import new_fcompiler\n self.fcompiler = new_fcompiler(compiler=self.fcompiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n self.fcompiler.customize(self.distribution)\n self.fcompiler.customize_cmd(self)\n if need_cxx_compiler:\n c = self.compiler\n if c.compiler[0].find('gcc')>=0:\n if sys.version[:3]>='2.3':\n if not c.compiler_cxx:\n c.compiler_cxx = [c.compiler[0].replace('gcc','g++')]\\\n + c.compiler[1:]\n else:\n c.compiler_cxx = [c.compiler[0].replace('gcc','g++')]\\\n + c.compiler[1:]\n else:\n print 'XXX: Fix compiler_cxx for',c.__class__.__name__\n\n # Build extensions\n self.build_extensions2()\n return\n\n def build_extensions(self):\n # Hold on building extensions in old_build_ext.run()\n # until Fortran/C++ compilers are set. Building will be\n # carried out in build_extensions2()\n return\n\n def build_extensions2(self):\n old_build_ext.build_extensions(self)\n return\n\n def swig_sources(self, sources):\n # Do nothing. Swig sources have beed handled in build_src command.\n return sources\n\n def build_extension(self, ext):\n sources = ext.sources\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'ext_modules' option (extension '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % ext.name\n sources = list(sources)\n\n fullname = self.get_ext_fullname(ext.name)\n if self.inplace:\n modpath = string.split(fullname, '.')\n package = string.join(modpath[0:-1], '.')\n base = modpath[-1]\n\n build_py = self.get_finalized_command('build_py')\n package_dir = build_py.get_package_dir(package)\n ext_filename = os.path.join(package_dir,\n self.get_ext_filename(base))\n else:\n ext_filename = os.path.join(self.build_lib,\n self.get_ext_filename(fullname))\n depends = sources + ext.depends\n\n if not (self.force or newer_group(depends, ext_filename, 'newer')):\n log.debug(\"skipping '%s' extension (up-to-date)\", ext.name)\n return\n else:\n log.info(\"building '%s' extension\", ext.name)\n\n extra_args = ext.extra_compile_args or []\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n c_sources, cxx_sources, f_sources, fmodule_sources = filter_sources(ext.sources)\n\n if sys.version[:3]>='2.3':\n kws = {'depends':ext.depends}\n else:\n kws = {}\n\n c_objects = self.compiler.compile(c_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=ext.include_dirs,\n debug=self.debug,\n extra_postargs=extra_args,\n **kws)\n if cxx_sources:\n old_compiler = self.compiler.compiler_so[0]\n self.compiler.compiler_so[0] = self.compiler.compiler_cxx[0]\n c_objects += self.compiler.compile(cxx_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=ext.include_dirs,\n debug=self.debug,\n extra_postargs=extra_args,\n **kws)\n self.compiler.compiler_so[0] = old_compiler\n\n check_for_f90_modules = not not fmodule_sources\n\n if f_sources or fmodule_sources:\n extra_postargs = []\n include_dirs = ext.include_dirs[:]\n module_dirs = [] # XXX Figure out how users could change this?\n\n if check_for_f90_modules:\n module_build_dir = os.path.join(\\\n self.build_temp,os.path.dirname(\\\n self.get_ext_filename(fullname)))\n\n self.mkpath(module_build_dir)\n if self.fcompiler.module_dir_switch is None:\n existing_modules = glob('*.mod')\n extra_postargs += self.fcompiler.module_options(\\\n module_dirs,module_build_dir)\n\n f_objects = self.fcompiler.compile(fmodule_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs,\n depends=ext.depends)\n\n if check_for_f90_modules \\\n and self.fcompiler.module_dir_switch is None:\n for f in glob('*.mod'):\n if f in existing_modules:\n continue\n self.move_file(f, module_build_dir)\n\n f_objects += self.fcompiler.compile(f_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs,\n depends=ext.depends)\n else:\n f_objects = []\n\n objects = c_objects + f_objects\n\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n old_linker_so_0 = self.compiler.linker_so[0]\n\n use_fortran_linker = 0\n if f_sources:\n use_fortran_linker = 1\n elif self.distribution.has_c_libraries(): \n build_clib = self.get_finalized_command('build_clib')\n f_libs = []\n for (lib_name, build_info) in build_clib.libraries:\n if has_f_sources(build_info.get('sources',[])):\n f_libs.append(lib_name)\n for l in ext.libraries:\n if l in f_libs:\n use_fortran_linker = 1\n break\n\n if use_fortran_linker:\n if cxx_sources:\n # XXX: Which linker should be used, Fortran or C++?\n log.warn('mixing Fortran and C++ is untested')\n link = self.fcompiler.link_shared_object\n language = ext.language or self.fcompiler.detect_language(f_sources)\n else:\n link = self.compiler.link_shared_object\n if sys.version[:3]>='2.3':\n language = ext.language or self.compiler.detect_language(sources)\n else:\n language = ext.language\n if cxx_sources:\n self.compiler.linker_so[0] = self.compiler.compiler_cxx[0]\n\n if sys.version[:3]>='2.3':\n kws = {'target_lang':language}\n else:\n kws = {}\n link(objects, ext_filename,\n libraries=self.get_libraries(ext),\n library_dirs=ext.library_dirs,\n runtime_library_dirs=ext.runtime_library_dirs,\n extra_postargs=extra_args,\n export_symbols=self.get_export_symbols(ext),\n debug=self.debug,\n build_temp=self.build_temp,**kws)\n\n self.compiler.linker_so[0] = old_linker_so_0\n return\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n def visit_func(filenames,dirname,names):\n if os.path.basename(dirname)=='CVS':\n return\n for name in names:\n fullname = os.path.join(dirname,name)\n if os.path.isfile(fullname):\n filenames.append(fullname)\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n sources = filter(lambda s:type(s) is StringType,ext.sources)\n filenames.extend(sources)\n filenames.extend(get_headers(get_directories(sources)))\n for d in ext.depends:\n if is_local_src_dir(d):\n os.path.walk(d,visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return 0\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_ext.py", "nloc": 47, "complexity": 14, "token_count": 305, "parameters": [ "self" ], "start_line": 31, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 1 }, { "name": "build_extensions", "long_name": "build_extensions( self )", "filename": "build_ext.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 94, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_extensions2", "long_name": "build_extensions2( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "swig_sources", "long_name": "swig_sources( self , sources )", "filename": "build_ext.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "sources" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 139, "complexity": 34, "token_count": 944, "parameters": [ "self", "ext" ], "start_line": 108, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 164, "top_nesting_level": 1 }, { "name": "get_source_files.visit_func", "long_name": "get_source_files.visit_func( filenames , dirname , names )", "filename": "build_ext.py", "nloc": 7, "complexity": 4, "token_count": 55, "parameters": [ "filenames", "dirname", "names" ], "start_line": 276, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 14, "complexity": 5, "token_count": 105, "parameters": [ "self" ], "start_line": 273, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "is_local_src_dir", "long_name": "is_local_src_dir( directory )", "filename": "build_ext.py", "nloc": 10, "complexity": 5, "token_count": 98, "parameters": [ "directory" ], "start_line": 295, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_ext.py", "nloc": 47, "complexity": 14, "token_count": 305, "parameters": [ "self" ], "start_line": 31, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 1 }, { "name": "build_extensions", "long_name": "build_extensions( self )", "filename": "build_ext.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 94, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_extensions2", "long_name": "build_extensions2( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "swig_sources", "long_name": "swig_sources( self , sources )", "filename": "build_ext.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "sources" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 134, "complexity": 33, "token_count": 897, "parameters": [ "self", "ext" ], "start_line": 108, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 156, "top_nesting_level": 1 }, { "name": "get_source_files.visit_func", "long_name": "get_source_files.visit_func( filenames , dirname , names )", "filename": "build_ext.py", "nloc": 7, "complexity": 4, "token_count": 55, "parameters": [ "filenames", "dirname", "names" ], "start_line": 268, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 14, "complexity": 5, "token_count": 105, "parameters": [ "self" ], "start_line": 265, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "is_local_src_dir", "long_name": "is_local_src_dir( directory )", "filename": "build_ext.py", "nloc": 10, "complexity": 5, "token_count": 98, "parameters": [ "directory" ], "start_line": 287, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 139, "complexity": 34, "token_count": 944, "parameters": [ "self", "ext" ], "start_line": 108, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 164, "top_nesting_level": 1 } ], "nloc": 245, "complexity": 66, "token_count": 1642, "diff_parsed": { "added": [ " c_libraries = []", " c_library_dirs = []", " if lib_name in ext.libraries:", " # XXX: how to determine if c_libraries contain", " # fortran compiled sources?", " c_libraries.extend(build_info.get('libraries',[]))", " c_library_dirs.extend(build_info.get('library_dirs',[]))", "", " libraries=self.get_libraries(ext) + c_libraries,", " library_dirs=ext.library_dirs + c_library_dirs," ], "deleted": [ " libraries=self.get_libraries(ext),", " library_dirs=ext.library_dirs," ] } }, { "old_path": "scipy_distutils/fcompiler.py", "new_path": "scipy_distutils/fcompiler.py", "filename": "fcompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -13,7 +13,7 @@\n from glob import glob\n \n from distutils.version import StrictVersion\n-from distutils.ccompiler import CCompiler, gen_lib_options\n+from scipy_distutils.ccompiler import CCompiler, gen_lib_options\n # distutils.ccompiler provides the following functions:\n # gen_preprocess_options(macros, include_dirs)\n # gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)\n@@ -460,6 +460,11 @@ def exec_command(self,*args,**kws):\n log.info('*****status:%s\\n*****output:\\n%s\\n*****' % (status,output))\n return status, output\n \n+ def spawn(self, cmd):\n+ s,o = self.exec_command(cmd)\n+ assert not s,`s`\n+\n+\n ###################\n \n def _get_cc_args(self, pp_opts, debug, before):\n@@ -735,7 +740,9 @@ def new_fcompiler(plat=None,\n raise DistutilsModuleError, \\\n (\"can't compile Fortran code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n-\n+ print '*'*80\n+ print klass\n+ print '*'*80\n return klass(None, dry_run, force)\n \n \n", "added_lines": 9, "deleted_lines": 2, "source_code": "\"\"\"scipy_distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the Scipy_istutils Fortran compiler abstraction model.\n\n\"\"\"\n\nimport re\nimport os\nimport sys\nimport atexit\nfrom types import StringType, NoneType, ListType, TupleType\nfrom glob import glob\n\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import CCompiler, gen_lib_options\n# distutils.ccompiler provides the following functions:\n# gen_preprocess_options(macros, include_dirs)\n# gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.core import Command\nfrom distutils.util import split_quoted\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.version import LooseVersion\nfrom distutils.sysconfig import get_config_var\n\nfrom scipy_distutils.command.config_compiler import config_fc\n\nimport log\nfrom exec_command import find_executable, exec_command\n\n\nclass FCompiler(CCompiler):\n \"\"\" Abstract base class to define the interface that must be implemented\n by real Fortran compiler classes.\n\n Methods that subclasses may redefine:\n\n get_version_cmd(), get_linker_so(), get_version()\n get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()\n get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),\n get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),\n get_flags_arch_f90(), get_flags_debug_f90(),\n get_flags_fix(), get_flags_linker_so(), get_flags_version()\n\n DON'T call these methods (except get_version) after\n constructing a compiler instance or inside any other method.\n All methods, except get_version_cmd() and get_flags_version(), may\n call get_version() method.\n\n After constructing a compiler instance, always call customize(dist=None)\n method that finalizes compiler construction and makes the following\n attributes available:\n compiler_f77\n compiler_f90\n compiler_fix\n linker_so\n archiver\n ranlib\n libraries\n library_dirs\n \"\"\"\n # CCompiler defines the following attributes:\n # compiler_type\n # src_extensions\n # obj_extension\n # static_lib_extension\n # shared_lib_extension\n # static_lib_format\n # shared_lib_format\n # exe_extension\n # language_map ### REDEFINED\n # language_order ### REDEFINED\n # and the following public methods:\n # set_executables(**args)\n # set_executable(key,value)\n # define_macro(name, value=None)\n # undefine_macro(name)\n # add_include_dir(dir)\n # set_include_dirs(dirs)\n # add_library(libname)\n # set_libraries(libnames)\n # add_library_dir(dir)\n # set_library_dirs(dirs)\n # add_runtime_library_dir(dir)\n # set_runtime_library_dirs(dirs)\n # add_link_object(object)\n # set_link_objects(objects)\n #\n # detect_language(sources) ### USABLE\n #\n # preprocess(source,output_file=None,macros=None,include_dirs=None,\n # extra_preargs=None,extra_postargs=None)\n # compile(sources, output_dir=None, macros=None,\n # include_dirs=None, debug=0, extra_preargs=None,\n # extra_postargs=None, depends=None)\n # create_static_lib(objects,output_libname,output_dir=None,debug=0,target_lang=None):\n # link(target_desc, objects, output_filename, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None,\n # build_temp=None, target_lang=None)\n # link_shared_lib(objects, output_libname, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None,\n # extra_postargs=None, build_temp=None, target_lang=None)\n # link_shared_object(objects,output_filename,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # export_symbols=None,debug=0,extra_preargs=None,\n # extra_postargs=None,build_temp=None,target_lang=None)\n # link_executable(objects,output_progname,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # debug=0,extra_preargs=None,extra_postargs=None,target_lang=None)\n #\n # library_dir_option(dir)\n # runtime_library_dir_option(dir)\n # library_option(lib)\n # has_function(funcname,includes=None,include_dirs=None,\n # libraries=None,library_dirs=None)\n # find_library_file(dirs, lib, debug=0)\n #\n # object_filenames(source_filenames, strip_dir=0, output_dir='')\n # shared_object_filename(basename, strip_dir=0, output_dir='')\n # executable_filenamee(basename, strip_dir=0, output_dir='')\n # library_filename(libname, lib_type='static',strip_dir=0, output_dir=''):\n #\n # announce(msg, level=1)\n # debug_print(msg)\n # warn(msg)\n # execute(func, args, msg=None, level=1)\n # spawn(cmd)\n # move_file(src,dst)\n # mkpath(name, mode=0777)\n #\n\n language_map = {'.f':'f77',\n '.for':'f77',\n '.ftn':'f77',\n '.f77':'f77',\n '.f90':'f90',\n '.f95':'f90'}\n language_order = ['f90','f77']\n\n version_pattern = None\n\n executables = {\n 'version_cmd' : [\"f77\",\"-v\"],\n 'compiler_f77' : [\"f77\"],\n 'compiler_f90' : [\"f90\"],\n 'compiler_fix' : [\"f90\",\"-fixed\"],\n 'linker_so' : [\"f90\",\"-shared\"],\n #'linker_exe' : [\"f90\"], # XXX do we need it??\n 'archiver' : [\"ar\",\"-cr\"],\n 'ranlib' : None,\n }\n\n compile_switch = \"-c\"\n object_switch = \"-o \" # Ending space matters! It will be stripped\n # but if it is missing then object_switch\n # will be prefixed to object file name by\n # string concatenation.\n library_switch = \"-o \" # Ditto!\n\n # Switch to specify where module files are created and searched\n # for USE statement. Normally it is a string and also here ending\n # space matters. See above.\n module_dir_switch = None\n\n # Switch to specify where module files are searched for USE statement.\n module_include_switch = '-I' \n\n pic_flags = [] # Flags to create position-independent code\n\n src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95']\n obj_extension = \".o\"\n shared_lib_extension = get_config_var('SO') # or .dll\n static_lib_extension = \".a\" # or .lib\n static_lib_format = \"lib%s%s\" # or %s%s\n shared_lib_format = \"%s%s\"\n exe_extension = \"\"\n\n ######################################################################\n ## Methods that subclasses may redefine. But don't call these methods!\n ## They are private to FCompiler class and may return unexpected\n ## results if used elsewhere. So, you have been warned..\n\n def get_version_cmd(self):\n \"\"\" Compiler command to print out version information. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n cmd = self.executables['version_cmd']\n if cmd is not None:\n cmd = cmd[0]\n if cmd==f77:\n cmd = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if cmd==f90:\n cmd = self.compiler_f90[0]\n return cmd\n\n def get_linker_so(self):\n \"\"\" Linker command to build shared libraries. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n ln = self.executables['linker_so']\n if ln is not None:\n ln = ln[0]\n if ln==f77:\n ln = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if ln==f90:\n ln = self.compiler_f90[0]\n return ln\n\n def get_flags(self):\n \"\"\" List of flags common to all compiler types. \"\"\"\n return [] + self.pic_flags\n def get_flags_version(self):\n \"\"\" List of compiler flags to print out version information. \"\"\"\n if self.executables['version_cmd']:\n return self.executables['version_cmd'][1:]\n return []\n def get_flags_f77(self):\n \"\"\" List of Fortran 77 specific flags. \"\"\"\n if self.executables['compiler_f77']:\n return self.executables['compiler_f77'][1:]\n return []\n def get_flags_f90(self):\n \"\"\" List of Fortran 90 specific flags. \"\"\"\n if self.executables['compiler_f90']:\n return self.executables['compiler_f90'][1:]\n return []\n def get_flags_fix(self):\n \"\"\" List of Fortran 90 fixed format specific flags. \"\"\"\n if self.executables['compiler_fix']:\n return self.executables['compiler_fix'][1:]\n return []\n def get_flags_linker_so(self):\n \"\"\" List of linker flags to build a shared library. \"\"\"\n if self.executables['linker_so']:\n return self.executables['linker_so'][1:]\n return []\n def get_flags_ar(self):\n \"\"\" List of archiver flags. \"\"\"\n if self.executables['archiver']:\n return self.executables['archiver'][1:]\n return []\n def get_flags_opt(self):\n \"\"\" List of architecture independent compiler flags. \"\"\"\n return []\n def get_flags_arch(self):\n \"\"\" List of architecture dependent compiler flags. \"\"\"\n return []\n def get_flags_debug(self):\n \"\"\" List of compiler flags to compile with debugging information. \"\"\"\n return []\n get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt\n get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch\n get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug\n\n def get_libraries(self):\n \"\"\" List of compiler libraries. \"\"\"\n return self.libraries[:]\n def get_library_dirs(self):\n \"\"\" List of compiler library directories. \"\"\"\n return self.library_dirs[:]\n\n def get_version(self, force=0, ok_status=[0]):\n \"\"\" Compiler version. Returns None if compiler is not available. \"\"\"\n if not force and hasattr(self,'version'):\n return self.version\n\n cmd = ' '.join(self.version_cmd)\n status, output = self.exec_command(cmd,use_tee=0)\n version = None\n if status in ok_status:\n m = re.match(self.version_pattern,output)\n if m:\n version = m.group('version')\n assert version,`version`\n version = LooseVersion(version)\n self.version = version\n return version\n\n ############################################################\n\n ## Public methods:\n\n def customize(self, dist=None):\n \"\"\" Customize Fortran compiler.\n\n This method gets Fortran compiler specific information from\n (i) class definition, (ii) environment, (iii) distutils config\n files, and (iv) command line.\n\n This method should be always called after constructing a\n compiler instance. But not in __init__ because Distribution\n instance is needed for (iii) and (iv).\n \"\"\"\n if dist is None:\n # These hooks are for testing only!\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n conf = dist.get_option_dict('config_fc')\n\n noopt = conf.get('noopt',[None,0])[1]\n noarch = conf.get('noarch',[None,noopt])[1]\n debug = conf.get('debug',[None,0])[1]\n\n f77 = self.__get_cmd('compiler_f77','F77',(conf,'f77exec'))\n f90 = self.__get_cmd('compiler_f90','F90',(conf,'f90exec'))\n # Temporarily setting f77,f90 compilers so that\n # version_cmd can use their executables.\n if f77:\n self.set_executables(compiler_f77=[f77])\n if f90:\n self.set_executables(compiler_f90=[f90])\n\n # Must set version_cmd before others as self.get_flags*\n # methods may call self.get_version.\n vers_cmd = self.__get_cmd(self.get_version_cmd)\n if vers_cmd:\n vflags = self.__get_flags(self.get_flags_version)\n self.set_executables(version_cmd=[vers_cmd]+vflags)\n\n if f77:\n f77flags = self.__get_flags(self.get_flags_f77,'F77FLAGS',\n (conf,'f77flags'))\n if f90:\n f90flags = self.__get_flags(self.get_flags_f90,'F90FLAGS',\n (conf,'f90flags'))\n\n # XXX Assuming that free format is default for f90 compiler.\n fix = self.__get_cmd('compiler_fix','F90',(conf,'f90exec'))\n if fix:\n fixflags = self.__get_flags(self.get_flags_fix) + f90flags\n\n oflags,aflags,dflags = [],[],[]\n if not noopt:\n oflags = self.__get_flags(self.get_flags_opt,'FOPT',(conf,'opt'))\n if f77 and self.get_flags_opt is not self.get_flags_opt_f77:\n f77flags += self.__get_flags(self.get_flags_opt_f77)\n if f90 and self.get_flags_opt is not self.get_flags_opt_f90:\n f90flags += self.__get_flags(self.get_flags_opt_f90)\n if fix and self.get_flags_opt is not self.get_flags_opt_f90:\n fixflags += self.__get_flags(self.get_flags_opt_f90)\n if not noarch:\n aflags = self.__get_flags(self.get_flags_arch,'FARCH',\n (conf,'arch'))\n if f77 and self.get_flags_arch is not self.get_flags_arch_f77:\n f77flags += self.__get_flags(self.get_flags_arch_f77)\n if f90 and self.get_flags_arch is not self.get_flags_arch_f90:\n f90flags += self.__get_flags(self.get_flags_arch_f90)\n if fix and self.get_flags_arch is not self.get_flags_arch_f90:\n fixflags += self.__get_flags(self.get_flags_arch_f90)\n if debug:\n dflags = self.__get_flags(self.get_flags_debug,'FDEBUG')\n if f77 and self.get_flags_debug is not self.get_flags_debug_f77:\n f77flags += self.__get_flags(self.get_flags_debug_f77)\n if f90 and self.get_flags_debug is not self.get_flags_debug_f90:\n f90flags += self.__get_flags(self.get_flags_debug_f90)\n if fix and self.get_flags_debug is not self.get_flags_debug_f90:\n fixflags += self.__get_flags(self.get_flags_debug_f90)\n\n fflags = self.__get_flags(self.get_flags,'FFLAGS') \\\n + dflags + oflags + aflags\n\n if f77:\n self.set_executables(compiler_f77=[f77]+f77flags+fflags)\n if f90:\n self.set_executables(compiler_f90=[f90]+f90flags+fflags)\n if fix:\n self.set_executables(compiler_fix=[fix]+fixflags+fflags)\n\n #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS\n linker_so = self.__get_cmd(self.get_linker_so,'LDSHARED')\n if linker_so:\n linker_so_flags = self.__get_flags(self.get_flags_linker_so,'LDFLAGS')\n self.set_executables(linker_so=[linker_so]+linker_so_flags)\n\n ar = self.__get_cmd('archiver','AR')\n if ar:\n arflags = self.__get_flags(self.get_flags_ar,'ARFLAGS')\n self.set_executables(archiver=[ar]+arflags)\n\n ranlib = self.__get_cmd('ranlib','RANLIB')\n if ranlib:\n self.set_executables(ranlib=[ranlib])\n\n self.set_library_dirs(self.get_library_dirs())\n self.set_libraries(self.get_libraries())\n\n verbose = conf.get('verbose',[None,0])[1]\n if verbose:\n self.dump_properties()\n return\n\n def customize_cmd(self, cmd):\n if cmd.include_dirs is not None:\n self.set_include_dirs(cmd.include_dirs)\n if cmd.define is not None:\n for (name,value) in cmd.define:\n self.define_macro(name, value)\n if cmd.undef is not None:\n for macro in cmd.undef:\n self.undefine_macro(macro)\n if cmd.libraries is not None:\n self.set_libraries(self.get_libraries() + cmd.libraries)\n if cmd.library_dirs is not None:\n self.set_library_dirs(self.get_library_dirs() + cmd.library_dirs)\n if cmd.rpath is not None:\n self.set_runtime_library_dirs(cmd.rpath)\n if cmd.link_objects is not None:\n self.set_link_objects(cmd.link_objects)\n return\n \n def dump_properties(self):\n \"\"\" Print out the attributes of a compiler instance. \"\"\"\n props = []\n for key in self.executables.keys() + \\\n ['version','libraries','library_dirs',\n 'object_switch','compile_switch']:\n if hasattr(self,key):\n v = getattr(self,key)\n props.append((key, None, '= '+`v`))\n props.sort()\n\n pretty_printer = FancyGetopt(props)\n for l in pretty_printer.generate_help(\"%s instance properties:\" \\\n % (self.__class__.__name__)):\n if l[:4]==' --':\n l = ' ' + l[4:]\n print l\n return\n\n def exec_command(self,*args,**kws):\n \"\"\" Return status,output of a command. \"\"\"\n quiet = kws.get('quiet',1)\n try: del kws['quiet']\n except KeyError: pass\n if not quiet:\n log.info('%s.exec_command(*%s,**%s)' % (self.__class__.__name__,\n args,kws))\n status, output = exec_command(*args,**kws)\n if not quiet:\n log.info('*****status:%s\\n*****output:\\n%s\\n*****' % (status,output))\n return status, output\n\n def spawn(self, cmd):\n s,o = self.exec_command(cmd)\n assert not s,`s`\n\n\n ###################\n\n def _get_cc_args(self, pp_opts, debug, before):\n #XXX\n print self.__class__.__name__ + '._get_cc_args:',pp_opts, debug, before\n return []\n\n def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):\n \"\"\"Compile 'src' to product 'obj'.\"\"\"\n print self.__class__.__name__ + '._compile:',obj, src, ext, cc_args, extra_postargs, pp_opts\n\n if is_f_file(src):\n compiler = self.compiler_f77\n elif is_free_format(src):\n compiler = self.compiler_f90\n if compiler is None:\n raise DistutilsExecError, 'f90 not supported by '\\\n +self.__class__.__name__\n else:\n compiler = self.compiler_fix\n if compiler is None:\n raise DistutilsExecError, 'f90 (fixed) not supported by '\\\n +self.__class__.__name__\n if self.object_switch[-1]==' ':\n o_args = [self.object_switch.strip(),obj]\n else:\n o_args = [self.object_switch.strip()+obj]\n\n assert self.compile_switch.strip()\n s_args = [self.compile_switch, src]\n\n command = compiler + cc_args + pp_opts + s_args + o_args + extra_postargs\n log.info(' '.join(command))\n try:\n s,o = self.exec_command(command)\n except DistutilsExecError, msg:\n raise CompileError, msg\n if s:\n raise CompileError, o\n\n return\n\n def module_options(self, module_dirs, module_build_dir):\n options = []\n if self.module_dir_switch is not None:\n if self.module_dir_switch[-1]==' ':\n options.extend([self.module_dir_switch.strip(),module_build_dir])\n else:\n options.append(self.module_dir_switch.strip()+module_build_dir)\n else:\n print 'XXX: module_build_dir=%r option ignored' % (module_build_dir)\n print 'XXX: Fix module_dir_switch for ',self.__class__.__name__\n if self.module_include_switch is not None:\n for d in [module_build_dir]+module_dirs:\n options.append('%s%s' % (self.module_include_switch, d))\n else:\n print 'XXX: module_dirs=%r option ignored' % (module_dirs)\n print 'XXX: Fix module_include_switch for ',self.__class__.__name__\n return options\n\n def library_option(self, lib):\n return \"-l\" + lib\n def library_dir_option(self, dir):\n return \"-L\" + dir\n\n if sys.version[:3]<'2.3':\n def compile(self, sources, output_dir=None, macros=None,\n include_dirs=None, debug=0, extra_preargs=None,\n extra_postargs=None, depends=None):\n if output_dir is None: output_dir = self.output_dir\n if macros is None: macros = self.macros\n elif type(macros) is ListType: macros = macros + (self.macros or [])\n if include_dirs is None: include_dirs = self.include_dirs\n elif type(include_dirs) in (ListType, TupleType):\n include_dirs = list(include_dirs) + (self.include_dirs or [])\n if extra_preargs is None: extra_preargs=[]\n from distutils.sysconfig import python_build\n objects = self.object_filenames(sources,strip_dir=python_build,\n output_dir=output_dir)\n from distutils.ccompiler import gen_preprocess_options\n pp_opts = gen_preprocess_options(macros, include_dirs)\n build = {}\n for i in range(len(sources)):\n src,obj = sources[i],objects[i]\n ext = os.path.splitext(src)[1]\n self.mkpath(os.path.dirname(obj))\n build[obj] = src, ext\n cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)\n for obj, (src, ext) in build.items():\n self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)\n return objects\n def detect_language(self, sources):\n return\n\n def link(self, target_desc, objects,\n output_filename, output_dir=None, libraries=None,\n library_dirs=None, runtime_library_dirs=None,\n export_symbols=None, debug=0, extra_preargs=None,\n extra_postargs=None, build_temp=None, target_lang=None):\n objects, output_dir = self._fix_object_args(objects, output_dir)\n libraries, library_dirs, runtime_library_dirs = \\\n self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)\n\n lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,\n libraries)\n if type(output_dir) not in (StringType, NoneType):\n raise TypeError, \"'output_dir' must be a string or None\"\n if output_dir is not None:\n output_filename = os.path.join(output_dir, output_filename)\n\n if self._need_link(objects, output_filename):\n if self.library_switch[-1]==' ':\n o_args = [self.library_switch.strip(),output_filename]\n else:\n o_args = [self.library_switch.strip()+output_filename]\n ld_args = (objects + self.objects +\n lib_opts + o_args)\n #if debug:\n # ld_args[:0] = ['-g']\n if extra_preargs:\n ld_args[:0] = extra_preargs\n if extra_postargs:\n ld_args.extend(extra_postargs)\n self.mkpath(os.path.dirname(output_filename))\n if target_desc == CCompiler.EXECUTABLE:\n raise NotImplementedError,self.__class__.__name__+'.linker_exe attribute'\n else:\n linker = self.linker_so[:]\n command = linker + ld_args\n log.info(' '.join(command))\n try:\n s,o = self.exec_command(command)\n except DistutilsExecError, msg:\n raise LinkError, msg\n if s:\n raise LinkError, o\n else:\n log.debug(\"skipping %s (up-to-date)\", output_filename)\n return\n\n ############################################################\n\n ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif type(command) is type(''):\n var = self.executables[command]\n if var is not None:\n var = var[0]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n return var\n\n def __get_flags(self, command, envvar=None, confvar=None):\n if command is None:\n var = []\n elif type(command) is type(''):\n var = self.executables[command][1:]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n if type(var) is type(''):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\n##############################################################################\n\nfcompiler_class = {'gnu':('gnufcompiler','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'pg':('pgfcompiler','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoftfcompiler','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mipsfcompiler','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sunfcompiler','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intelfcompiler','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intelfcompiler','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intelfcompiler','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intelfcompiler','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nagfcompiler','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaqfcompiler','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaqfcompiler','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vastfcompiler','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpuxfcompiler','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('laheyfcompiler','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'f':('fcompiler','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelitanium')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelitanium')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intelitanium')),\n ('sunos.*',('forte','gnu','sun')),\n ('irix',('mips','gnu')),\n # OS mappings\n ('posix',('gnu',)),\n ('nt',('gnu',)),\n ('mac',('gnu',)),\n )\n\ndef get_default_fcompiler(osname=None, platform=None):\n \"\"\" Determine the default Fortran compiler to use for the given platform. \"\"\"\n if osname is None:\n osname = os.name\n if platform is None:\n platform = sys.platform\n for pattern, compiler in _default_compilers:\n if re.match(pattern, platform) is not None or \\\n re.match(pattern, osname) is not None:\n if type(compiler) is type(()):\n return compiler[0]\n return compiler\n return 'gnu'\n\ndef new_fcompiler(plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n \"\"\" Generate an instance of some FCompiler subclass for the supplied\n platform/compiler combination.\n \"\"\"\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_fcompiler(plat)\n (module_name, class_name, long_description) = fcompiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile Fortran code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler.\" % compiler\n msg = msg + \" Supported compilers are: %s)\" \\\n % (','.join(fcompiler_class.keys()))\n raise DistutilsPlatformError, msg\n\n try:\n module_name = 'scipy_distutils.'+module_name\n __import__ (module_name)\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile Fortran code: unable to load module '%s'\" % \\\n module_name\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile Fortran code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n print '*'*80\n print klass\n print '*'*80\n return klass(None, dry_run, force)\n\n\ndef show_fcompilers(dist = None):\n \"\"\" Print list of available compilers (used by the \"--help-fcompiler\"\n option to \"config_fc\").\n \"\"\"\n if dist is None:\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n compilers = []\n compilers_na = []\n compilers_ni = []\n for compiler in fcompiler_class.keys():\n v = 'N/A'\n try:\n c = new_fcompiler(compiler=compiler)\n c.customize(dist)\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except:\n print sys.exc_info()[0],sys.exc_info()[1]\n if v is None:\n compilers_na.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n elif v=='N/A':\n compilers_ni.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n else:\n compilers.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2] + ' (%s)' % v))\n compilers.sort()\n compilers_na.sort()\n pretty_printer = FancyGetopt(compilers)\n pretty_printer.print_help(\"List of available Fortran compilers:\")\n pretty_printer = FancyGetopt(compilers_na)\n pretty_printer.print_help(\"List of unavailable Fortran compilers:\")\n if compilers_ni:\n pretty_printer = FancyGetopt(compilers_ni)\n pretty_printer.print_help(\"List of unimplemented Fortran compilers:\")\n print \"For compiler details, run 'config_fc --verbose' setup command.\"\n\ndef dummy_fortran_file():\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n def rm_file(name=dummy_name,log_threshold=log._global_log.threshold):\n save_th = log._global_log.threshold\n log.set_threshold(log_threshold)\n try: os.remove(name+'.f'); log.debug('removed '+name+'.f')\n except OSError: pass\n try: os.remove(name+'.o'); log.debug('removed '+name+'.o')\n except OSError: pass\n log.set_threshold(save_th)\n atexit.register(rm_file)\n return dummy_name\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15 # the number of non-comment lines to scan for hints\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nif __name__ == '__main__':\n show_fcompilers()\n", "source_code_before": "\"\"\"scipy_distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the Scipy_istutils Fortran compiler abstraction model.\n\n\"\"\"\n\nimport re\nimport os\nimport sys\nimport atexit\nfrom types import StringType, NoneType, ListType, TupleType\nfrom glob import glob\n\nfrom distutils.version import StrictVersion\nfrom distutils.ccompiler import CCompiler, gen_lib_options\n# distutils.ccompiler provides the following functions:\n# gen_preprocess_options(macros, include_dirs)\n# gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.core import Command\nfrom distutils.util import split_quoted\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.version import LooseVersion\nfrom distutils.sysconfig import get_config_var\n\nfrom scipy_distutils.command.config_compiler import config_fc\n\nimport log\nfrom exec_command import find_executable, exec_command\n\n\nclass FCompiler(CCompiler):\n \"\"\" Abstract base class to define the interface that must be implemented\n by real Fortran compiler classes.\n\n Methods that subclasses may redefine:\n\n get_version_cmd(), get_linker_so(), get_version()\n get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()\n get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),\n get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),\n get_flags_arch_f90(), get_flags_debug_f90(),\n get_flags_fix(), get_flags_linker_so(), get_flags_version()\n\n DON'T call these methods (except get_version) after\n constructing a compiler instance or inside any other method.\n All methods, except get_version_cmd() and get_flags_version(), may\n call get_version() method.\n\n After constructing a compiler instance, always call customize(dist=None)\n method that finalizes compiler construction and makes the following\n attributes available:\n compiler_f77\n compiler_f90\n compiler_fix\n linker_so\n archiver\n ranlib\n libraries\n library_dirs\n \"\"\"\n # CCompiler defines the following attributes:\n # compiler_type\n # src_extensions\n # obj_extension\n # static_lib_extension\n # shared_lib_extension\n # static_lib_format\n # shared_lib_format\n # exe_extension\n # language_map ### REDEFINED\n # language_order ### REDEFINED\n # and the following public methods:\n # set_executables(**args)\n # set_executable(key,value)\n # define_macro(name, value=None)\n # undefine_macro(name)\n # add_include_dir(dir)\n # set_include_dirs(dirs)\n # add_library(libname)\n # set_libraries(libnames)\n # add_library_dir(dir)\n # set_library_dirs(dirs)\n # add_runtime_library_dir(dir)\n # set_runtime_library_dirs(dirs)\n # add_link_object(object)\n # set_link_objects(objects)\n #\n # detect_language(sources) ### USABLE\n #\n # preprocess(source,output_file=None,macros=None,include_dirs=None,\n # extra_preargs=None,extra_postargs=None)\n # compile(sources, output_dir=None, macros=None,\n # include_dirs=None, debug=0, extra_preargs=None,\n # extra_postargs=None, depends=None)\n # create_static_lib(objects,output_libname,output_dir=None,debug=0,target_lang=None):\n # link(target_desc, objects, output_filename, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None,\n # build_temp=None, target_lang=None)\n # link_shared_lib(objects, output_libname, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None,\n # extra_postargs=None, build_temp=None, target_lang=None)\n # link_shared_object(objects,output_filename,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # export_symbols=None,debug=0,extra_preargs=None,\n # extra_postargs=None,build_temp=None,target_lang=None)\n # link_executable(objects,output_progname,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # debug=0,extra_preargs=None,extra_postargs=None,target_lang=None)\n #\n # library_dir_option(dir)\n # runtime_library_dir_option(dir)\n # library_option(lib)\n # has_function(funcname,includes=None,include_dirs=None,\n # libraries=None,library_dirs=None)\n # find_library_file(dirs, lib, debug=0)\n #\n # object_filenames(source_filenames, strip_dir=0, output_dir='')\n # shared_object_filename(basename, strip_dir=0, output_dir='')\n # executable_filenamee(basename, strip_dir=0, output_dir='')\n # library_filename(libname, lib_type='static',strip_dir=0, output_dir=''):\n #\n # announce(msg, level=1)\n # debug_print(msg)\n # warn(msg)\n # execute(func, args, msg=None, level=1)\n # spawn(cmd)\n # move_file(src,dst)\n # mkpath(name, mode=0777)\n #\n\n language_map = {'.f':'f77',\n '.for':'f77',\n '.ftn':'f77',\n '.f77':'f77',\n '.f90':'f90',\n '.f95':'f90'}\n language_order = ['f90','f77']\n\n version_pattern = None\n\n executables = {\n 'version_cmd' : [\"f77\",\"-v\"],\n 'compiler_f77' : [\"f77\"],\n 'compiler_f90' : [\"f90\"],\n 'compiler_fix' : [\"f90\",\"-fixed\"],\n 'linker_so' : [\"f90\",\"-shared\"],\n #'linker_exe' : [\"f90\"], # XXX do we need it??\n 'archiver' : [\"ar\",\"-cr\"],\n 'ranlib' : None,\n }\n\n compile_switch = \"-c\"\n object_switch = \"-o \" # Ending space matters! It will be stripped\n # but if it is missing then object_switch\n # will be prefixed to object file name by\n # string concatenation.\n library_switch = \"-o \" # Ditto!\n\n # Switch to specify where module files are created and searched\n # for USE statement. Normally it is a string and also here ending\n # space matters. See above.\n module_dir_switch = None\n\n # Switch to specify where module files are searched for USE statement.\n module_include_switch = '-I' \n\n pic_flags = [] # Flags to create position-independent code\n\n src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95']\n obj_extension = \".o\"\n shared_lib_extension = get_config_var('SO') # or .dll\n static_lib_extension = \".a\" # or .lib\n static_lib_format = \"lib%s%s\" # or %s%s\n shared_lib_format = \"%s%s\"\n exe_extension = \"\"\n\n ######################################################################\n ## Methods that subclasses may redefine. But don't call these methods!\n ## They are private to FCompiler class and may return unexpected\n ## results if used elsewhere. So, you have been warned..\n\n def get_version_cmd(self):\n \"\"\" Compiler command to print out version information. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n cmd = self.executables['version_cmd']\n if cmd is not None:\n cmd = cmd[0]\n if cmd==f77:\n cmd = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if cmd==f90:\n cmd = self.compiler_f90[0]\n return cmd\n\n def get_linker_so(self):\n \"\"\" Linker command to build shared libraries. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n ln = self.executables['linker_so']\n if ln is not None:\n ln = ln[0]\n if ln==f77:\n ln = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if ln==f90:\n ln = self.compiler_f90[0]\n return ln\n\n def get_flags(self):\n \"\"\" List of flags common to all compiler types. \"\"\"\n return [] + self.pic_flags\n def get_flags_version(self):\n \"\"\" List of compiler flags to print out version information. \"\"\"\n if self.executables['version_cmd']:\n return self.executables['version_cmd'][1:]\n return []\n def get_flags_f77(self):\n \"\"\" List of Fortran 77 specific flags. \"\"\"\n if self.executables['compiler_f77']:\n return self.executables['compiler_f77'][1:]\n return []\n def get_flags_f90(self):\n \"\"\" List of Fortran 90 specific flags. \"\"\"\n if self.executables['compiler_f90']:\n return self.executables['compiler_f90'][1:]\n return []\n def get_flags_fix(self):\n \"\"\" List of Fortran 90 fixed format specific flags. \"\"\"\n if self.executables['compiler_fix']:\n return self.executables['compiler_fix'][1:]\n return []\n def get_flags_linker_so(self):\n \"\"\" List of linker flags to build a shared library. \"\"\"\n if self.executables['linker_so']:\n return self.executables['linker_so'][1:]\n return []\n def get_flags_ar(self):\n \"\"\" List of archiver flags. \"\"\"\n if self.executables['archiver']:\n return self.executables['archiver'][1:]\n return []\n def get_flags_opt(self):\n \"\"\" List of architecture independent compiler flags. \"\"\"\n return []\n def get_flags_arch(self):\n \"\"\" List of architecture dependent compiler flags. \"\"\"\n return []\n def get_flags_debug(self):\n \"\"\" List of compiler flags to compile with debugging information. \"\"\"\n return []\n get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt\n get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch\n get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug\n\n def get_libraries(self):\n \"\"\" List of compiler libraries. \"\"\"\n return self.libraries[:]\n def get_library_dirs(self):\n \"\"\" List of compiler library directories. \"\"\"\n return self.library_dirs[:]\n\n def get_version(self, force=0, ok_status=[0]):\n \"\"\" Compiler version. Returns None if compiler is not available. \"\"\"\n if not force and hasattr(self,'version'):\n return self.version\n\n cmd = ' '.join(self.version_cmd)\n status, output = self.exec_command(cmd,use_tee=0)\n version = None\n if status in ok_status:\n m = re.match(self.version_pattern,output)\n if m:\n version = m.group('version')\n assert version,`version`\n version = LooseVersion(version)\n self.version = version\n return version\n\n ############################################################\n\n ## Public methods:\n\n def customize(self, dist=None):\n \"\"\" Customize Fortran compiler.\n\n This method gets Fortran compiler specific information from\n (i) class definition, (ii) environment, (iii) distutils config\n files, and (iv) command line.\n\n This method should be always called after constructing a\n compiler instance. But not in __init__ because Distribution\n instance is needed for (iii) and (iv).\n \"\"\"\n if dist is None:\n # These hooks are for testing only!\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n conf = dist.get_option_dict('config_fc')\n\n noopt = conf.get('noopt',[None,0])[1]\n noarch = conf.get('noarch',[None,noopt])[1]\n debug = conf.get('debug',[None,0])[1]\n\n f77 = self.__get_cmd('compiler_f77','F77',(conf,'f77exec'))\n f90 = self.__get_cmd('compiler_f90','F90',(conf,'f90exec'))\n # Temporarily setting f77,f90 compilers so that\n # version_cmd can use their executables.\n if f77:\n self.set_executables(compiler_f77=[f77])\n if f90:\n self.set_executables(compiler_f90=[f90])\n\n # Must set version_cmd before others as self.get_flags*\n # methods may call self.get_version.\n vers_cmd = self.__get_cmd(self.get_version_cmd)\n if vers_cmd:\n vflags = self.__get_flags(self.get_flags_version)\n self.set_executables(version_cmd=[vers_cmd]+vflags)\n\n if f77:\n f77flags = self.__get_flags(self.get_flags_f77,'F77FLAGS',\n (conf,'f77flags'))\n if f90:\n f90flags = self.__get_flags(self.get_flags_f90,'F90FLAGS',\n (conf,'f90flags'))\n\n # XXX Assuming that free format is default for f90 compiler.\n fix = self.__get_cmd('compiler_fix','F90',(conf,'f90exec'))\n if fix:\n fixflags = self.__get_flags(self.get_flags_fix) + f90flags\n\n oflags,aflags,dflags = [],[],[]\n if not noopt:\n oflags = self.__get_flags(self.get_flags_opt,'FOPT',(conf,'opt'))\n if f77 and self.get_flags_opt is not self.get_flags_opt_f77:\n f77flags += self.__get_flags(self.get_flags_opt_f77)\n if f90 and self.get_flags_opt is not self.get_flags_opt_f90:\n f90flags += self.__get_flags(self.get_flags_opt_f90)\n if fix and self.get_flags_opt is not self.get_flags_opt_f90:\n fixflags += self.__get_flags(self.get_flags_opt_f90)\n if not noarch:\n aflags = self.__get_flags(self.get_flags_arch,'FARCH',\n (conf,'arch'))\n if f77 and self.get_flags_arch is not self.get_flags_arch_f77:\n f77flags += self.__get_flags(self.get_flags_arch_f77)\n if f90 and self.get_flags_arch is not self.get_flags_arch_f90:\n f90flags += self.__get_flags(self.get_flags_arch_f90)\n if fix and self.get_flags_arch is not self.get_flags_arch_f90:\n fixflags += self.__get_flags(self.get_flags_arch_f90)\n if debug:\n dflags = self.__get_flags(self.get_flags_debug,'FDEBUG')\n if f77 and self.get_flags_debug is not self.get_flags_debug_f77:\n f77flags += self.__get_flags(self.get_flags_debug_f77)\n if f90 and self.get_flags_debug is not self.get_flags_debug_f90:\n f90flags += self.__get_flags(self.get_flags_debug_f90)\n if fix and self.get_flags_debug is not self.get_flags_debug_f90:\n fixflags += self.__get_flags(self.get_flags_debug_f90)\n\n fflags = self.__get_flags(self.get_flags,'FFLAGS') \\\n + dflags + oflags + aflags\n\n if f77:\n self.set_executables(compiler_f77=[f77]+f77flags+fflags)\n if f90:\n self.set_executables(compiler_f90=[f90]+f90flags+fflags)\n if fix:\n self.set_executables(compiler_fix=[fix]+fixflags+fflags)\n\n #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS\n linker_so = self.__get_cmd(self.get_linker_so,'LDSHARED')\n if linker_so:\n linker_so_flags = self.__get_flags(self.get_flags_linker_so,'LDFLAGS')\n self.set_executables(linker_so=[linker_so]+linker_so_flags)\n\n ar = self.__get_cmd('archiver','AR')\n if ar:\n arflags = self.__get_flags(self.get_flags_ar,'ARFLAGS')\n self.set_executables(archiver=[ar]+arflags)\n\n ranlib = self.__get_cmd('ranlib','RANLIB')\n if ranlib:\n self.set_executables(ranlib=[ranlib])\n\n self.set_library_dirs(self.get_library_dirs())\n self.set_libraries(self.get_libraries())\n\n verbose = conf.get('verbose',[None,0])[1]\n if verbose:\n self.dump_properties()\n return\n\n def customize_cmd(self, cmd):\n if cmd.include_dirs is not None:\n self.set_include_dirs(cmd.include_dirs)\n if cmd.define is not None:\n for (name,value) in cmd.define:\n self.define_macro(name, value)\n if cmd.undef is not None:\n for macro in cmd.undef:\n self.undefine_macro(macro)\n if cmd.libraries is not None:\n self.set_libraries(self.get_libraries() + cmd.libraries)\n if cmd.library_dirs is not None:\n self.set_library_dirs(self.get_library_dirs() + cmd.library_dirs)\n if cmd.rpath is not None:\n self.set_runtime_library_dirs(cmd.rpath)\n if cmd.link_objects is not None:\n self.set_link_objects(cmd.link_objects)\n return\n \n def dump_properties(self):\n \"\"\" Print out the attributes of a compiler instance. \"\"\"\n props = []\n for key in self.executables.keys() + \\\n ['version','libraries','library_dirs',\n 'object_switch','compile_switch']:\n if hasattr(self,key):\n v = getattr(self,key)\n props.append((key, None, '= '+`v`))\n props.sort()\n\n pretty_printer = FancyGetopt(props)\n for l in pretty_printer.generate_help(\"%s instance properties:\" \\\n % (self.__class__.__name__)):\n if l[:4]==' --':\n l = ' ' + l[4:]\n print l\n return\n\n def exec_command(self,*args,**kws):\n \"\"\" Return status,output of a command. \"\"\"\n quiet = kws.get('quiet',1)\n try: del kws['quiet']\n except KeyError: pass\n if not quiet:\n log.info('%s.exec_command(*%s,**%s)' % (self.__class__.__name__,\n args,kws))\n status, output = exec_command(*args,**kws)\n if not quiet:\n log.info('*****status:%s\\n*****output:\\n%s\\n*****' % (status,output))\n return status, output\n\n ###################\n\n def _get_cc_args(self, pp_opts, debug, before):\n #XXX\n print self.__class__.__name__ + '._get_cc_args:',pp_opts, debug, before\n return []\n\n def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):\n \"\"\"Compile 'src' to product 'obj'.\"\"\"\n print self.__class__.__name__ + '._compile:',obj, src, ext, cc_args, extra_postargs, pp_opts\n\n if is_f_file(src):\n compiler = self.compiler_f77\n elif is_free_format(src):\n compiler = self.compiler_f90\n if compiler is None:\n raise DistutilsExecError, 'f90 not supported by '\\\n +self.__class__.__name__\n else:\n compiler = self.compiler_fix\n if compiler is None:\n raise DistutilsExecError, 'f90 (fixed) not supported by '\\\n +self.__class__.__name__\n if self.object_switch[-1]==' ':\n o_args = [self.object_switch.strip(),obj]\n else:\n o_args = [self.object_switch.strip()+obj]\n\n assert self.compile_switch.strip()\n s_args = [self.compile_switch, src]\n\n command = compiler + cc_args + pp_opts + s_args + o_args + extra_postargs\n log.info(' '.join(command))\n try:\n s,o = self.exec_command(command)\n except DistutilsExecError, msg:\n raise CompileError, msg\n if s:\n raise CompileError, o\n\n return\n\n def module_options(self, module_dirs, module_build_dir):\n options = []\n if self.module_dir_switch is not None:\n if self.module_dir_switch[-1]==' ':\n options.extend([self.module_dir_switch.strip(),module_build_dir])\n else:\n options.append(self.module_dir_switch.strip()+module_build_dir)\n else:\n print 'XXX: module_build_dir=%r option ignored' % (module_build_dir)\n print 'XXX: Fix module_dir_switch for ',self.__class__.__name__\n if self.module_include_switch is not None:\n for d in [module_build_dir]+module_dirs:\n options.append('%s%s' % (self.module_include_switch, d))\n else:\n print 'XXX: module_dirs=%r option ignored' % (module_dirs)\n print 'XXX: Fix module_include_switch for ',self.__class__.__name__\n return options\n\n def library_option(self, lib):\n return \"-l\" + lib\n def library_dir_option(self, dir):\n return \"-L\" + dir\n\n if sys.version[:3]<'2.3':\n def compile(self, sources, output_dir=None, macros=None,\n include_dirs=None, debug=0, extra_preargs=None,\n extra_postargs=None, depends=None):\n if output_dir is None: output_dir = self.output_dir\n if macros is None: macros = self.macros\n elif type(macros) is ListType: macros = macros + (self.macros or [])\n if include_dirs is None: include_dirs = self.include_dirs\n elif type(include_dirs) in (ListType, TupleType):\n include_dirs = list(include_dirs) + (self.include_dirs or [])\n if extra_preargs is None: extra_preargs=[]\n from distutils.sysconfig import python_build\n objects = self.object_filenames(sources,strip_dir=python_build,\n output_dir=output_dir)\n from distutils.ccompiler import gen_preprocess_options\n pp_opts = gen_preprocess_options(macros, include_dirs)\n build = {}\n for i in range(len(sources)):\n src,obj = sources[i],objects[i]\n ext = os.path.splitext(src)[1]\n self.mkpath(os.path.dirname(obj))\n build[obj] = src, ext\n cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)\n for obj, (src, ext) in build.items():\n self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)\n return objects\n def detect_language(self, sources):\n return\n\n def link(self, target_desc, objects,\n output_filename, output_dir=None, libraries=None,\n library_dirs=None, runtime_library_dirs=None,\n export_symbols=None, debug=0, extra_preargs=None,\n extra_postargs=None, build_temp=None, target_lang=None):\n objects, output_dir = self._fix_object_args(objects, output_dir)\n libraries, library_dirs, runtime_library_dirs = \\\n self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)\n\n lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,\n libraries)\n if type(output_dir) not in (StringType, NoneType):\n raise TypeError, \"'output_dir' must be a string or None\"\n if output_dir is not None:\n output_filename = os.path.join(output_dir, output_filename)\n\n if self._need_link(objects, output_filename):\n if self.library_switch[-1]==' ':\n o_args = [self.library_switch.strip(),output_filename]\n else:\n o_args = [self.library_switch.strip()+output_filename]\n ld_args = (objects + self.objects +\n lib_opts + o_args)\n #if debug:\n # ld_args[:0] = ['-g']\n if extra_preargs:\n ld_args[:0] = extra_preargs\n if extra_postargs:\n ld_args.extend(extra_postargs)\n self.mkpath(os.path.dirname(output_filename))\n if target_desc == CCompiler.EXECUTABLE:\n raise NotImplementedError,self.__class__.__name__+'.linker_exe attribute'\n else:\n linker = self.linker_so[:]\n command = linker + ld_args\n log.info(' '.join(command))\n try:\n s,o = self.exec_command(command)\n except DistutilsExecError, msg:\n raise LinkError, msg\n if s:\n raise LinkError, o\n else:\n log.debug(\"skipping %s (up-to-date)\", output_filename)\n return\n\n ############################################################\n\n ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif type(command) is type(''):\n var = self.executables[command]\n if var is not None:\n var = var[0]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n return var\n\n def __get_flags(self, command, envvar=None, confvar=None):\n if command is None:\n var = []\n elif type(command) is type(''):\n var = self.executables[command][1:]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n if type(var) is type(''):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\n##############################################################################\n\nfcompiler_class = {'gnu':('gnufcompiler','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'pg':('pgfcompiler','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoftfcompiler','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mipsfcompiler','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sunfcompiler','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intelfcompiler','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intelfcompiler','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intelfcompiler','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intelfcompiler','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nagfcompiler','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaqfcompiler','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaqfcompiler','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vastfcompiler','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpuxfcompiler','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('laheyfcompiler','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'f':('fcompiler','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelitanium')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelitanium')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intelitanium')),\n ('sunos.*',('forte','gnu','sun')),\n ('irix',('mips','gnu')),\n # OS mappings\n ('posix',('gnu',)),\n ('nt',('gnu',)),\n ('mac',('gnu',)),\n )\n\ndef get_default_fcompiler(osname=None, platform=None):\n \"\"\" Determine the default Fortran compiler to use for the given platform. \"\"\"\n if osname is None:\n osname = os.name\n if platform is None:\n platform = sys.platform\n for pattern, compiler in _default_compilers:\n if re.match(pattern, platform) is not None or \\\n re.match(pattern, osname) is not None:\n if type(compiler) is type(()):\n return compiler[0]\n return compiler\n return 'gnu'\n\ndef new_fcompiler(plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n \"\"\" Generate an instance of some FCompiler subclass for the supplied\n platform/compiler combination.\n \"\"\"\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_fcompiler(plat)\n (module_name, class_name, long_description) = fcompiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile Fortran code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler.\" % compiler\n msg = msg + \" Supported compilers are: %s)\" \\\n % (','.join(fcompiler_class.keys()))\n raise DistutilsPlatformError, msg\n\n try:\n module_name = 'scipy_distutils.'+module_name\n __import__ (module_name)\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile Fortran code: unable to load module '%s'\" % \\\n module_name\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile Fortran code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n\n return klass(None, dry_run, force)\n\n\ndef show_fcompilers(dist = None):\n \"\"\" Print list of available compilers (used by the \"--help-fcompiler\"\n option to \"config_fc\").\n \"\"\"\n if dist is None:\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n compilers = []\n compilers_na = []\n compilers_ni = []\n for compiler in fcompiler_class.keys():\n v = 'N/A'\n try:\n c = new_fcompiler(compiler=compiler)\n c.customize(dist)\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except:\n print sys.exc_info()[0],sys.exc_info()[1]\n if v is None:\n compilers_na.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n elif v=='N/A':\n compilers_ni.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n else:\n compilers.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2] + ' (%s)' % v))\n compilers.sort()\n compilers_na.sort()\n pretty_printer = FancyGetopt(compilers)\n pretty_printer.print_help(\"List of available Fortran compilers:\")\n pretty_printer = FancyGetopt(compilers_na)\n pretty_printer.print_help(\"List of unavailable Fortran compilers:\")\n if compilers_ni:\n pretty_printer = FancyGetopt(compilers_ni)\n pretty_printer.print_help(\"List of unimplemented Fortran compilers:\")\n print \"For compiler details, run 'config_fc --verbose' setup command.\"\n\ndef dummy_fortran_file():\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n def rm_file(name=dummy_name,log_threshold=log._global_log.threshold):\n save_th = log._global_log.threshold\n log.set_threshold(log_threshold)\n try: os.remove(name+'.f'); log.debug('removed '+name+'.f')\n except OSError: pass\n try: os.remove(name+'.o'); log.debug('removed '+name+'.o')\n except OSError: pass\n log.set_threshold(save_th)\n atexit.register(rm_file)\n return dummy_name\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15 # the number of non-comment lines to scan for hints\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nif __name__ == '__main__':\n show_fcompilers()\n", "methods": [ { "name": "get_version_cmd", "long_name": "get_version_cmd( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 187, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 205, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_flags", "long_name": "get_flags( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 223, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_version", "long_name": "get_flags_version( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 226, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f77", "long_name": "get_flags_f77( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 231, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f90", "long_name": "get_flags_f90( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 236, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_fix", "long_name": "get_flags_fix( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 246, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_ar", "long_name": "get_flags_ar( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 251, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 256, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 259, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 262, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 272, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self , force = 0 , ok_status = [ 0 ] )", "filename": "fcompiler.py", "nloc": 14, "complexity": 5, "token_count": 105, "parameters": [ "self", "force", "ok_status" ], "start_line": 276, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 83, "complexity": 36, "token_count": 785, "parameters": [ "self", "dist" ], "start_line": 297, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 114, "top_nesting_level": 1 }, { "name": "customize_cmd", "long_name": "customize_cmd( self , cmd )", "filename": "fcompiler.py", "nloc": 18, "complexity": 10, "token_count": 148, "parameters": [ "self", "cmd" ], "start_line": 412, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "dump_properties", "long_name": "dump_properties( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 5, "token_count": 117, "parameters": [ "self" ], "start_line": 431, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "exec_command", "long_name": "exec_command( self , * args , ** kws )", "filename": "fcompiler.py", "nloc": 11, "complexity": 4, "token_count": 87, "parameters": [ "self", "args", "kws" ], "start_line": 450, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "spawn", "long_name": "spawn( self , cmd )", "filename": "fcompiler.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self", "cmd" ], "start_line": 463, "end_line": 465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_get_cc_args", "long_name": "_get_cc_args( self , pp_opts , debug , before )", "filename": "fcompiler.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self", "pp_opts", "debug", "before" ], "start_line": 470, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "_compile", "long_name": "_compile( self , obj , src , ext , cc_args , extra_postargs , pp_opts )", "filename": "fcompiler.py", "nloc": 29, "complexity": 8, "token_count": 208, "parameters": [ "self", "obj", "src", "ext", "cc_args", "extra_postargs", "pp_opts" ], "start_line": 475, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "module_options", "long_name": "module_options( self , module_dirs , module_build_dir )", "filename": "fcompiler.py", "nloc": 17, "complexity": 5, "token_count": 129, "parameters": [ "self", "module_dirs", "module_build_dir" ], "start_line": 510, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "library_option", "long_name": "library_option( self , lib )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "lib" ], "start_line": 528, "end_line": 529, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dir_option", "long_name": "library_dir_option( self , dir )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "dir" ], "start_line": 530, "end_line": 531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , sources , output_dir = None , macros = None , include_dirs = None , debug = 0 , extra_preargs = None , extra_postargs = None , depends = None )", "filename": "fcompiler.py", "nloc": 25, "complexity": 11, "token_count": 264, "parameters": [ "self", "sources", "output_dir", "macros", "include_dirs", "debug", "extra_preargs", "extra_postargs", "depends" ], "start_line": 534, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 2 }, { "name": "detect_language", "long_name": "detect_language( self , sources )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "sources" ], "start_line": 559, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir = None , libraries = None , library_dirs = None , runtime_library_dirs = None , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 10, "token_count": 303, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 562, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "__get_cmd", "long_name": "__get_cmd( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 110, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 612, "end_line": 625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "__get_flags", "long_name": "__get_flags( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 120, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 627, "end_line": 640, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "get_default_fcompiler", "long_name": "get_default_fcompiler( osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 12, "complexity": 7, "token_count": 86, "parameters": [ "osname", "platform" ], "start_line": 694, "end_line": 706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "new_fcompiler", "long_name": "new_fcompiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "fcompiler.py", "nloc": 35, "complexity": 7, "token_count": 179, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 708, "end_line": 746, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "show_fcompilers", "long_name": "show_fcompilers( dist = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 8, "token_count": 270, "parameters": [ "dist" ], "start_line": 749, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "dummy_fortran_file.rm_file", "long_name": "dummy_fortran_file.rm_file( name = dummy_name , log_threshold = log . _global_log . threshold )", "filename": "fcompiler.py", "nloc": 8, "complexity": 3, "token_count": 84, "parameters": [ "name", "log_threshold" ], "start_line": 801, "end_line": 808, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "dummy_fortran_file", "long_name": "dummy_fortran_file( )", "filename": "fcompiler.py", "nloc": 9, "complexity": 1, "token_count": 46, "parameters": [], "start_line": 795, "end_line": 810, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "fcompiler.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 816, "end_line": 837, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_version_cmd", "long_name": "get_version_cmd( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 187, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 205, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_flags", "long_name": "get_flags( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 223, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_version", "long_name": "get_flags_version( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 226, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f77", "long_name": "get_flags_f77( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 231, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f90", "long_name": "get_flags_f90( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 236, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_fix", "long_name": "get_flags_fix( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 246, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_ar", "long_name": "get_flags_ar( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 251, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 256, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 259, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 262, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 272, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self , force = 0 , ok_status = [ 0 ] )", "filename": "fcompiler.py", "nloc": 14, "complexity": 5, "token_count": 105, "parameters": [ "self", "force", "ok_status" ], "start_line": 276, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 83, "complexity": 36, "token_count": 785, "parameters": [ "self", "dist" ], "start_line": 297, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 114, "top_nesting_level": 1 }, { "name": "customize_cmd", "long_name": "customize_cmd( self , cmd )", "filename": "fcompiler.py", "nloc": 18, "complexity": 10, "token_count": 148, "parameters": [ "self", "cmd" ], "start_line": 412, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "dump_properties", "long_name": "dump_properties( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 5, "token_count": 117, "parameters": [ "self" ], "start_line": 431, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "exec_command", "long_name": "exec_command( self , * args , ** kws )", "filename": "fcompiler.py", "nloc": 11, "complexity": 4, "token_count": 87, "parameters": [ "self", "args", "kws" ], "start_line": 450, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "_get_cc_args", "long_name": "_get_cc_args( self , pp_opts , debug , before )", "filename": "fcompiler.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self", "pp_opts", "debug", "before" ], "start_line": 465, "end_line": 468, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "_compile", "long_name": "_compile( self , obj , src , ext , cc_args , extra_postargs , pp_opts )", "filename": "fcompiler.py", "nloc": 29, "complexity": 8, "token_count": 208, "parameters": [ "self", "obj", "src", "ext", "cc_args", "extra_postargs", "pp_opts" ], "start_line": 470, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "module_options", "long_name": "module_options( self , module_dirs , module_build_dir )", "filename": "fcompiler.py", "nloc": 17, "complexity": 5, "token_count": 129, "parameters": [ "self", "module_dirs", "module_build_dir" ], "start_line": 505, "end_line": 521, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "library_option", "long_name": "library_option( self , lib )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "lib" ], "start_line": 523, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dir_option", "long_name": "library_dir_option( self , dir )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "dir" ], "start_line": 525, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , sources , output_dir = None , macros = None , include_dirs = None , debug = 0 , extra_preargs = None , extra_postargs = None , depends = None )", "filename": "fcompiler.py", "nloc": 25, "complexity": 11, "token_count": 264, "parameters": [ "self", "sources", "output_dir", "macros", "include_dirs", "debug", "extra_preargs", "extra_postargs", "depends" ], "start_line": 529, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 2 }, { "name": "detect_language", "long_name": "detect_language( self , sources )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "sources" ], "start_line": 554, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir = None , libraries = None , library_dirs = None , runtime_library_dirs = None , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 10, "token_count": 303, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 557, "end_line": 601, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "__get_cmd", "long_name": "__get_cmd( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 110, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 607, "end_line": 620, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "__get_flags", "long_name": "__get_flags( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 120, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 622, "end_line": 635, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "get_default_fcompiler", "long_name": "get_default_fcompiler( osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 12, "complexity": 7, "token_count": 86, "parameters": [ "osname", "platform" ], "start_line": 689, "end_line": 701, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "new_fcompiler", "long_name": "new_fcompiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "fcompiler.py", "nloc": 32, "complexity": 7, "token_count": 169, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 703, "end_line": 739, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "show_fcompilers", "long_name": "show_fcompilers( dist = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 8, "token_count": 270, "parameters": [ "dist" ], "start_line": 742, "end_line": 786, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "dummy_fortran_file.rm_file", "long_name": "dummy_fortran_file.rm_file( name = dummy_name , log_threshold = log . _global_log . threshold )", "filename": "fcompiler.py", "nloc": 8, "complexity": 3, "token_count": 84, "parameters": [ "name", "log_threshold" ], "start_line": 794, "end_line": 801, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "dummy_fortran_file", "long_name": "dummy_fortran_file( )", "filename": "fcompiler.py", "nloc": 9, "complexity": 1, "token_count": 46, "parameters": [], "start_line": 788, "end_line": 803, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "fcompiler.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 809, "end_line": 830, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "spawn", "long_name": "spawn( self , cmd )", "filename": "fcompiler.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self", "cmd" ], "start_line": 463, "end_line": 465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "new_fcompiler", "long_name": "new_fcompiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "fcompiler.py", "nloc": 35, "complexity": 7, "token_count": 179, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 708, "end_line": 746, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 } ], "nloc": 623, "complexity": 175, "token_count": 4306, "diff_parsed": { "added": [ "from scipy_distutils.ccompiler import CCompiler, gen_lib_options", " def spawn(self, cmd):", " s,o = self.exec_command(cmd)", " assert not s,`s`", "", "", " print '*'*80", " print klass", " print '*'*80" ], "deleted": [ "from distutils.ccompiler import CCompiler, gen_lib_options", "" ] } }, { "old_path": "scipy_distutils/gnufcompiler.py", "new_path": "scipy_distutils/gnufcompiler.py", "filename": "gnufcompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -33,19 +33,21 @@ class GnuFCompiler(FCompiler):\n }\n module_dir_switch = None\n module_include_switch = None\n- if os.name != 'nt':\n+\n+ # Cygwin: f771: warning: -fPIC ignored for target (all code is position independent)\n+ if os.name != 'nt' and sys.platform!='cygwin':\n pic_flags = ['-fPIC']\n \n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n- if re.match(r'(win32|cygwin.*|darwin)', sys.platform):\n+ if re.match(r'(darwin)', sys.platform):\n return\n return FCompiler.get_linker_so(self)\n \n def get_flags_linker_so(self):\n opt = FCompiler.get_flags_linker_so(self)\n- if not re.match(r'(win32|cygwin.*|darwin)', sys.platform):\n+ if not re.match(r'(darwin)', sys.platform):\n opt.append(\"-shared\")\n if sys.platform[:5]=='sunos':\n # SunOS often has dynamically loaded symbols defined in the\n@@ -167,6 +169,7 @@ def get_flags_arch(self):\n from scipy_distutils import log\n log.set_verbosity(2)\n from fcompiler import new_fcompiler\n- compiler = new_fcompiler(compiler='gnu')\n+ #compiler = new_fcompiler(compiler='gnu')\n+ compiler = GnuFCompiler()\n compiler.customize()\n print compiler.get_version()\n", "added_lines": 7, "deleted_lines": 4, "source_code": "\nimport re\nimport os\nimport sys\n\nfrom cpuinfo import cpu\nfrom fcompiler import FCompiler\nfrom exec_command import find_executable\n\nclass GnuFCompiler(FCompiler):\n\n compiler_type = 'gnu'\n version_pattern = r'GNU Fortran ((\\(GCC[^\\)]*(\\)\\)|\\)))|)\\s*'\\\n '(?P[^\\s*\\)]+)'\n\n # 'g77 --version' results\n # SunOS: GNU Fortran (GCC 3.2) 3.2 20020814 (release)\n # Debian: GNU Fortran (GCC) 3.3.3 20040110 (prerelease) (Debian)\n # GNU Fortran 0.5.25 20010319 (prerelease)\n # Redhat: GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)\n\n for fc_exe in map(find_executable,['g77','f77']):\n if os.path.isfile(fc_exe):\n break\n executables = {\n 'version_cmd' : [fc_exe,\"--version\"],\n 'compiler_f77' : [fc_exe,\"-Wall\",\"-fno-second-underscore\"],\n 'compiler_f90' : None,\n 'compiler_fix' : None,\n 'linker_so' : [fc_exe],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"],\n }\n module_dir_switch = None\n module_include_switch = None\n\n # Cygwin: f771: warning: -fPIC ignored for target (all code is position independent)\n if os.name != 'nt' and sys.platform!='cygwin':\n pic_flags = ['-fPIC']\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if re.match(r'(darwin)', sys.platform):\n return\n return FCompiler.get_linker_so(self)\n\n def get_flags_linker_so(self):\n opt = FCompiler.get_flags_linker_so(self)\n if not re.match(r'(darwin)', sys.platform):\n opt.append(\"-shared\")\n if sys.platform[:5]=='sunos':\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work. 'man gcc' says:\n # \".. Instead of using -mimpure-text, you should compile all\n # source code with -fpic or -fPIC.\"\n opt.append('-mimpure-text')\n return opt\n\n def get_libgcc_dir(self):\n status, output = self.exec_command('%s -print-libgcc-file-name' \\\n % (self.compiler_f77[0]),use_tee=0) \n if not status:\n return os.path.dirname(output)\n return\n\n def get_library_dirs(self):\n opt = FCompiler.get_library_dirs(self)\n if sys.platform[:5] != 'linux':\n d = self.get_libgcc_dir()\n if d:\n opt.append(d)\n return opt\n\n def get_libraries(self):\n opt = FCompiler.get_libraries(self)\n d = self.get_libgcc_dir()\n if d is not None:\n for g2c in ['g2c-pic','g2c']:\n f = self.static_lib_format % (g2c, self.static_lib_extension)\n if os.path.isfile(os.path.join(d,f)):\n break\n else:\n g2c = 'g2c'\n if sys.platform=='win32':\n opt.extend(['gcc',g2c])\n else:\n opt.append(g2c)\n return opt\n\n def get_flags_debug(self):\n return ['-g']\n\n def get_flags_opt(self):\n opt = ['-O3','-funroll-loops']\n return opt\n\n def get_flags_arch(self):\n opt = []\n if sys.platform=='darwin':\n if os.name != 'posix':\n # this should presumably correspond to Apple\n if cpu.is_ppc():\n opt.append('-arch ppc')\n elif cpu.is_i386():\n opt.append('-arch i386')\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt.append('-mcpu='+a)\n opt.append('-mtune='+a)\n break \n return opt\n march_flag = 1\n # 0.5.25 corresponds to 2.95.x\n if self.get_version() == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt.append('-march=k6')\n elif cpu.is_AthlonK7():\n opt.append('-march=athlon')\n else:\n march_flag = 0\n # Note: gcc 3.2 on win32 has breakage with -march specified\n elif self.get_version() >= '3.1.1' \\\n and not sys.platform=='win32': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt.append('-march=k6')\n elif cpu.is_AthlonK6_2():\n opt.append('-march=k6-2')\n elif cpu.is_AthlonK6_3():\n opt.append('-march=k6-3')\n elif cpu.is_AthlonK7():\n opt.append('-march=athlon')\n elif cpu.is_AthlonMP():\n opt.append('-march=athlon-mp')\n # there's also: athlon-tbird, athlon-4, athlon-xp\n elif cpu.is_PentiumIV():\n opt.append('-march=pentium4')\n elif cpu.is_PentiumIII():\n opt.append('-march=pentium3')\n elif cpu.is_PentiumII():\n opt.append('-march=pentium2')\n else:\n march_flag = 0\n if cpu.has_mmx(): opt.append('-mmmx') \n if self.get_version() > '3.2.2':\n if cpu.has_sse2(): opt.append('-msse2')\n if cpu.has_sse(): opt.append('-msse')\n if cpu.has_3dnow(): opt.append('-m3dnow')\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt.append('-march=i686')\n elif cpu.is_i586():\n opt.append('-march=i586')\n elif cpu.is_i486():\n opt.append('-march=i486')\n elif cpu.is_i386():\n opt.append('-march=i386')\n if cpu.is_Intel():\n opt.extend(['-malign-double','-fomit-frame-pointer'])\n return opt\n\nif __name__ == '__main__':\n from scipy_distutils import log\n log.set_verbosity(2)\n from fcompiler import new_fcompiler\n #compiler = new_fcompiler(compiler='gnu')\n compiler = GnuFCompiler()\n compiler.customize()\n print compiler.get_version()\n", "source_code_before": "\nimport re\nimport os\nimport sys\n\nfrom cpuinfo import cpu\nfrom fcompiler import FCompiler\nfrom exec_command import find_executable\n\nclass GnuFCompiler(FCompiler):\n\n compiler_type = 'gnu'\n version_pattern = r'GNU Fortran ((\\(GCC[^\\)]*(\\)\\)|\\)))|)\\s*'\\\n '(?P[^\\s*\\)]+)'\n\n # 'g77 --version' results\n # SunOS: GNU Fortran (GCC 3.2) 3.2 20020814 (release)\n # Debian: GNU Fortran (GCC) 3.3.3 20040110 (prerelease) (Debian)\n # GNU Fortran 0.5.25 20010319 (prerelease)\n # Redhat: GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)\n\n for fc_exe in map(find_executable,['g77','f77']):\n if os.path.isfile(fc_exe):\n break\n executables = {\n 'version_cmd' : [fc_exe,\"--version\"],\n 'compiler_f77' : [fc_exe,\"-Wall\",\"-fno-second-underscore\"],\n 'compiler_f90' : None,\n 'compiler_fix' : None,\n 'linker_so' : [fc_exe],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"],\n }\n module_dir_switch = None\n module_include_switch = None\n if os.name != 'nt':\n pic_flags = ['-fPIC']\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if re.match(r'(win32|cygwin.*|darwin)', sys.platform):\n return\n return FCompiler.get_linker_so(self)\n\n def get_flags_linker_so(self):\n opt = FCompiler.get_flags_linker_so(self)\n if not re.match(r'(win32|cygwin.*|darwin)', sys.platform):\n opt.append(\"-shared\")\n if sys.platform[:5]=='sunos':\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work. 'man gcc' says:\n # \".. Instead of using -mimpure-text, you should compile all\n # source code with -fpic or -fPIC.\"\n opt.append('-mimpure-text')\n return opt\n\n def get_libgcc_dir(self):\n status, output = self.exec_command('%s -print-libgcc-file-name' \\\n % (self.compiler_f77[0]),use_tee=0) \n if not status:\n return os.path.dirname(output)\n return\n\n def get_library_dirs(self):\n opt = FCompiler.get_library_dirs(self)\n if sys.platform[:5] != 'linux':\n d = self.get_libgcc_dir()\n if d:\n opt.append(d)\n return opt\n\n def get_libraries(self):\n opt = FCompiler.get_libraries(self)\n d = self.get_libgcc_dir()\n if d is not None:\n for g2c in ['g2c-pic','g2c']:\n f = self.static_lib_format % (g2c, self.static_lib_extension)\n if os.path.isfile(os.path.join(d,f)):\n break\n else:\n g2c = 'g2c'\n if sys.platform=='win32':\n opt.extend(['gcc',g2c])\n else:\n opt.append(g2c)\n return opt\n\n def get_flags_debug(self):\n return ['-g']\n\n def get_flags_opt(self):\n opt = ['-O3','-funroll-loops']\n return opt\n\n def get_flags_arch(self):\n opt = []\n if sys.platform=='darwin':\n if os.name != 'posix':\n # this should presumably correspond to Apple\n if cpu.is_ppc():\n opt.append('-arch ppc')\n elif cpu.is_i386():\n opt.append('-arch i386')\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt.append('-mcpu='+a)\n opt.append('-mtune='+a)\n break \n return opt\n march_flag = 1\n # 0.5.25 corresponds to 2.95.x\n if self.get_version() == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt.append('-march=k6')\n elif cpu.is_AthlonK7():\n opt.append('-march=athlon')\n else:\n march_flag = 0\n # Note: gcc 3.2 on win32 has breakage with -march specified\n elif self.get_version() >= '3.1.1' \\\n and not sys.platform=='win32': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt.append('-march=k6')\n elif cpu.is_AthlonK6_2():\n opt.append('-march=k6-2')\n elif cpu.is_AthlonK6_3():\n opt.append('-march=k6-3')\n elif cpu.is_AthlonK7():\n opt.append('-march=athlon')\n elif cpu.is_AthlonMP():\n opt.append('-march=athlon-mp')\n # there's also: athlon-tbird, athlon-4, athlon-xp\n elif cpu.is_PentiumIV():\n opt.append('-march=pentium4')\n elif cpu.is_PentiumIII():\n opt.append('-march=pentium3')\n elif cpu.is_PentiumII():\n opt.append('-march=pentium2')\n else:\n march_flag = 0\n if cpu.has_mmx(): opt.append('-mmmx') \n if self.get_version() > '3.2.2':\n if cpu.has_sse2(): opt.append('-msse2')\n if cpu.has_sse(): opt.append('-msse')\n if cpu.has_3dnow(): opt.append('-m3dnow')\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt.append('-march=i686')\n elif cpu.is_i586():\n opt.append('-march=i586')\n elif cpu.is_i486():\n opt.append('-march=i486')\n elif cpu.is_i386():\n opt.append('-march=i386')\n if cpu.is_Intel():\n opt.extend(['-malign-double','-fomit-frame-pointer'])\n return opt\n\nif __name__ == '__main__':\n from scipy_distutils import log\n log.set_verbosity(2)\n from fcompiler import new_fcompiler\n compiler = new_fcompiler(compiler='gnu')\n compiler.customize()\n print compiler.get_version()\n", "methods": [ { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "gnufcompiler.py", "nloc": 4, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 41, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "gnufcompiler.py", "nloc": 7, "complexity": 3, "token_count": 52, "parameters": [ "self" ], "start_line": 48, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_libgcc_dir", "long_name": "get_libgcc_dir( self )", "filename": "gnufcompiler.py", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "self" ], "start_line": 62, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "gnufcompiler.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 69, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "gnufcompiler.py", "nloc": 15, "complexity": 5, "token_count": 100, "parameters": [ "self" ], "start_line": 77, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "gnufcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 93, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "gnufcompiler.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 96, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "gnufcompiler.py", "nloc": 63, "complexity": 31, "token_count": 401, "parameters": [ "self" ], "start_line": 100, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 67, "top_nesting_level": 1 } ], "methods_before": [ { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "gnufcompiler.py", "nloc": 4, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 39, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "gnufcompiler.py", "nloc": 7, "complexity": 3, "token_count": 52, "parameters": [ "self" ], "start_line": 46, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_libgcc_dir", "long_name": "get_libgcc_dir( self )", "filename": "gnufcompiler.py", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "self" ], "start_line": 60, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "gnufcompiler.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 67, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "gnufcompiler.py", "nloc": 15, "complexity": 5, "token_count": 100, "parameters": [ "self" ], "start_line": 75, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "gnufcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 91, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "gnufcompiler.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "gnufcompiler.py", "nloc": 63, "complexity": 31, "token_count": 401, "parameters": [ "self" ], "start_line": 98, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 67, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "gnufcompiler.py", "nloc": 4, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 41, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "gnufcompiler.py", "nloc": 7, "complexity": 3, "token_count": 52, "parameters": [ "self" ], "start_line": 48, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 } ], "nloc": 140, "complexity": 48, "token_count": 862, "diff_parsed": { "added": [ "", " # Cygwin: f771: warning: -fPIC ignored for target (all code is position independent)", " if os.name != 'nt' and sys.platform!='cygwin':", " if re.match(r'(darwin)', sys.platform):", " if not re.match(r'(darwin)', sys.platform):", " #compiler = new_fcompiler(compiler='gnu')", " compiler = GnuFCompiler()" ], "deleted": [ " if os.name != 'nt':", " if re.match(r'(win32|cygwin.*|darwin)', sys.platform):", " if not re.match(r'(win32|cygwin.*|darwin)', sys.platform):", " compiler = new_fcompiler(compiler='gnu')" ] } } ] }, { "hash": "e404137498444ef2807195408a4ec7de66b83ab9", "msg": "Scipy builds under cygwin with build_src branch.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-05T12:02:04+00:00", "author_timezone": 0, "committer_date": "2004-02-05T12:02:04+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "0d9e6cd3d9f35efb3a1694a4c5da78f926b452c0" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 2, "insertions": 0, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/setup_scipy_base.py", "new_path": "scipy_base/setup_scipy_base.py", "filename": "setup_scipy_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -54,8 +54,6 @@ def configuration(parent_package='',parent_path=None):\n if __name__ == '__main__':\n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n- if sys.platform == 'win32':\n- from scipy_distutils.mingw32_support import *\n from scipy_distutils.core import setup\n \n setup(version = scipy_base_version,\n", "added_lines": 0, "deleted_lines": 2, "source_code": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nimport shutil\n\ndef configuration(parent_package='',parent_path=None):\n from scipy_distutils.system_info import get_info, NumericNotFoundError\n from scipy_distutils.core import Extension\n from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n from scipy_distutils.misc_util import get_path,default_config_dict,\\\n dot_join,SourceGenerator\n\n package = 'scipy_base'\n local_path = get_path(__name__,parent_path)\n config = default_config_dict(package,parent_package)\n\n numpy_info = get_info('numpy')\n if not numpy_info:\n raise NumericNotFoundError, NumericNotFoundError.__doc__\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n umath_c_sources = ['fastumathmodule.c',\n 'fastumath_unsigned.inc','fastumath_nounsigned.inc']\n umath_c_sources = [os.path.join(local_path,x) for x in umath_c_sources]\n umath_c = SourceGenerator(func = None,\n target = os.path.join(local_path,'fastumathmodule.c'),\n sources = umath_c_sources)\n sources = [umath_c, os.path.join(local_path,'isnan.c')]\n define_macros = []\n if sys.byteorder == \"little\":\n define_macros.append(('USE_MCONF_LITE_LE',None))\n else:\n define_macros.append(('USE_MCONF_LITE_BE',None))\n ext = Extension(dot_join(package,'fastumath'),sources,\n define_macros = define_macros,\n extra_compile_args=extra_compile_args,\n depends = umath_c_sources)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension(dot_join(package,'_compiled_base'),sources)\n config['ext_modules'].append(ext)\n\n return config\n\nif __name__ == '__main__':\n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n from scipy_distutils.core import setup\n\n setup(version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "source_code_before": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nimport shutil\n\ndef configuration(parent_package='',parent_path=None):\n from scipy_distutils.system_info import get_info, NumericNotFoundError\n from scipy_distutils.core import Extension\n from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n from scipy_distutils.misc_util import get_path,default_config_dict,\\\n dot_join,SourceGenerator\n\n package = 'scipy_base'\n local_path = get_path(__name__,parent_path)\n config = default_config_dict(package,parent_package)\n\n numpy_info = get_info('numpy')\n if not numpy_info:\n raise NumericNotFoundError, NumericNotFoundError.__doc__\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n umath_c_sources = ['fastumathmodule.c',\n 'fastumath_unsigned.inc','fastumath_nounsigned.inc']\n umath_c_sources = [os.path.join(local_path,x) for x in umath_c_sources]\n umath_c = SourceGenerator(func = None,\n target = os.path.join(local_path,'fastumathmodule.c'),\n sources = umath_c_sources)\n sources = [umath_c, os.path.join(local_path,'isnan.c')]\n define_macros = []\n if sys.byteorder == \"little\":\n define_macros.append(('USE_MCONF_LITE_LE',None))\n else:\n define_macros.append(('USE_MCONF_LITE_BE',None))\n ext = Extension(dot_join(package,'fastumath'),sources,\n define_macros = define_macros,\n extra_compile_args=extra_compile_args,\n depends = umath_c_sources)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension(dot_join(package,'_compiled_base'),sources)\n config['ext_modules'].append(ext)\n\n return config\n\nif __name__ == '__main__':\n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n if sys.platform == 'win32':\n from scipy_distutils.mingw32_support import *\n from scipy_distutils.core import setup\n\n setup(version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 35, "complexity": 5, "token_count": 269, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 35, "complexity": 5, "token_count": 269, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 50, "complexity": 5, "token_count": 330, "diff_parsed": { "added": [], "deleted": [ " if sys.platform == 'win32':", " from scipy_distutils.mingw32_support import *" ] } } ] }, { "hash": "9e9dbee266df63739bb748364bd161c565e2c4c2", "msg": "Fixed bug in testing import library. Clean up. Scipy now builds and tests on win32 (tested so on Windows ME, on Windows 98 I get strange import errors)", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-06T08:14:04+00:00", "author_timezone": 0, "committer_date": "2004-02-06T08:14:04+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "6425c5985e656d022d8d43684b737e93aab4f57d" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 15, "insertions": 18, "lines": 33, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/mingw32ccompiler.py", "new_path": "scipy_distutils/mingw32ccompiler.py", "filename": "mingw32ccompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -17,9 +17,9 @@\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n+# --> this is done in scipy_distutils/ccompiler.py\n # 3. Force windows to use g77\n \n-# 1. Build libpython from .lib and .dll if they don't exist. \n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from scipy_distutils.ccompiler import gen_preprocess_options, gen_lib_options\n@@ -47,7 +47,7 @@ def __init__ (self,\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n- out = os.popen('gcc' + ' -dumpversion','r')\n+ out = os.popen('gcc -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n@@ -86,8 +86,8 @@ def __init__ (self,\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n- self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n- compiler_so='gcc -O2 -w -Wstrict-prototypes',\n+ self.set_executables(compiler='gcc -mno-cygwin -O2 -Wall',\n+ compiler_so='gcc -O2 -Wall -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n@@ -100,7 +100,8 @@ def __init__ (self,\n \n # no additional libraries needed \n self.dll_libraries=[]\n- \n+ return\n+\n # __init__ ()\n \n def link(self,\n@@ -136,6 +137,7 @@ def link(self,\n else:\n func = UnixCCompiler.link\n func(*args[:func.im_func.func_code.co_argcount])\n+ return\n \n def object_filenames (self,\n source_filenames,\n@@ -166,9 +168,6 @@ def object_filenames (self,\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n- print 'here', os.path.join (output_dir,\n- base + self.obj_extension)\n- print '...:', output_dir, base + self.obj_extension \n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n@@ -183,10 +182,15 @@ def build_import_library():\n return\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n- if os.path.isfile(lib_file):\n- log.info('Skip building import library \"%s\"' % (lib_file))\n+ out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n+ out_file = os.path.join(sys.prefix,'libs',out_name)\n+ if not os.path.isfile(lib_file):\n+ log.info('Cannot build import library: \"%s\" not found' % (lib_file))\n+ return\n+ if os.path.isfile(out_file):\n+ log.info('Skip building import library: \"%s\" exists' % (out_file))\n return\n- log.info('Building import library \"%s\"' % (lib_file))\n+ log.info('Building import library: \"%s\"' % (out_file))\n \n from scipy_distutils import lib2def\n \n@@ -197,15 +201,14 @@ def build_import_library():\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n- out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n- out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n- success = not os.system(cmd)\n+ status = os.system(cmd)\n # for now, fail silently\n- if not success:\n+ if not status:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n+ return\n", "added_lines": 18, "deleted_lines": 15, "source_code": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os\nimport sys\nimport log\n\nimport scipy_distutils.ccompiler\n\n# NT stuff\n# 1. Make sure libpython.a exists for gcc. If not, build it.\n# 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n# --> this is done in scipy_distutils/ccompiler.py\n# 3. Force windows to use g77\n\nimport distutils.cygwinccompiler\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import gen_preprocess_options, gen_lib_options\nfrom distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n\nfrom distutils.unixccompiler import UnixCCompiler \n \n# the same as cygwin plus some additional parameters\nclass Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n\n build_import_library()\n\n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -Wall',\n compiler_so='gcc -O2 -Wall -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = ['g++']\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n return\n\n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None,\n target_lang=None):\n args = (self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, #export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n if self.gcc_version < \"3.0.0\":\n func = distutils.cygwinccompiler.CygwinCCompiler.link\n else:\n func = UnixCCompiler.link\n func(*args[:func.im_func.func_code.co_argcount])\n return\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n \n # object_filenames ()\n\n \ndef build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n if os.name != 'nt':\n return\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n if not os.path.isfile(lib_file):\n log.info('Cannot build import library: \"%s\" not found' % (lib_file))\n return\n if os.path.isfile(out_file):\n log.info('Skip building import library: \"%s\" exists' % (out_file))\n return\n log.info('Building import library: \"%s\"' % (out_file))\n\n from scipy_distutils import lib2def\n\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n status = os.system(cmd)\n # for now, fail silently\n if not status:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n return\n", "source_code_before": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os\nimport sys\nimport log\n\nimport scipy_distutils.ccompiler\n\n# NT stuff\n# 1. Make sure libpython.a exists for gcc. If not, build it.\n# 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n# 3. Force windows to use g77\n\n# 1. Build libpython from .lib and .dll if they don't exist. \nimport distutils.cygwinccompiler\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import gen_preprocess_options, gen_lib_options\nfrom distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n\nfrom distutils.unixccompiler import UnixCCompiler \n \n# the same as cygwin plus some additional parameters\nclass Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n\n build_import_library()\n\n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = ['g++']\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None,\n target_lang=None):\n args = (self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, #export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n if self.gcc_version < \"3.0.0\":\n func = distutils.cygwinccompiler.CygwinCCompiler.link\n else:\n func = UnixCCompiler.link\n func(*args[:func.im_func.func_code.co_argcount])\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n print 'here', os.path.join (output_dir,\n base + self.obj_extension)\n print '...:', output_dir, base + self.obj_extension \n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n \n # object_filenames ()\n\n \ndef build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n if os.name != 'nt':\n return\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n if os.path.isfile(lib_file):\n log.info('Skip building import library \"%s\"' % (lib_file))\n return\n log.info('Building import library \"%s\"' % (lib_file))\n\n from scipy_distutils import lib2def\n\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32ccompiler.py", "nloc": 37, "complexity": 7, "token_count": 203, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 38, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 1 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32ccompiler.py", "nloc": 34, "complexity": 2, "token_count": 113, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 107, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32ccompiler.py", "nloc": 25, "complexity": 8, "token_count": 173, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 142, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32ccompiler.py", "nloc": 28, "complexity": 5, "token_count": 251, "parameters": [], "start_line": 178, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32ccompiler.py", "nloc": 36, "complexity": 7, "token_count": 204, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 38, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 1 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32ccompiler.py", "nloc": 33, "complexity": 2, "token_count": 112, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 106, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32ccompiler.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 140, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32ccompiler.py", "nloc": 24, "complexity": 4, "token_count": 229, "parameters": [], "start_line": 179, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32ccompiler.py", "nloc": 37, "complexity": 7, "token_count": 203, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 38, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 1 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32ccompiler.py", "nloc": 34, "complexity": 2, "token_count": 113, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 107, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32ccompiler.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 140, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32ccompiler.py", "nloc": 28, "complexity": 5, "token_count": 251, "parameters": [], "start_line": 178, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 } ], "nloc": 147, "complexity": 22, "token_count": 803, "diff_parsed": { "added": [ "# --> this is done in scipy_distutils/ccompiler.py", " out = os.popen('gcc -dumpversion','r')", " self.set_executables(compiler='gcc -mno-cygwin -O2 -Wall',", " compiler_so='gcc -O2 -Wall -Wstrict-prototypes',", " return", "", " return", " out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])", " out_file = os.path.join(sys.prefix,'libs',out_name)", " if not os.path.isfile(lib_file):", " log.info('Cannot build import library: \"%s\" not found' % (lib_file))", " return", " if os.path.isfile(out_file):", " log.info('Skip building import library: \"%s\" exists' % (out_file))", " log.info('Building import library: \"%s\"' % (out_file))", " status = os.system(cmd)", " if not status:", " return" ], "deleted": [ "# 1. Build libpython from .lib and .dll if they don't exist.", " out = os.popen('gcc' + ' -dumpversion','r')", " self.set_executables(compiler='gcc -mno-cygwin -O2 -w',", " compiler_so='gcc -O2 -w -Wstrict-prototypes',", "", " print 'here', os.path.join (output_dir,", " base + self.obj_extension)", " print '...:', output_dir, base + self.obj_extension", " if os.path.isfile(lib_file):", " log.info('Skip building import library \"%s\"' % (lib_file))", " log.info('Building import library \"%s\"' % (lib_file))", " out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])", " out_file = os.path.join(sys.prefix,'libs',out_name)", " success = not os.system(cmd)", " if not success:" ] } } ] }, { "hash": "18900e11d111b51a491e7fbf5769c9acb4bf351f", "msg": "unixccompiler.py handles very long ar arguments lists", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-06T08:33:17+00:00", "author_timezone": 0, "committer_date": "2004-02-06T08:33:17+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "9e9dbee266df63739bb748364bd161c565e2c4c2" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 0, "insertions": 40, "lines": 40, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": null, "new_path": "scipy_distutils/unixccompiler.py", "filename": "unixccompiler.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,40 @@\n+\"\"\"\n+unixccompiler - can handle very long argument lists for ar.\n+\"\"\"\n+\n+import os\n+from distutils import unixccompiler\n+\n+import log\n+\n+class UnixCCompiler(unixccompiler.UnixCCompiler):\n+\n+ def create_static_lib(self, objects, output_libname,\n+ output_dir=None, debug=0, target_lang=None):\n+ objects, output_dir = self._fix_object_args(objects, output_dir)\n+ \n+ output_filename = \\\n+ self.library_filename(output_libname, output_dir=output_dir)\n+ \n+ if self._need_link(objects, output_filename):\n+ self.mkpath(os.path.dirname(output_filename))\n+ tmp_objects = objects + self.objects\n+ while tmp_objects:\n+ objects = tmp_objects[:50]\n+ tmp_objects = tmp_objects[50:]\n+ self.spawn(self.archiver +\n+ [output_filename] +\n+ objects)\n+ \n+ # Not many Unices required ranlib anymore -- SunOS 4.x is, I\n+ # think the only major Unix that does. Maybe we need some\n+ # platform intelligence here to skip ranlib if it's not\n+ # needed -- or maybe Python's configure script took care of\n+ # it for us, hence the check for leading colon.\n+ if self.ranlib:\n+ try:\n+ self.spawn(self.ranlib + [output_filename])\n+ except DistutilsExecError, msg:\n+ raise LibError, msg\n+ else:\n+ log.debug(\"skipping %s (up-to-date)\", output_filename)\n", "added_lines": 40, "deleted_lines": 0, "source_code": "\"\"\"\nunixccompiler - can handle very long argument lists for ar.\n\"\"\"\n\nimport os\nfrom distutils import unixccompiler\n\nimport log\n\nclass UnixCCompiler(unixccompiler.UnixCCompiler):\n\n def create_static_lib(self, objects, output_libname,\n output_dir=None, debug=0, target_lang=None):\n objects, output_dir = self._fix_object_args(objects, output_dir)\n \n output_filename = \\\n self.library_filename(output_libname, output_dir=output_dir)\n \n if self._need_link(objects, output_filename):\n self.mkpath(os.path.dirname(output_filename))\n tmp_objects = objects + self.objects\n while tmp_objects:\n objects = tmp_objects[:50]\n tmp_objects = tmp_objects[50:]\n self.spawn(self.archiver +\n [output_filename] +\n objects)\n \n # Not many Unices required ranlib anymore -- SunOS 4.x is, I\n # think the only major Unix that does. Maybe we need some\n # platform intelligence here to skip ranlib if it's not\n # needed -- or maybe Python's configure script took care of\n # it for us, hence the check for leading colon.\n if self.ranlib:\n try:\n self.spawn(self.ranlib + [output_filename])\n except DistutilsExecError, msg:\n raise LibError, msg\n else:\n log.debug(\"skipping %s (up-to-date)\", output_filename)\n", "source_code_before": null, "methods": [ { "name": "create_static_lib", "long_name": "create_static_lib( self , objects , output_libname , output_dir = None , debug = 0 , target_lang = None )", "filename": "unixccompiler.py", "nloc": 21, "complexity": 5, "token_count": 145, "parameters": [ "self", "objects", "output_libname", "output_dir", "debug", "target_lang" ], "start_line": 12, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 } ], "methods_before": [], "changed_methods": [ { "name": "create_static_lib", "long_name": "create_static_lib( self , objects , output_libname , output_dir = None , debug = 0 , target_lang = None )", "filename": "unixccompiler.py", "nloc": 21, "complexity": 5, "token_count": 145, "parameters": [ "self", "objects", "output_libname", "output_dir", "debug", "target_lang" ], "start_line": 12, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 } ], "nloc": 28, "complexity": 5, "token_count": 163, "diff_parsed": { "added": [ "\"\"\"", "unixccompiler - can handle very long argument lists for ar.", "\"\"\"", "", "import os", "from distutils import unixccompiler", "", "import log", "", "class UnixCCompiler(unixccompiler.UnixCCompiler):", "", " def create_static_lib(self, objects, output_libname,", " output_dir=None, debug=0, target_lang=None):", " objects, output_dir = self._fix_object_args(objects, output_dir)", "", " output_filename = \\", " self.library_filename(output_libname, output_dir=output_dir)", "", " if self._need_link(objects, output_filename):", " self.mkpath(os.path.dirname(output_filename))", " tmp_objects = objects + self.objects", " while tmp_objects:", " objects = tmp_objects[:50]", " tmp_objects = tmp_objects[50:]", " self.spawn(self.archiver +", " [output_filename] +", " objects)", "", " # Not many Unices required ranlib anymore -- SunOS 4.x is, I", " # think the only major Unix that does. Maybe we need some", " # platform intelligence here to skip ranlib if it's not", " # needed -- or maybe Python's configure script took care of", " # it for us, hence the check for leading colon.", " if self.ranlib:", " try:", " self.spawn(self.ranlib + [output_filename])", " except DistutilsExecError, msg:", " raise LibError, msg", " else:", " log.debug(\"skipping %s (up-to-date)\", output_filename)" ], "deleted": [] } } ] }, { "hash": "0d5d2277ba7ae30da0762ba396f861ad3f6d50bd", "msg": "Disabled debug messages. On WinXP MSYS defines MSYSTEM instead of OSTYPE.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-06T21:14:41+00:00", "author_timezone": 0, "committer_date": "2004-02-06T21:14:41+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "18900e11d111b51a491e7fbf5769c9acb4bf351f" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 5, "insertions": 6, "lines": 11, "files": 2, "dmm_unit_size": 0.5, "dmm_unit_complexity": 0.5, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/ccompiler.py", "new_path": "scipy_distutils/ccompiler.py", "filename": "ccompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -13,7 +13,8 @@\n compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler',\n \"Mingw32 port of GNU C Compiler for Win32\"\\\n \"(for MSC built Python)\")\n- if os.environ.get('OSTYPE','')=='msys':\n+ if os.environ.get('OSTYPE','')=='msys' or \\\n+ os.environ.get('MSYSTEM','')=='MINGW32':\n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n log.info('Setting mingw32 as default compiler for nt.')\n", "added_lines": 2, "deleted_lines": 1, "source_code": "\nimport re\nimport os\nimport sys\n\nfrom distutils.ccompiler import *\nfrom distutils import ccompiler\n\nimport log\nfrom exec_command import exec_command\n\nif sys.platform == 'win32':\n compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler',\n \"Mingw32 port of GNU C Compiler for Win32\"\\\n \"(for MSC built Python)\")\n if os.environ.get('OSTYPE','')=='msys' or \\\n os.environ.get('MSYSTEM','')=='MINGW32':\n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n log.info('Setting mingw32 as default compiler for nt.')\n ccompiler._default_compilers = (('nt', 'mingw32'),) \\\n + ccompiler._default_compilers\n\n_distutils_new_compiler = new_compiler\ndef new_compiler (plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n # Try first C compilers from scipy_distutils.\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_compiler(plat)\n (module_name, class_name, long_description) = compiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile C/C++ code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler\" % compiler\n raise DistutilsPlatformError, msg\n\n module_name = \"scipy_distutils.\" + module_name\n try:\n __import__ (module_name)\n except ImportError, msg:\n print msg\n module_name = module_name[6:]\n try:\n __import__(module_name)\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile C/C++ code: unable to load module '%s'\" % \\\n module_name\n try:\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile C/C++ code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n print '*'*80\n print klass\n print '*'*80\n return klass(None, dry_run, force)\n\n", "source_code_before": "\nimport re\nimport os\nimport sys\n\nfrom distutils.ccompiler import *\nfrom distutils import ccompiler\n\nimport log\nfrom exec_command import exec_command\n\nif sys.platform == 'win32':\n compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler',\n \"Mingw32 port of GNU C Compiler for Win32\"\\\n \"(for MSC built Python)\")\n if os.environ.get('OSTYPE','')=='msys':\n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n log.info('Setting mingw32 as default compiler for nt.')\n ccompiler._default_compilers = (('nt', 'mingw32'),) \\\n + ccompiler._default_compilers\n\n_distutils_new_compiler = new_compiler\ndef new_compiler (plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n # Try first C compilers from scipy_distutils.\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_compiler(plat)\n (module_name, class_name, long_description) = compiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile C/C++ code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler\" % compiler\n raise DistutilsPlatformError, msg\n\n module_name = \"scipy_distutils.\" + module_name\n try:\n __import__ (module_name)\n except ImportError, msg:\n print msg\n module_name = module_name[6:]\n try:\n __import__(module_name)\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile C/C++ code: unable to load module '%s'\" % \\\n module_name\n try:\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile C/C++ code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n print '*'*80\n print klass\n print '*'*80\n return klass(None, dry_run, force)\n\n", "methods": [ { "name": "new_compiler", "long_name": "new_compiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "ccompiler.py", "nloc": 39, "complexity": 8, "token_count": 181, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 25, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 } ], "methods_before": [ { "name": "new_compiler", "long_name": "new_compiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "ccompiler.py", "nloc": 39, "complexity": 8, "token_count": 181, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 24, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 56, "complexity": 8, "token_count": 279, "diff_parsed": { "added": [ " if os.environ.get('OSTYPE','')=='msys' or \\", " os.environ.get('MSYSTEM','')=='MINGW32':" ], "deleted": [ " if os.environ.get('OSTYPE','')=='msys':" ] } }, { "old_path": "scipy_distutils/fcompiler.py", "new_path": "scipy_distutils/fcompiler.py", "filename": "fcompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -469,12 +469,12 @@ def spawn(self, cmd):\n \n def _get_cc_args(self, pp_opts, debug, before):\n #XXX\n- print self.__class__.__name__ + '._get_cc_args:',pp_opts, debug, before\n+ #print self.__class__.__name__ + '._get_cc_args:',pp_opts, debug, before\n return []\n \n def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):\n \"\"\"Compile 'src' to product 'obj'.\"\"\"\n- print self.__class__.__name__ + '._compile:',obj, src, ext, cc_args, extra_postargs, pp_opts\n+ #print self.__class__.__name__ + '._compile:',obj, src, ext, cc_args, extra_postargs, pp_opts\n \n if is_f_file(src):\n compiler = self.compiler_f77\n@@ -770,8 +770,8 @@ def show_fcompilers(dist = None):\n v = c.get_version()\n except DistutilsModuleError:\n pass\n- except:\n- print sys.exc_info()[0],sys.exc_info()[1]\n+ except Exception, msg:\n+ print msg\n if v is None:\n compilers_na.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n", "added_lines": 4, "deleted_lines": 4, "source_code": "\"\"\"scipy_distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the Scipy_istutils Fortran compiler abstraction model.\n\n\"\"\"\n\nimport re\nimport os\nimport sys\nimport atexit\nfrom types import StringType, NoneType, ListType, TupleType\nfrom glob import glob\n\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import CCompiler, gen_lib_options\n# distutils.ccompiler provides the following functions:\n# gen_preprocess_options(macros, include_dirs)\n# gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.core import Command\nfrom distutils.util import split_quoted\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.version import LooseVersion\nfrom distutils.sysconfig import get_config_var\n\nfrom scipy_distutils.command.config_compiler import config_fc\n\nimport log\nfrom exec_command import find_executable, exec_command\n\n\nclass FCompiler(CCompiler):\n \"\"\" Abstract base class to define the interface that must be implemented\n by real Fortran compiler classes.\n\n Methods that subclasses may redefine:\n\n get_version_cmd(), get_linker_so(), get_version()\n get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()\n get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),\n get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),\n get_flags_arch_f90(), get_flags_debug_f90(),\n get_flags_fix(), get_flags_linker_so(), get_flags_version()\n\n DON'T call these methods (except get_version) after\n constructing a compiler instance or inside any other method.\n All methods, except get_version_cmd() and get_flags_version(), may\n call get_version() method.\n\n After constructing a compiler instance, always call customize(dist=None)\n method that finalizes compiler construction and makes the following\n attributes available:\n compiler_f77\n compiler_f90\n compiler_fix\n linker_so\n archiver\n ranlib\n libraries\n library_dirs\n \"\"\"\n # CCompiler defines the following attributes:\n # compiler_type\n # src_extensions\n # obj_extension\n # static_lib_extension\n # shared_lib_extension\n # static_lib_format\n # shared_lib_format\n # exe_extension\n # language_map ### REDEFINED\n # language_order ### REDEFINED\n # and the following public methods:\n # set_executables(**args)\n # set_executable(key,value)\n # define_macro(name, value=None)\n # undefine_macro(name)\n # add_include_dir(dir)\n # set_include_dirs(dirs)\n # add_library(libname)\n # set_libraries(libnames)\n # add_library_dir(dir)\n # set_library_dirs(dirs)\n # add_runtime_library_dir(dir)\n # set_runtime_library_dirs(dirs)\n # add_link_object(object)\n # set_link_objects(objects)\n #\n # detect_language(sources) ### USABLE\n #\n # preprocess(source,output_file=None,macros=None,include_dirs=None,\n # extra_preargs=None,extra_postargs=None)\n # compile(sources, output_dir=None, macros=None,\n # include_dirs=None, debug=0, extra_preargs=None,\n # extra_postargs=None, depends=None)\n # create_static_lib(objects,output_libname,output_dir=None,debug=0,target_lang=None):\n # link(target_desc, objects, output_filename, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None,\n # build_temp=None, target_lang=None)\n # link_shared_lib(objects, output_libname, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None,\n # extra_postargs=None, build_temp=None, target_lang=None)\n # link_shared_object(objects,output_filename,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # export_symbols=None,debug=0,extra_preargs=None,\n # extra_postargs=None,build_temp=None,target_lang=None)\n # link_executable(objects,output_progname,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # debug=0,extra_preargs=None,extra_postargs=None,target_lang=None)\n #\n # library_dir_option(dir)\n # runtime_library_dir_option(dir)\n # library_option(lib)\n # has_function(funcname,includes=None,include_dirs=None,\n # libraries=None,library_dirs=None)\n # find_library_file(dirs, lib, debug=0)\n #\n # object_filenames(source_filenames, strip_dir=0, output_dir='')\n # shared_object_filename(basename, strip_dir=0, output_dir='')\n # executable_filenamee(basename, strip_dir=0, output_dir='')\n # library_filename(libname, lib_type='static',strip_dir=0, output_dir=''):\n #\n # announce(msg, level=1)\n # debug_print(msg)\n # warn(msg)\n # execute(func, args, msg=None, level=1)\n # spawn(cmd)\n # move_file(src,dst)\n # mkpath(name, mode=0777)\n #\n\n language_map = {'.f':'f77',\n '.for':'f77',\n '.ftn':'f77',\n '.f77':'f77',\n '.f90':'f90',\n '.f95':'f90'}\n language_order = ['f90','f77']\n\n version_pattern = None\n\n executables = {\n 'version_cmd' : [\"f77\",\"-v\"],\n 'compiler_f77' : [\"f77\"],\n 'compiler_f90' : [\"f90\"],\n 'compiler_fix' : [\"f90\",\"-fixed\"],\n 'linker_so' : [\"f90\",\"-shared\"],\n #'linker_exe' : [\"f90\"], # XXX do we need it??\n 'archiver' : [\"ar\",\"-cr\"],\n 'ranlib' : None,\n }\n\n compile_switch = \"-c\"\n object_switch = \"-o \" # Ending space matters! It will be stripped\n # but if it is missing then object_switch\n # will be prefixed to object file name by\n # string concatenation.\n library_switch = \"-o \" # Ditto!\n\n # Switch to specify where module files are created and searched\n # for USE statement. Normally it is a string and also here ending\n # space matters. See above.\n module_dir_switch = None\n\n # Switch to specify where module files are searched for USE statement.\n module_include_switch = '-I' \n\n pic_flags = [] # Flags to create position-independent code\n\n src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95']\n obj_extension = \".o\"\n shared_lib_extension = get_config_var('SO') # or .dll\n static_lib_extension = \".a\" # or .lib\n static_lib_format = \"lib%s%s\" # or %s%s\n shared_lib_format = \"%s%s\"\n exe_extension = \"\"\n\n ######################################################################\n ## Methods that subclasses may redefine. But don't call these methods!\n ## They are private to FCompiler class and may return unexpected\n ## results if used elsewhere. So, you have been warned..\n\n def get_version_cmd(self):\n \"\"\" Compiler command to print out version information. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n cmd = self.executables['version_cmd']\n if cmd is not None:\n cmd = cmd[0]\n if cmd==f77:\n cmd = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if cmd==f90:\n cmd = self.compiler_f90[0]\n return cmd\n\n def get_linker_so(self):\n \"\"\" Linker command to build shared libraries. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n ln = self.executables['linker_so']\n if ln is not None:\n ln = ln[0]\n if ln==f77:\n ln = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if ln==f90:\n ln = self.compiler_f90[0]\n return ln\n\n def get_flags(self):\n \"\"\" List of flags common to all compiler types. \"\"\"\n return [] + self.pic_flags\n def get_flags_version(self):\n \"\"\" List of compiler flags to print out version information. \"\"\"\n if self.executables['version_cmd']:\n return self.executables['version_cmd'][1:]\n return []\n def get_flags_f77(self):\n \"\"\" List of Fortran 77 specific flags. \"\"\"\n if self.executables['compiler_f77']:\n return self.executables['compiler_f77'][1:]\n return []\n def get_flags_f90(self):\n \"\"\" List of Fortran 90 specific flags. \"\"\"\n if self.executables['compiler_f90']:\n return self.executables['compiler_f90'][1:]\n return []\n def get_flags_fix(self):\n \"\"\" List of Fortran 90 fixed format specific flags. \"\"\"\n if self.executables['compiler_fix']:\n return self.executables['compiler_fix'][1:]\n return []\n def get_flags_linker_so(self):\n \"\"\" List of linker flags to build a shared library. \"\"\"\n if self.executables['linker_so']:\n return self.executables['linker_so'][1:]\n return []\n def get_flags_ar(self):\n \"\"\" List of archiver flags. \"\"\"\n if self.executables['archiver']:\n return self.executables['archiver'][1:]\n return []\n def get_flags_opt(self):\n \"\"\" List of architecture independent compiler flags. \"\"\"\n return []\n def get_flags_arch(self):\n \"\"\" List of architecture dependent compiler flags. \"\"\"\n return []\n def get_flags_debug(self):\n \"\"\" List of compiler flags to compile with debugging information. \"\"\"\n return []\n get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt\n get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch\n get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug\n\n def get_libraries(self):\n \"\"\" List of compiler libraries. \"\"\"\n return self.libraries[:]\n def get_library_dirs(self):\n \"\"\" List of compiler library directories. \"\"\"\n return self.library_dirs[:]\n\n def get_version(self, force=0, ok_status=[0]):\n \"\"\" Compiler version. Returns None if compiler is not available. \"\"\"\n if not force and hasattr(self,'version'):\n return self.version\n\n cmd = ' '.join(self.version_cmd)\n status, output = self.exec_command(cmd,use_tee=0)\n version = None\n if status in ok_status:\n m = re.match(self.version_pattern,output)\n if m:\n version = m.group('version')\n assert version,`version`\n version = LooseVersion(version)\n self.version = version\n return version\n\n ############################################################\n\n ## Public methods:\n\n def customize(self, dist=None):\n \"\"\" Customize Fortran compiler.\n\n This method gets Fortran compiler specific information from\n (i) class definition, (ii) environment, (iii) distutils config\n files, and (iv) command line.\n\n This method should be always called after constructing a\n compiler instance. But not in __init__ because Distribution\n instance is needed for (iii) and (iv).\n \"\"\"\n if dist is None:\n # These hooks are for testing only!\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n conf = dist.get_option_dict('config_fc')\n\n noopt = conf.get('noopt',[None,0])[1]\n noarch = conf.get('noarch',[None,noopt])[1]\n debug = conf.get('debug',[None,0])[1]\n\n f77 = self.__get_cmd('compiler_f77','F77',(conf,'f77exec'))\n f90 = self.__get_cmd('compiler_f90','F90',(conf,'f90exec'))\n # Temporarily setting f77,f90 compilers so that\n # version_cmd can use their executables.\n if f77:\n self.set_executables(compiler_f77=[f77])\n if f90:\n self.set_executables(compiler_f90=[f90])\n\n # Must set version_cmd before others as self.get_flags*\n # methods may call self.get_version.\n vers_cmd = self.__get_cmd(self.get_version_cmd)\n if vers_cmd:\n vflags = self.__get_flags(self.get_flags_version)\n self.set_executables(version_cmd=[vers_cmd]+vflags)\n\n if f77:\n f77flags = self.__get_flags(self.get_flags_f77,'F77FLAGS',\n (conf,'f77flags'))\n if f90:\n f90flags = self.__get_flags(self.get_flags_f90,'F90FLAGS',\n (conf,'f90flags'))\n\n # XXX Assuming that free format is default for f90 compiler.\n fix = self.__get_cmd('compiler_fix','F90',(conf,'f90exec'))\n if fix:\n fixflags = self.__get_flags(self.get_flags_fix) + f90flags\n\n oflags,aflags,dflags = [],[],[]\n if not noopt:\n oflags = self.__get_flags(self.get_flags_opt,'FOPT',(conf,'opt'))\n if f77 and self.get_flags_opt is not self.get_flags_opt_f77:\n f77flags += self.__get_flags(self.get_flags_opt_f77)\n if f90 and self.get_flags_opt is not self.get_flags_opt_f90:\n f90flags += self.__get_flags(self.get_flags_opt_f90)\n if fix and self.get_flags_opt is not self.get_flags_opt_f90:\n fixflags += self.__get_flags(self.get_flags_opt_f90)\n if not noarch:\n aflags = self.__get_flags(self.get_flags_arch,'FARCH',\n (conf,'arch'))\n if f77 and self.get_flags_arch is not self.get_flags_arch_f77:\n f77flags += self.__get_flags(self.get_flags_arch_f77)\n if f90 and self.get_flags_arch is not self.get_flags_arch_f90:\n f90flags += self.__get_flags(self.get_flags_arch_f90)\n if fix and self.get_flags_arch is not self.get_flags_arch_f90:\n fixflags += self.__get_flags(self.get_flags_arch_f90)\n if debug:\n dflags = self.__get_flags(self.get_flags_debug,'FDEBUG')\n if f77 and self.get_flags_debug is not self.get_flags_debug_f77:\n f77flags += self.__get_flags(self.get_flags_debug_f77)\n if f90 and self.get_flags_debug is not self.get_flags_debug_f90:\n f90flags += self.__get_flags(self.get_flags_debug_f90)\n if fix and self.get_flags_debug is not self.get_flags_debug_f90:\n fixflags += self.__get_flags(self.get_flags_debug_f90)\n\n fflags = self.__get_flags(self.get_flags,'FFLAGS') \\\n + dflags + oflags + aflags\n\n if f77:\n self.set_executables(compiler_f77=[f77]+f77flags+fflags)\n if f90:\n self.set_executables(compiler_f90=[f90]+f90flags+fflags)\n if fix:\n self.set_executables(compiler_fix=[fix]+fixflags+fflags)\n\n #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS\n linker_so = self.__get_cmd(self.get_linker_so,'LDSHARED')\n if linker_so:\n linker_so_flags = self.__get_flags(self.get_flags_linker_so,'LDFLAGS')\n self.set_executables(linker_so=[linker_so]+linker_so_flags)\n\n ar = self.__get_cmd('archiver','AR')\n if ar:\n arflags = self.__get_flags(self.get_flags_ar,'ARFLAGS')\n self.set_executables(archiver=[ar]+arflags)\n\n ranlib = self.__get_cmd('ranlib','RANLIB')\n if ranlib:\n self.set_executables(ranlib=[ranlib])\n\n self.set_library_dirs(self.get_library_dirs())\n self.set_libraries(self.get_libraries())\n\n verbose = conf.get('verbose',[None,0])[1]\n if verbose:\n self.dump_properties()\n return\n\n def customize_cmd(self, cmd):\n if cmd.include_dirs is not None:\n self.set_include_dirs(cmd.include_dirs)\n if cmd.define is not None:\n for (name,value) in cmd.define:\n self.define_macro(name, value)\n if cmd.undef is not None:\n for macro in cmd.undef:\n self.undefine_macro(macro)\n if cmd.libraries is not None:\n self.set_libraries(self.get_libraries() + cmd.libraries)\n if cmd.library_dirs is not None:\n self.set_library_dirs(self.get_library_dirs() + cmd.library_dirs)\n if cmd.rpath is not None:\n self.set_runtime_library_dirs(cmd.rpath)\n if cmd.link_objects is not None:\n self.set_link_objects(cmd.link_objects)\n return\n \n def dump_properties(self):\n \"\"\" Print out the attributes of a compiler instance. \"\"\"\n props = []\n for key in self.executables.keys() + \\\n ['version','libraries','library_dirs',\n 'object_switch','compile_switch']:\n if hasattr(self,key):\n v = getattr(self,key)\n props.append((key, None, '= '+`v`))\n props.sort()\n\n pretty_printer = FancyGetopt(props)\n for l in pretty_printer.generate_help(\"%s instance properties:\" \\\n % (self.__class__.__name__)):\n if l[:4]==' --':\n l = ' ' + l[4:]\n print l\n return\n\n def exec_command(self,*args,**kws):\n \"\"\" Return status,output of a command. \"\"\"\n quiet = kws.get('quiet',1)\n try: del kws['quiet']\n except KeyError: pass\n if not quiet:\n log.info('%s.exec_command(*%s,**%s)' % (self.__class__.__name__,\n args,kws))\n status, output = exec_command(*args,**kws)\n if not quiet:\n log.info('*****status:%s\\n*****output:\\n%s\\n*****' % (status,output))\n return status, output\n\n def spawn(self, cmd):\n s,o = self.exec_command(cmd)\n assert not s,`s`\n\n\n ###################\n\n def _get_cc_args(self, pp_opts, debug, before):\n #XXX\n #print self.__class__.__name__ + '._get_cc_args:',pp_opts, debug, before\n return []\n\n def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):\n \"\"\"Compile 'src' to product 'obj'.\"\"\"\n #print self.__class__.__name__ + '._compile:',obj, src, ext, cc_args, extra_postargs, pp_opts\n\n if is_f_file(src):\n compiler = self.compiler_f77\n elif is_free_format(src):\n compiler = self.compiler_f90\n if compiler is None:\n raise DistutilsExecError, 'f90 not supported by '\\\n +self.__class__.__name__\n else:\n compiler = self.compiler_fix\n if compiler is None:\n raise DistutilsExecError, 'f90 (fixed) not supported by '\\\n +self.__class__.__name__\n if self.object_switch[-1]==' ':\n o_args = [self.object_switch.strip(),obj]\n else:\n o_args = [self.object_switch.strip()+obj]\n\n assert self.compile_switch.strip()\n s_args = [self.compile_switch, src]\n\n command = compiler + cc_args + pp_opts + s_args + o_args + extra_postargs\n log.info(' '.join(command))\n try:\n s,o = self.exec_command(command)\n except DistutilsExecError, msg:\n raise CompileError, msg\n if s:\n raise CompileError, o\n\n return\n\n def module_options(self, module_dirs, module_build_dir):\n options = []\n if self.module_dir_switch is not None:\n if self.module_dir_switch[-1]==' ':\n options.extend([self.module_dir_switch.strip(),module_build_dir])\n else:\n options.append(self.module_dir_switch.strip()+module_build_dir)\n else:\n print 'XXX: module_build_dir=%r option ignored' % (module_build_dir)\n print 'XXX: Fix module_dir_switch for ',self.__class__.__name__\n if self.module_include_switch is not None:\n for d in [module_build_dir]+module_dirs:\n options.append('%s%s' % (self.module_include_switch, d))\n else:\n print 'XXX: module_dirs=%r option ignored' % (module_dirs)\n print 'XXX: Fix module_include_switch for ',self.__class__.__name__\n return options\n\n def library_option(self, lib):\n return \"-l\" + lib\n def library_dir_option(self, dir):\n return \"-L\" + dir\n\n if sys.version[:3]<'2.3':\n def compile(self, sources, output_dir=None, macros=None,\n include_dirs=None, debug=0, extra_preargs=None,\n extra_postargs=None, depends=None):\n if output_dir is None: output_dir = self.output_dir\n if macros is None: macros = self.macros\n elif type(macros) is ListType: macros = macros + (self.macros or [])\n if include_dirs is None: include_dirs = self.include_dirs\n elif type(include_dirs) in (ListType, TupleType):\n include_dirs = list(include_dirs) + (self.include_dirs or [])\n if extra_preargs is None: extra_preargs=[]\n from distutils.sysconfig import python_build\n objects = self.object_filenames(sources,strip_dir=python_build,\n output_dir=output_dir)\n from distutils.ccompiler import gen_preprocess_options\n pp_opts = gen_preprocess_options(macros, include_dirs)\n build = {}\n for i in range(len(sources)):\n src,obj = sources[i],objects[i]\n ext = os.path.splitext(src)[1]\n self.mkpath(os.path.dirname(obj))\n build[obj] = src, ext\n cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)\n for obj, (src, ext) in build.items():\n self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)\n return objects\n def detect_language(self, sources):\n return\n\n def link(self, target_desc, objects,\n output_filename, output_dir=None, libraries=None,\n library_dirs=None, runtime_library_dirs=None,\n export_symbols=None, debug=0, extra_preargs=None,\n extra_postargs=None, build_temp=None, target_lang=None):\n objects, output_dir = self._fix_object_args(objects, output_dir)\n libraries, library_dirs, runtime_library_dirs = \\\n self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)\n\n lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,\n libraries)\n if type(output_dir) not in (StringType, NoneType):\n raise TypeError, \"'output_dir' must be a string or None\"\n if output_dir is not None:\n output_filename = os.path.join(output_dir, output_filename)\n\n if self._need_link(objects, output_filename):\n if self.library_switch[-1]==' ':\n o_args = [self.library_switch.strip(),output_filename]\n else:\n o_args = [self.library_switch.strip()+output_filename]\n ld_args = (objects + self.objects +\n lib_opts + o_args)\n #if debug:\n # ld_args[:0] = ['-g']\n if extra_preargs:\n ld_args[:0] = extra_preargs\n if extra_postargs:\n ld_args.extend(extra_postargs)\n self.mkpath(os.path.dirname(output_filename))\n if target_desc == CCompiler.EXECUTABLE:\n raise NotImplementedError,self.__class__.__name__+'.linker_exe attribute'\n else:\n linker = self.linker_so[:]\n command = linker + ld_args\n log.info(' '.join(command))\n try:\n s,o = self.exec_command(command)\n except DistutilsExecError, msg:\n raise LinkError, msg\n if s:\n raise LinkError, o\n else:\n log.debug(\"skipping %s (up-to-date)\", output_filename)\n return\n\n ############################################################\n\n ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif type(command) is type(''):\n var = self.executables[command]\n if var is not None:\n var = var[0]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n return var\n\n def __get_flags(self, command, envvar=None, confvar=None):\n if command is None:\n var = []\n elif type(command) is type(''):\n var = self.executables[command][1:]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n if type(var) is type(''):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\n##############################################################################\n\nfcompiler_class = {'gnu':('gnufcompiler','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'pg':('pgfcompiler','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoftfcompiler','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mipsfcompiler','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sunfcompiler','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intelfcompiler','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intelfcompiler','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intelfcompiler','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intelfcompiler','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nagfcompiler','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaqfcompiler','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaqfcompiler','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vastfcompiler','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpuxfcompiler','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('laheyfcompiler','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'f':('fcompiler','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelitanium')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelitanium')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intelitanium')),\n ('sunos.*',('forte','gnu','sun')),\n ('irix',('mips','gnu')),\n # OS mappings\n ('posix',('gnu',)),\n ('nt',('gnu',)),\n ('mac',('gnu',)),\n )\n\ndef get_default_fcompiler(osname=None, platform=None):\n \"\"\" Determine the default Fortran compiler to use for the given platform. \"\"\"\n if osname is None:\n osname = os.name\n if platform is None:\n platform = sys.platform\n for pattern, compiler in _default_compilers:\n if re.match(pattern, platform) is not None or \\\n re.match(pattern, osname) is not None:\n if type(compiler) is type(()):\n return compiler[0]\n return compiler\n return 'gnu'\n\ndef new_fcompiler(plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n \"\"\" Generate an instance of some FCompiler subclass for the supplied\n platform/compiler combination.\n \"\"\"\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_fcompiler(plat)\n (module_name, class_name, long_description) = fcompiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile Fortran code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler.\" % compiler\n msg = msg + \" Supported compilers are: %s)\" \\\n % (','.join(fcompiler_class.keys()))\n raise DistutilsPlatformError, msg\n\n try:\n module_name = 'scipy_distutils.'+module_name\n __import__ (module_name)\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile Fortran code: unable to load module '%s'\" % \\\n module_name\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile Fortran code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n print '*'*80\n print klass\n print '*'*80\n return klass(None, dry_run, force)\n\n\ndef show_fcompilers(dist = None):\n \"\"\" Print list of available compilers (used by the \"--help-fcompiler\"\n option to \"config_fc\").\n \"\"\"\n if dist is None:\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n compilers = []\n compilers_na = []\n compilers_ni = []\n for compiler in fcompiler_class.keys():\n v = 'N/A'\n try:\n c = new_fcompiler(compiler=compiler)\n c.customize(dist)\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n print msg\n if v is None:\n compilers_na.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n elif v=='N/A':\n compilers_ni.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n else:\n compilers.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2] + ' (%s)' % v))\n compilers.sort()\n compilers_na.sort()\n pretty_printer = FancyGetopt(compilers)\n pretty_printer.print_help(\"List of available Fortran compilers:\")\n pretty_printer = FancyGetopt(compilers_na)\n pretty_printer.print_help(\"List of unavailable Fortran compilers:\")\n if compilers_ni:\n pretty_printer = FancyGetopt(compilers_ni)\n pretty_printer.print_help(\"List of unimplemented Fortran compilers:\")\n print \"For compiler details, run 'config_fc --verbose' setup command.\"\n\ndef dummy_fortran_file():\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n def rm_file(name=dummy_name,log_threshold=log._global_log.threshold):\n save_th = log._global_log.threshold\n log.set_threshold(log_threshold)\n try: os.remove(name+'.f'); log.debug('removed '+name+'.f')\n except OSError: pass\n try: os.remove(name+'.o'); log.debug('removed '+name+'.o')\n except OSError: pass\n log.set_threshold(save_th)\n atexit.register(rm_file)\n return dummy_name\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15 # the number of non-comment lines to scan for hints\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nif __name__ == '__main__':\n show_fcompilers()\n", "source_code_before": "\"\"\"scipy_distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the Scipy_istutils Fortran compiler abstraction model.\n\n\"\"\"\n\nimport re\nimport os\nimport sys\nimport atexit\nfrom types import StringType, NoneType, ListType, TupleType\nfrom glob import glob\n\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import CCompiler, gen_lib_options\n# distutils.ccompiler provides the following functions:\n# gen_preprocess_options(macros, include_dirs)\n# gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.core import Command\nfrom distutils.util import split_quoted\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.version import LooseVersion\nfrom distutils.sysconfig import get_config_var\n\nfrom scipy_distutils.command.config_compiler import config_fc\n\nimport log\nfrom exec_command import find_executable, exec_command\n\n\nclass FCompiler(CCompiler):\n \"\"\" Abstract base class to define the interface that must be implemented\n by real Fortran compiler classes.\n\n Methods that subclasses may redefine:\n\n get_version_cmd(), get_linker_so(), get_version()\n get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()\n get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),\n get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),\n get_flags_arch_f90(), get_flags_debug_f90(),\n get_flags_fix(), get_flags_linker_so(), get_flags_version()\n\n DON'T call these methods (except get_version) after\n constructing a compiler instance or inside any other method.\n All methods, except get_version_cmd() and get_flags_version(), may\n call get_version() method.\n\n After constructing a compiler instance, always call customize(dist=None)\n method that finalizes compiler construction and makes the following\n attributes available:\n compiler_f77\n compiler_f90\n compiler_fix\n linker_so\n archiver\n ranlib\n libraries\n library_dirs\n \"\"\"\n # CCompiler defines the following attributes:\n # compiler_type\n # src_extensions\n # obj_extension\n # static_lib_extension\n # shared_lib_extension\n # static_lib_format\n # shared_lib_format\n # exe_extension\n # language_map ### REDEFINED\n # language_order ### REDEFINED\n # and the following public methods:\n # set_executables(**args)\n # set_executable(key,value)\n # define_macro(name, value=None)\n # undefine_macro(name)\n # add_include_dir(dir)\n # set_include_dirs(dirs)\n # add_library(libname)\n # set_libraries(libnames)\n # add_library_dir(dir)\n # set_library_dirs(dirs)\n # add_runtime_library_dir(dir)\n # set_runtime_library_dirs(dirs)\n # add_link_object(object)\n # set_link_objects(objects)\n #\n # detect_language(sources) ### USABLE\n #\n # preprocess(source,output_file=None,macros=None,include_dirs=None,\n # extra_preargs=None,extra_postargs=None)\n # compile(sources, output_dir=None, macros=None,\n # include_dirs=None, debug=0, extra_preargs=None,\n # extra_postargs=None, depends=None)\n # create_static_lib(objects,output_libname,output_dir=None,debug=0,target_lang=None):\n # link(target_desc, objects, output_filename, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None,\n # build_temp=None, target_lang=None)\n # link_shared_lib(objects, output_libname, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None,\n # extra_postargs=None, build_temp=None, target_lang=None)\n # link_shared_object(objects,output_filename,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # export_symbols=None,debug=0,extra_preargs=None,\n # extra_postargs=None,build_temp=None,target_lang=None)\n # link_executable(objects,output_progname,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # debug=0,extra_preargs=None,extra_postargs=None,target_lang=None)\n #\n # library_dir_option(dir)\n # runtime_library_dir_option(dir)\n # library_option(lib)\n # has_function(funcname,includes=None,include_dirs=None,\n # libraries=None,library_dirs=None)\n # find_library_file(dirs, lib, debug=0)\n #\n # object_filenames(source_filenames, strip_dir=0, output_dir='')\n # shared_object_filename(basename, strip_dir=0, output_dir='')\n # executable_filenamee(basename, strip_dir=0, output_dir='')\n # library_filename(libname, lib_type='static',strip_dir=0, output_dir=''):\n #\n # announce(msg, level=1)\n # debug_print(msg)\n # warn(msg)\n # execute(func, args, msg=None, level=1)\n # spawn(cmd)\n # move_file(src,dst)\n # mkpath(name, mode=0777)\n #\n\n language_map = {'.f':'f77',\n '.for':'f77',\n '.ftn':'f77',\n '.f77':'f77',\n '.f90':'f90',\n '.f95':'f90'}\n language_order = ['f90','f77']\n\n version_pattern = None\n\n executables = {\n 'version_cmd' : [\"f77\",\"-v\"],\n 'compiler_f77' : [\"f77\"],\n 'compiler_f90' : [\"f90\"],\n 'compiler_fix' : [\"f90\",\"-fixed\"],\n 'linker_so' : [\"f90\",\"-shared\"],\n #'linker_exe' : [\"f90\"], # XXX do we need it??\n 'archiver' : [\"ar\",\"-cr\"],\n 'ranlib' : None,\n }\n\n compile_switch = \"-c\"\n object_switch = \"-o \" # Ending space matters! It will be stripped\n # but if it is missing then object_switch\n # will be prefixed to object file name by\n # string concatenation.\n library_switch = \"-o \" # Ditto!\n\n # Switch to specify where module files are created and searched\n # for USE statement. Normally it is a string and also here ending\n # space matters. See above.\n module_dir_switch = None\n\n # Switch to specify where module files are searched for USE statement.\n module_include_switch = '-I' \n\n pic_flags = [] # Flags to create position-independent code\n\n src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95']\n obj_extension = \".o\"\n shared_lib_extension = get_config_var('SO') # or .dll\n static_lib_extension = \".a\" # or .lib\n static_lib_format = \"lib%s%s\" # or %s%s\n shared_lib_format = \"%s%s\"\n exe_extension = \"\"\n\n ######################################################################\n ## Methods that subclasses may redefine. But don't call these methods!\n ## They are private to FCompiler class and may return unexpected\n ## results if used elsewhere. So, you have been warned..\n\n def get_version_cmd(self):\n \"\"\" Compiler command to print out version information. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n cmd = self.executables['version_cmd']\n if cmd is not None:\n cmd = cmd[0]\n if cmd==f77:\n cmd = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if cmd==f90:\n cmd = self.compiler_f90[0]\n return cmd\n\n def get_linker_so(self):\n \"\"\" Linker command to build shared libraries. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n ln = self.executables['linker_so']\n if ln is not None:\n ln = ln[0]\n if ln==f77:\n ln = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if ln==f90:\n ln = self.compiler_f90[0]\n return ln\n\n def get_flags(self):\n \"\"\" List of flags common to all compiler types. \"\"\"\n return [] + self.pic_flags\n def get_flags_version(self):\n \"\"\" List of compiler flags to print out version information. \"\"\"\n if self.executables['version_cmd']:\n return self.executables['version_cmd'][1:]\n return []\n def get_flags_f77(self):\n \"\"\" List of Fortran 77 specific flags. \"\"\"\n if self.executables['compiler_f77']:\n return self.executables['compiler_f77'][1:]\n return []\n def get_flags_f90(self):\n \"\"\" List of Fortran 90 specific flags. \"\"\"\n if self.executables['compiler_f90']:\n return self.executables['compiler_f90'][1:]\n return []\n def get_flags_fix(self):\n \"\"\" List of Fortran 90 fixed format specific flags. \"\"\"\n if self.executables['compiler_fix']:\n return self.executables['compiler_fix'][1:]\n return []\n def get_flags_linker_so(self):\n \"\"\" List of linker flags to build a shared library. \"\"\"\n if self.executables['linker_so']:\n return self.executables['linker_so'][1:]\n return []\n def get_flags_ar(self):\n \"\"\" List of archiver flags. \"\"\"\n if self.executables['archiver']:\n return self.executables['archiver'][1:]\n return []\n def get_flags_opt(self):\n \"\"\" List of architecture independent compiler flags. \"\"\"\n return []\n def get_flags_arch(self):\n \"\"\" List of architecture dependent compiler flags. \"\"\"\n return []\n def get_flags_debug(self):\n \"\"\" List of compiler flags to compile with debugging information. \"\"\"\n return []\n get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt\n get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch\n get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug\n\n def get_libraries(self):\n \"\"\" List of compiler libraries. \"\"\"\n return self.libraries[:]\n def get_library_dirs(self):\n \"\"\" List of compiler library directories. \"\"\"\n return self.library_dirs[:]\n\n def get_version(self, force=0, ok_status=[0]):\n \"\"\" Compiler version. Returns None if compiler is not available. \"\"\"\n if not force and hasattr(self,'version'):\n return self.version\n\n cmd = ' '.join(self.version_cmd)\n status, output = self.exec_command(cmd,use_tee=0)\n version = None\n if status in ok_status:\n m = re.match(self.version_pattern,output)\n if m:\n version = m.group('version')\n assert version,`version`\n version = LooseVersion(version)\n self.version = version\n return version\n\n ############################################################\n\n ## Public methods:\n\n def customize(self, dist=None):\n \"\"\" Customize Fortran compiler.\n\n This method gets Fortran compiler specific information from\n (i) class definition, (ii) environment, (iii) distutils config\n files, and (iv) command line.\n\n This method should be always called after constructing a\n compiler instance. But not in __init__ because Distribution\n instance is needed for (iii) and (iv).\n \"\"\"\n if dist is None:\n # These hooks are for testing only!\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n conf = dist.get_option_dict('config_fc')\n\n noopt = conf.get('noopt',[None,0])[1]\n noarch = conf.get('noarch',[None,noopt])[1]\n debug = conf.get('debug',[None,0])[1]\n\n f77 = self.__get_cmd('compiler_f77','F77',(conf,'f77exec'))\n f90 = self.__get_cmd('compiler_f90','F90',(conf,'f90exec'))\n # Temporarily setting f77,f90 compilers so that\n # version_cmd can use their executables.\n if f77:\n self.set_executables(compiler_f77=[f77])\n if f90:\n self.set_executables(compiler_f90=[f90])\n\n # Must set version_cmd before others as self.get_flags*\n # methods may call self.get_version.\n vers_cmd = self.__get_cmd(self.get_version_cmd)\n if vers_cmd:\n vflags = self.__get_flags(self.get_flags_version)\n self.set_executables(version_cmd=[vers_cmd]+vflags)\n\n if f77:\n f77flags = self.__get_flags(self.get_flags_f77,'F77FLAGS',\n (conf,'f77flags'))\n if f90:\n f90flags = self.__get_flags(self.get_flags_f90,'F90FLAGS',\n (conf,'f90flags'))\n\n # XXX Assuming that free format is default for f90 compiler.\n fix = self.__get_cmd('compiler_fix','F90',(conf,'f90exec'))\n if fix:\n fixflags = self.__get_flags(self.get_flags_fix) + f90flags\n\n oflags,aflags,dflags = [],[],[]\n if not noopt:\n oflags = self.__get_flags(self.get_flags_opt,'FOPT',(conf,'opt'))\n if f77 and self.get_flags_opt is not self.get_flags_opt_f77:\n f77flags += self.__get_flags(self.get_flags_opt_f77)\n if f90 and self.get_flags_opt is not self.get_flags_opt_f90:\n f90flags += self.__get_flags(self.get_flags_opt_f90)\n if fix and self.get_flags_opt is not self.get_flags_opt_f90:\n fixflags += self.__get_flags(self.get_flags_opt_f90)\n if not noarch:\n aflags = self.__get_flags(self.get_flags_arch,'FARCH',\n (conf,'arch'))\n if f77 and self.get_flags_arch is not self.get_flags_arch_f77:\n f77flags += self.__get_flags(self.get_flags_arch_f77)\n if f90 and self.get_flags_arch is not self.get_flags_arch_f90:\n f90flags += self.__get_flags(self.get_flags_arch_f90)\n if fix and self.get_flags_arch is not self.get_flags_arch_f90:\n fixflags += self.__get_flags(self.get_flags_arch_f90)\n if debug:\n dflags = self.__get_flags(self.get_flags_debug,'FDEBUG')\n if f77 and self.get_flags_debug is not self.get_flags_debug_f77:\n f77flags += self.__get_flags(self.get_flags_debug_f77)\n if f90 and self.get_flags_debug is not self.get_flags_debug_f90:\n f90flags += self.__get_flags(self.get_flags_debug_f90)\n if fix and self.get_flags_debug is not self.get_flags_debug_f90:\n fixflags += self.__get_flags(self.get_flags_debug_f90)\n\n fflags = self.__get_flags(self.get_flags,'FFLAGS') \\\n + dflags + oflags + aflags\n\n if f77:\n self.set_executables(compiler_f77=[f77]+f77flags+fflags)\n if f90:\n self.set_executables(compiler_f90=[f90]+f90flags+fflags)\n if fix:\n self.set_executables(compiler_fix=[fix]+fixflags+fflags)\n\n #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS\n linker_so = self.__get_cmd(self.get_linker_so,'LDSHARED')\n if linker_so:\n linker_so_flags = self.__get_flags(self.get_flags_linker_so,'LDFLAGS')\n self.set_executables(linker_so=[linker_so]+linker_so_flags)\n\n ar = self.__get_cmd('archiver','AR')\n if ar:\n arflags = self.__get_flags(self.get_flags_ar,'ARFLAGS')\n self.set_executables(archiver=[ar]+arflags)\n\n ranlib = self.__get_cmd('ranlib','RANLIB')\n if ranlib:\n self.set_executables(ranlib=[ranlib])\n\n self.set_library_dirs(self.get_library_dirs())\n self.set_libraries(self.get_libraries())\n\n verbose = conf.get('verbose',[None,0])[1]\n if verbose:\n self.dump_properties()\n return\n\n def customize_cmd(self, cmd):\n if cmd.include_dirs is not None:\n self.set_include_dirs(cmd.include_dirs)\n if cmd.define is not None:\n for (name,value) in cmd.define:\n self.define_macro(name, value)\n if cmd.undef is not None:\n for macro in cmd.undef:\n self.undefine_macro(macro)\n if cmd.libraries is not None:\n self.set_libraries(self.get_libraries() + cmd.libraries)\n if cmd.library_dirs is not None:\n self.set_library_dirs(self.get_library_dirs() + cmd.library_dirs)\n if cmd.rpath is not None:\n self.set_runtime_library_dirs(cmd.rpath)\n if cmd.link_objects is not None:\n self.set_link_objects(cmd.link_objects)\n return\n \n def dump_properties(self):\n \"\"\" Print out the attributes of a compiler instance. \"\"\"\n props = []\n for key in self.executables.keys() + \\\n ['version','libraries','library_dirs',\n 'object_switch','compile_switch']:\n if hasattr(self,key):\n v = getattr(self,key)\n props.append((key, None, '= '+`v`))\n props.sort()\n\n pretty_printer = FancyGetopt(props)\n for l in pretty_printer.generate_help(\"%s instance properties:\" \\\n % (self.__class__.__name__)):\n if l[:4]==' --':\n l = ' ' + l[4:]\n print l\n return\n\n def exec_command(self,*args,**kws):\n \"\"\" Return status,output of a command. \"\"\"\n quiet = kws.get('quiet',1)\n try: del kws['quiet']\n except KeyError: pass\n if not quiet:\n log.info('%s.exec_command(*%s,**%s)' % (self.__class__.__name__,\n args,kws))\n status, output = exec_command(*args,**kws)\n if not quiet:\n log.info('*****status:%s\\n*****output:\\n%s\\n*****' % (status,output))\n return status, output\n\n def spawn(self, cmd):\n s,o = self.exec_command(cmd)\n assert not s,`s`\n\n\n ###################\n\n def _get_cc_args(self, pp_opts, debug, before):\n #XXX\n print self.__class__.__name__ + '._get_cc_args:',pp_opts, debug, before\n return []\n\n def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):\n \"\"\"Compile 'src' to product 'obj'.\"\"\"\n print self.__class__.__name__ + '._compile:',obj, src, ext, cc_args, extra_postargs, pp_opts\n\n if is_f_file(src):\n compiler = self.compiler_f77\n elif is_free_format(src):\n compiler = self.compiler_f90\n if compiler is None:\n raise DistutilsExecError, 'f90 not supported by '\\\n +self.__class__.__name__\n else:\n compiler = self.compiler_fix\n if compiler is None:\n raise DistutilsExecError, 'f90 (fixed) not supported by '\\\n +self.__class__.__name__\n if self.object_switch[-1]==' ':\n o_args = [self.object_switch.strip(),obj]\n else:\n o_args = [self.object_switch.strip()+obj]\n\n assert self.compile_switch.strip()\n s_args = [self.compile_switch, src]\n\n command = compiler + cc_args + pp_opts + s_args + o_args + extra_postargs\n log.info(' '.join(command))\n try:\n s,o = self.exec_command(command)\n except DistutilsExecError, msg:\n raise CompileError, msg\n if s:\n raise CompileError, o\n\n return\n\n def module_options(self, module_dirs, module_build_dir):\n options = []\n if self.module_dir_switch is not None:\n if self.module_dir_switch[-1]==' ':\n options.extend([self.module_dir_switch.strip(),module_build_dir])\n else:\n options.append(self.module_dir_switch.strip()+module_build_dir)\n else:\n print 'XXX: module_build_dir=%r option ignored' % (module_build_dir)\n print 'XXX: Fix module_dir_switch for ',self.__class__.__name__\n if self.module_include_switch is not None:\n for d in [module_build_dir]+module_dirs:\n options.append('%s%s' % (self.module_include_switch, d))\n else:\n print 'XXX: module_dirs=%r option ignored' % (module_dirs)\n print 'XXX: Fix module_include_switch for ',self.__class__.__name__\n return options\n\n def library_option(self, lib):\n return \"-l\" + lib\n def library_dir_option(self, dir):\n return \"-L\" + dir\n\n if sys.version[:3]<'2.3':\n def compile(self, sources, output_dir=None, macros=None,\n include_dirs=None, debug=0, extra_preargs=None,\n extra_postargs=None, depends=None):\n if output_dir is None: output_dir = self.output_dir\n if macros is None: macros = self.macros\n elif type(macros) is ListType: macros = macros + (self.macros or [])\n if include_dirs is None: include_dirs = self.include_dirs\n elif type(include_dirs) in (ListType, TupleType):\n include_dirs = list(include_dirs) + (self.include_dirs or [])\n if extra_preargs is None: extra_preargs=[]\n from distutils.sysconfig import python_build\n objects = self.object_filenames(sources,strip_dir=python_build,\n output_dir=output_dir)\n from distutils.ccompiler import gen_preprocess_options\n pp_opts = gen_preprocess_options(macros, include_dirs)\n build = {}\n for i in range(len(sources)):\n src,obj = sources[i],objects[i]\n ext = os.path.splitext(src)[1]\n self.mkpath(os.path.dirname(obj))\n build[obj] = src, ext\n cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)\n for obj, (src, ext) in build.items():\n self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)\n return objects\n def detect_language(self, sources):\n return\n\n def link(self, target_desc, objects,\n output_filename, output_dir=None, libraries=None,\n library_dirs=None, runtime_library_dirs=None,\n export_symbols=None, debug=0, extra_preargs=None,\n extra_postargs=None, build_temp=None, target_lang=None):\n objects, output_dir = self._fix_object_args(objects, output_dir)\n libraries, library_dirs, runtime_library_dirs = \\\n self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)\n\n lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,\n libraries)\n if type(output_dir) not in (StringType, NoneType):\n raise TypeError, \"'output_dir' must be a string or None\"\n if output_dir is not None:\n output_filename = os.path.join(output_dir, output_filename)\n\n if self._need_link(objects, output_filename):\n if self.library_switch[-1]==' ':\n o_args = [self.library_switch.strip(),output_filename]\n else:\n o_args = [self.library_switch.strip()+output_filename]\n ld_args = (objects + self.objects +\n lib_opts + o_args)\n #if debug:\n # ld_args[:0] = ['-g']\n if extra_preargs:\n ld_args[:0] = extra_preargs\n if extra_postargs:\n ld_args.extend(extra_postargs)\n self.mkpath(os.path.dirname(output_filename))\n if target_desc == CCompiler.EXECUTABLE:\n raise NotImplementedError,self.__class__.__name__+'.linker_exe attribute'\n else:\n linker = self.linker_so[:]\n command = linker + ld_args\n log.info(' '.join(command))\n try:\n s,o = self.exec_command(command)\n except DistutilsExecError, msg:\n raise LinkError, msg\n if s:\n raise LinkError, o\n else:\n log.debug(\"skipping %s (up-to-date)\", output_filename)\n return\n\n ############################################################\n\n ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif type(command) is type(''):\n var = self.executables[command]\n if var is not None:\n var = var[0]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n return var\n\n def __get_flags(self, command, envvar=None, confvar=None):\n if command is None:\n var = []\n elif type(command) is type(''):\n var = self.executables[command][1:]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n if type(var) is type(''):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\n##############################################################################\n\nfcompiler_class = {'gnu':('gnufcompiler','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'pg':('pgfcompiler','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoftfcompiler','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mipsfcompiler','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sunfcompiler','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intelfcompiler','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intelfcompiler','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intelfcompiler','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intelfcompiler','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nagfcompiler','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaqfcompiler','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaqfcompiler','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vastfcompiler','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpuxfcompiler','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('laheyfcompiler','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'f':('fcompiler','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelitanium')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelitanium')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intelitanium')),\n ('sunos.*',('forte','gnu','sun')),\n ('irix',('mips','gnu')),\n # OS mappings\n ('posix',('gnu',)),\n ('nt',('gnu',)),\n ('mac',('gnu',)),\n )\n\ndef get_default_fcompiler(osname=None, platform=None):\n \"\"\" Determine the default Fortran compiler to use for the given platform. \"\"\"\n if osname is None:\n osname = os.name\n if platform is None:\n platform = sys.platform\n for pattern, compiler in _default_compilers:\n if re.match(pattern, platform) is not None or \\\n re.match(pattern, osname) is not None:\n if type(compiler) is type(()):\n return compiler[0]\n return compiler\n return 'gnu'\n\ndef new_fcompiler(plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n \"\"\" Generate an instance of some FCompiler subclass for the supplied\n platform/compiler combination.\n \"\"\"\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_fcompiler(plat)\n (module_name, class_name, long_description) = fcompiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile Fortran code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler.\" % compiler\n msg = msg + \" Supported compilers are: %s)\" \\\n % (','.join(fcompiler_class.keys()))\n raise DistutilsPlatformError, msg\n\n try:\n module_name = 'scipy_distutils.'+module_name\n __import__ (module_name)\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile Fortran code: unable to load module '%s'\" % \\\n module_name\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile Fortran code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n print '*'*80\n print klass\n print '*'*80\n return klass(None, dry_run, force)\n\n\ndef show_fcompilers(dist = None):\n \"\"\" Print list of available compilers (used by the \"--help-fcompiler\"\n option to \"config_fc\").\n \"\"\"\n if dist is None:\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n compilers = []\n compilers_na = []\n compilers_ni = []\n for compiler in fcompiler_class.keys():\n v = 'N/A'\n try:\n c = new_fcompiler(compiler=compiler)\n c.customize(dist)\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except:\n print sys.exc_info()[0],sys.exc_info()[1]\n if v is None:\n compilers_na.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n elif v=='N/A':\n compilers_ni.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n else:\n compilers.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2] + ' (%s)' % v))\n compilers.sort()\n compilers_na.sort()\n pretty_printer = FancyGetopt(compilers)\n pretty_printer.print_help(\"List of available Fortran compilers:\")\n pretty_printer = FancyGetopt(compilers_na)\n pretty_printer.print_help(\"List of unavailable Fortran compilers:\")\n if compilers_ni:\n pretty_printer = FancyGetopt(compilers_ni)\n pretty_printer.print_help(\"List of unimplemented Fortran compilers:\")\n print \"For compiler details, run 'config_fc --verbose' setup command.\"\n\ndef dummy_fortran_file():\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n def rm_file(name=dummy_name,log_threshold=log._global_log.threshold):\n save_th = log._global_log.threshold\n log.set_threshold(log_threshold)\n try: os.remove(name+'.f'); log.debug('removed '+name+'.f')\n except OSError: pass\n try: os.remove(name+'.o'); log.debug('removed '+name+'.o')\n except OSError: pass\n log.set_threshold(save_th)\n atexit.register(rm_file)\n return dummy_name\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15 # the number of non-comment lines to scan for hints\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nif __name__ == '__main__':\n show_fcompilers()\n", "methods": [ { "name": "get_version_cmd", "long_name": "get_version_cmd( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 187, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 205, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_flags", "long_name": "get_flags( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 223, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_version", "long_name": "get_flags_version( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 226, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f77", "long_name": "get_flags_f77( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 231, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f90", "long_name": "get_flags_f90( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 236, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_fix", "long_name": "get_flags_fix( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 246, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_ar", "long_name": "get_flags_ar( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 251, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 256, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 259, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 262, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 272, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self , force = 0 , ok_status = [ 0 ] )", "filename": "fcompiler.py", "nloc": 14, "complexity": 5, "token_count": 105, "parameters": [ "self", "force", "ok_status" ], "start_line": 276, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 83, "complexity": 36, "token_count": 785, "parameters": [ "self", "dist" ], "start_line": 297, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 114, "top_nesting_level": 1 }, { "name": "customize_cmd", "long_name": "customize_cmd( self , cmd )", "filename": "fcompiler.py", "nloc": 18, "complexity": 10, "token_count": 148, "parameters": [ "self", "cmd" ], "start_line": 412, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "dump_properties", "long_name": "dump_properties( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 5, "token_count": 117, "parameters": [ "self" ], "start_line": 431, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "exec_command", "long_name": "exec_command( self , * args , ** kws )", "filename": "fcompiler.py", "nloc": 11, "complexity": 4, "token_count": 87, "parameters": [ "self", "args", "kws" ], "start_line": 450, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "spawn", "long_name": "spawn( self , cmd )", "filename": "fcompiler.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self", "cmd" ], "start_line": 463, "end_line": 465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_get_cc_args", "long_name": "_get_cc_args( self , pp_opts , debug , before )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self", "pp_opts", "debug", "before" ], "start_line": 470, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "_compile", "long_name": "_compile( self , obj , src , ext , cc_args , extra_postargs , pp_opts )", "filename": "fcompiler.py", "nloc": 28, "complexity": 8, "token_count": 188, "parameters": [ "self", "obj", "src", "ext", "cc_args", "extra_postargs", "pp_opts" ], "start_line": 475, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "module_options", "long_name": "module_options( self , module_dirs , module_build_dir )", "filename": "fcompiler.py", "nloc": 17, "complexity": 5, "token_count": 129, "parameters": [ "self", "module_dirs", "module_build_dir" ], "start_line": 510, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "library_option", "long_name": "library_option( self , lib )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "lib" ], "start_line": 528, "end_line": 529, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dir_option", "long_name": "library_dir_option( self , dir )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "dir" ], "start_line": 530, "end_line": 531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , sources , output_dir = None , macros = None , include_dirs = None , debug = 0 , extra_preargs = None , extra_postargs = None , depends = None )", "filename": "fcompiler.py", "nloc": 25, "complexity": 11, "token_count": 264, "parameters": [ "self", "sources", "output_dir", "macros", "include_dirs", "debug", "extra_preargs", "extra_postargs", "depends" ], "start_line": 534, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 2 }, { "name": "detect_language", "long_name": "detect_language( self , sources )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "sources" ], "start_line": 559, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir = None , libraries = None , library_dirs = None , runtime_library_dirs = None , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 10, "token_count": 303, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 562, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "__get_cmd", "long_name": "__get_cmd( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 110, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 612, "end_line": 625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "__get_flags", "long_name": "__get_flags( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 120, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 627, "end_line": 640, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "get_default_fcompiler", "long_name": "get_default_fcompiler( osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 12, "complexity": 7, "token_count": 86, "parameters": [ "osname", "platform" ], "start_line": 694, "end_line": 706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "new_fcompiler", "long_name": "new_fcompiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "fcompiler.py", "nloc": 35, "complexity": 7, "token_count": 179, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 708, "end_line": 746, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "show_fcompilers", "long_name": "show_fcompilers( dist = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 8, "token_count": 257, "parameters": [ "dist" ], "start_line": 749, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "dummy_fortran_file.rm_file", "long_name": "dummy_fortran_file.rm_file( name = dummy_name , log_threshold = log . _global_log . threshold )", "filename": "fcompiler.py", "nloc": 8, "complexity": 3, "token_count": 84, "parameters": [ "name", "log_threshold" ], "start_line": 801, "end_line": 808, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "dummy_fortran_file", "long_name": "dummy_fortran_file( )", "filename": "fcompiler.py", "nloc": 9, "complexity": 1, "token_count": 46, "parameters": [], "start_line": 795, "end_line": 810, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "fcompiler.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 816, "end_line": 837, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_version_cmd", "long_name": "get_version_cmd( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 187, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 205, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_flags", "long_name": "get_flags( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 223, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_version", "long_name": "get_flags_version( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 226, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f77", "long_name": "get_flags_f77( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 231, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f90", "long_name": "get_flags_f90( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 236, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_fix", "long_name": "get_flags_fix( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 246, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_ar", "long_name": "get_flags_ar( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 251, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 256, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 259, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 262, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 272, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self , force = 0 , ok_status = [ 0 ] )", "filename": "fcompiler.py", "nloc": 14, "complexity": 5, "token_count": 105, "parameters": [ "self", "force", "ok_status" ], "start_line": 276, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 83, "complexity": 36, "token_count": 785, "parameters": [ "self", "dist" ], "start_line": 297, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 114, "top_nesting_level": 1 }, { "name": "customize_cmd", "long_name": "customize_cmd( self , cmd )", "filename": "fcompiler.py", "nloc": 18, "complexity": 10, "token_count": 148, "parameters": [ "self", "cmd" ], "start_line": 412, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "dump_properties", "long_name": "dump_properties( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 5, "token_count": 117, "parameters": [ "self" ], "start_line": 431, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "exec_command", "long_name": "exec_command( self , * args , ** kws )", "filename": "fcompiler.py", "nloc": 11, "complexity": 4, "token_count": 87, "parameters": [ "self", "args", "kws" ], "start_line": 450, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "spawn", "long_name": "spawn( self , cmd )", "filename": "fcompiler.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self", "cmd" ], "start_line": 463, "end_line": 465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_get_cc_args", "long_name": "_get_cc_args( self , pp_opts , debug , before )", "filename": "fcompiler.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self", "pp_opts", "debug", "before" ], "start_line": 470, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "_compile", "long_name": "_compile( self , obj , src , ext , cc_args , extra_postargs , pp_opts )", "filename": "fcompiler.py", "nloc": 29, "complexity": 8, "token_count": 208, "parameters": [ "self", "obj", "src", "ext", "cc_args", "extra_postargs", "pp_opts" ], "start_line": 475, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "module_options", "long_name": "module_options( self , module_dirs , module_build_dir )", "filename": "fcompiler.py", "nloc": 17, "complexity": 5, "token_count": 129, "parameters": [ "self", "module_dirs", "module_build_dir" ], "start_line": 510, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "library_option", "long_name": "library_option( self , lib )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "lib" ], "start_line": 528, "end_line": 529, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dir_option", "long_name": "library_dir_option( self , dir )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "dir" ], "start_line": 530, "end_line": 531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , sources , output_dir = None , macros = None , include_dirs = None , debug = 0 , extra_preargs = None , extra_postargs = None , depends = None )", "filename": "fcompiler.py", "nloc": 25, "complexity": 11, "token_count": 264, "parameters": [ "self", "sources", "output_dir", "macros", "include_dirs", "debug", "extra_preargs", "extra_postargs", "depends" ], "start_line": 534, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 2 }, { "name": "detect_language", "long_name": "detect_language( self , sources )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "sources" ], "start_line": 559, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir = None , libraries = None , library_dirs = None , runtime_library_dirs = None , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 10, "token_count": 303, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 562, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "__get_cmd", "long_name": "__get_cmd( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 110, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 612, "end_line": 625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "__get_flags", "long_name": "__get_flags( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 120, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 627, "end_line": 640, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "get_default_fcompiler", "long_name": "get_default_fcompiler( osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 12, "complexity": 7, "token_count": 86, "parameters": [ "osname", "platform" ], "start_line": 694, "end_line": 706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "new_fcompiler", "long_name": "new_fcompiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "fcompiler.py", "nloc": 35, "complexity": 7, "token_count": 179, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 708, "end_line": 746, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "show_fcompilers", "long_name": "show_fcompilers( dist = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 8, "token_count": 270, "parameters": [ "dist" ], "start_line": 749, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "dummy_fortran_file.rm_file", "long_name": "dummy_fortran_file.rm_file( name = dummy_name , log_threshold = log . _global_log . threshold )", "filename": "fcompiler.py", "nloc": 8, "complexity": 3, "token_count": 84, "parameters": [ "name", "log_threshold" ], "start_line": 801, "end_line": 808, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "dummy_fortran_file", "long_name": "dummy_fortran_file( )", "filename": "fcompiler.py", "nloc": 9, "complexity": 1, "token_count": 46, "parameters": [], "start_line": 795, "end_line": 810, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "fcompiler.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 816, "end_line": 837, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "_get_cc_args", "long_name": "_get_cc_args( self , pp_opts , debug , before )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self", "pp_opts", "debug", "before" ], "start_line": 470, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "_compile", "long_name": "_compile( self , obj , src , ext , cc_args , extra_postargs , pp_opts )", "filename": "fcompiler.py", "nloc": 28, "complexity": 8, "token_count": 188, "parameters": [ "self", "obj", "src", "ext", "cc_args", "extra_postargs", "pp_opts" ], "start_line": 475, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "show_fcompilers", "long_name": "show_fcompilers( dist = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 8, "token_count": 257, "parameters": [ "dist" ], "start_line": 749, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 } ], "nloc": 621, "complexity": 175, "token_count": 4259, "diff_parsed": { "added": [ " #print self.__class__.__name__ + '._get_cc_args:',pp_opts, debug, before", " #print self.__class__.__name__ + '._compile:',obj, src, ext, cc_args, extra_postargs, pp_opts", " except Exception, msg:", " print msg" ], "deleted": [ " print self.__class__.__name__ + '._get_cc_args:',pp_opts, debug, before", " print self.__class__.__name__ + '._compile:',obj, src, ext, cc_args, extra_postargs, pp_opts", " except:", " print sys.exc_info()[0],sys.exc_info()[1]" ] } } ] }, { "hash": "0a3bd249b5bbba831618b9f07d7d282a94fa1f85", "msg": "Fixed logic of the warning message.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-06T21:21:18+00:00", "author_timezone": 0, "committer_date": "2004-02-06T21:21:18+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "0d5d2277ba7ae30da0762ba396f861ad3f6d50bd" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 2, "insertions": 2, "lines": 4, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/mingw32ccompiler.py", "new_path": "scipy_distutils/mingw32ccompiler.py", "filename": "mingw32ccompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -206,8 +206,8 @@ def build_import_library():\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n status = os.system(cmd)\n # for now, fail silently\n- if not status:\n- print 'WARNING: failed to build import library for gcc. Linking will fail.'\n+ if status:\n+ log.warn('Failed to build import library for gcc. Linking will fail.')\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n", "added_lines": 2, "deleted_lines": 2, "source_code": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os\nimport sys\nimport log\n\nimport scipy_distutils.ccompiler\n\n# NT stuff\n# 1. Make sure libpython.a exists for gcc. If not, build it.\n# 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n# --> this is done in scipy_distutils/ccompiler.py\n# 3. Force windows to use g77\n\nimport distutils.cygwinccompiler\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import gen_preprocess_options, gen_lib_options\nfrom distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n\nfrom distutils.unixccompiler import UnixCCompiler \n \n# the same as cygwin plus some additional parameters\nclass Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n\n build_import_library()\n\n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -Wall',\n compiler_so='gcc -O2 -Wall -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = ['g++']\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n return\n\n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None,\n target_lang=None):\n args = (self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, #export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n if self.gcc_version < \"3.0.0\":\n func = distutils.cygwinccompiler.CygwinCCompiler.link\n else:\n func = UnixCCompiler.link\n func(*args[:func.im_func.func_code.co_argcount])\n return\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n \n # object_filenames ()\n\n \ndef build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n if os.name != 'nt':\n return\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n if not os.path.isfile(lib_file):\n log.info('Cannot build import library: \"%s\" not found' % (lib_file))\n return\n if os.path.isfile(out_file):\n log.info('Skip building import library: \"%s\" exists' % (out_file))\n return\n log.info('Building import library: \"%s\"' % (out_file))\n\n from scipy_distutils import lib2def\n\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n status = os.system(cmd)\n # for now, fail silently\n if status:\n log.warn('Failed to build import library for gcc. Linking will fail.')\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n return\n", "source_code_before": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os\nimport sys\nimport log\n\nimport scipy_distutils.ccompiler\n\n# NT stuff\n# 1. Make sure libpython.a exists for gcc. If not, build it.\n# 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n# --> this is done in scipy_distutils/ccompiler.py\n# 3. Force windows to use g77\n\nimport distutils.cygwinccompiler\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import gen_preprocess_options, gen_lib_options\nfrom distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n\nfrom distutils.unixccompiler import UnixCCompiler \n \n# the same as cygwin plus some additional parameters\nclass Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n\n build_import_library()\n\n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -Wall',\n compiler_so='gcc -O2 -Wall -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = ['g++']\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n return\n\n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None,\n target_lang=None):\n args = (self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, #export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n if self.gcc_version < \"3.0.0\":\n func = distutils.cygwinccompiler.CygwinCCompiler.link\n else:\n func = UnixCCompiler.link\n func(*args[:func.im_func.func_code.co_argcount])\n return\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n \n # object_filenames ()\n\n \ndef build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n if os.name != 'nt':\n return\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n if not os.path.isfile(lib_file):\n log.info('Cannot build import library: \"%s\" not found' % (lib_file))\n return\n if os.path.isfile(out_file):\n log.info('Skip building import library: \"%s\" exists' % (out_file))\n return\n log.info('Building import library: \"%s\"' % (out_file))\n\n from scipy_distutils import lib2def\n\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n status = os.system(cmd)\n # for now, fail silently\n if not status:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n return\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32ccompiler.py", "nloc": 37, "complexity": 7, "token_count": 203, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 38, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 1 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32ccompiler.py", "nloc": 34, "complexity": 2, "token_count": 113, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 107, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32ccompiler.py", "nloc": 25, "complexity": 8, "token_count": 173, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 142, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32ccompiler.py", "nloc": 28, "complexity": 5, "token_count": 254, "parameters": [], "start_line": 178, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32ccompiler.py", "nloc": 37, "complexity": 7, "token_count": 203, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 38, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 1 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32ccompiler.py", "nloc": 34, "complexity": 2, "token_count": 113, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 107, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32ccompiler.py", "nloc": 25, "complexity": 8, "token_count": 173, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 142, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32ccompiler.py", "nloc": 28, "complexity": 5, "token_count": 251, "parameters": [], "start_line": 178, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32ccompiler.py", "nloc": 28, "complexity": 5, "token_count": 254, "parameters": [], "start_line": 178, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 } ], "nloc": 147, "complexity": 22, "token_count": 806, "diff_parsed": { "added": [ " if status:", " log.warn('Failed to build import library for gcc. Linking will fail.')" ], "deleted": [ " if not status:", " print 'WARNING: failed to build import library for gcc. Linking will fail.'" ] } } ] }, { "hash": "c396c0ddd74cc9580682e71e576c50faaad4954d", "msg": "Forcing scipy_distutils.unixccompiler because on WinXP long argument list to ar (eg when building lapack) silently crashes python.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-06T22:13:15+00:00", "author_timezone": 0, "committer_date": "2004-02-06T22:13:15+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "0a3bd249b5bbba831618b9f07d7d282a94fa1f85" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 0, "insertions": 4, "lines": 4, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/__init__.py", "new_path": "scipy_distutils/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -16,3 +16,7 @@\n import ccompiler\n sys.modules['distutils.ccompiler'] = ccompiler\n \n+assert not sys.modules.has_key('distutils.unixccompiler'),\\\n+ 'cannot override distutils.unixccompiler'\n+import unixccompiler\n+sys.modules['distutils.unixccompiler'] = unixccompiler\n", "added_lines": 4, "deleted_lines": 0, "source_code": "\"\"\"scipy_distutils\n\n Modified version of distutils to handle fortran source code, f2py,\n and other issues in the scipy build process.\n\"\"\"\n\n# Need to do something here to get distutils subsumed...\n\nfrom scipy_distutils_version import scipy_distutils_version as __version__\n\nimport sys\n\n# Replace distutils.ccompiler with scipy_distutils.ccompiler\nassert not sys.modules.has_key('distutils.ccompiler'),\\\n 'distutils has been imported before scipy_distutils'\nimport ccompiler\nsys.modules['distutils.ccompiler'] = ccompiler\n\nassert not sys.modules.has_key('distutils.unixccompiler'),\\\n 'cannot override distutils.unixccompiler'\nimport unixccompiler\nsys.modules['distutils.unixccompiler'] = unixccompiler\n", "source_code_before": "\"\"\"scipy_distutils\n\n Modified version of distutils to handle fortran source code, f2py,\n and other issues in the scipy build process.\n\"\"\"\n\n# Need to do something here to get distutils subsumed...\n\nfrom scipy_distutils_version import scipy_distutils_version as __version__\n\nimport sys\n\n# Replace distutils.ccompiler with scipy_distutils.ccompiler\nassert not sys.modules.has_key('distutils.ccompiler'),\\\n 'distutils has been imported before scipy_distutils'\nimport ccompiler\nsys.modules['distutils.ccompiler'] = ccompiler\n\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 15, "complexity": 0, "token_count": 55, "diff_parsed": { "added": [ "assert not sys.modules.has_key('distutils.unixccompiler'),\\", " 'cannot override distutils.unixccompiler'", "import unixccompiler", "sys.modules['distutils.unixccompiler'] = unixccompiler" ], "deleted": [] } } ] }, { "hash": "d98f6378a0bb5843984e24668815e8820a6de62d", "msg": "Single file libraries (like blas and lapack) can be specified with their corresponding environment variables (BLAS and LAPACK). Usage example: BLAS=/path/to/libfblas.a", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-08T09:32:07+00:00", "author_timezone": 0, "committer_date": "2004-02-08T09:32:07+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "c396c0ddd74cc9580682e71e576c50faaad4954d" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 4, "insertions": 17, "lines": 21, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/system_info.py", "new_path": "scipy_distutils/system_info.py", "filename": "system_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -276,7 +276,19 @@ def get_info(self):\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n- dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n+ d = os.environ[self.dir_env_var]\n+ if os.path.isfile(d):\n+ dirs = [os.path.dirname(d)] + dirs\n+ l = getattr(self,'_lib_names',[])\n+ if len(l)==1:\n+ b = os.path.basename(d)\n+ b = os.path.splitext(b)[0]\n+ if b[:3]=='lib':\n+ print 'Replacing _lib_names[0]==%r with %r' \\\n+ % (self._lib_names[0], b[3:])\n+ self._lib_names[0] = b[3:]\n+ else:\n+ dirs = d.split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n@@ -549,11 +561,11 @@ class lapack_atlas_threads_info(atlas_threads_info):\n class lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n-\n+ _lib_names = ['lapack']\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n \n- lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n+ lapack_libs = self.get_libs('lapack_libs', self._lib_names)\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n@@ -664,11 +676,12 @@ def calc_info(self):\n class blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n+ _lib_names = ['blas']\n \n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n \n- blas_libs = self.get_libs('blas_libs', ['blas'])\n+ blas_libs = self.get_libs('blas_libs', self._lib_names)\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n", "added_lines": 17, "deleted_lines": 4, "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n atlas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'atlas_threads':atlas_threads_info,\n 'lapack_atlas_threads':lapack_atlas_threads_info,\n 'lapack_atlas':lapack_atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n d = os.environ[self.dir_env_var]\n if os.path.isfile(d):\n dirs = [os.path.dirname(d)] + dirs\n l = getattr(self,'_lib_names',[])\n if len(l)==1:\n b = os.path.basename(d)\n b = os.path.splitext(b)[0]\n if b[:3]=='lib':\n print 'Replacing _lib_names[0]==%r with %r' \\\n % (self._lib_names[0], b[3:])\n self._lib_names[0] = b[3:]\n else:\n dirs = d.split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n self.set_info(**info)\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n _lib_names = ['lapack']\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', self._lib_names)\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n _lib_names = ['blas']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', self._lib_names)\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32','cygwin']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n py_incl_dir = get_python_inc()\n include_dirs = [py_incl_dir]\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"%s\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n atlas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'atlas_threads':atlas_threads_info,\n 'lapack_atlas_threads':lapack_atlas_threads_info,\n 'lapack_atlas':lapack_atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n self.set_info(**info)\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32','cygwin']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n py_incl_dir = get_python_inc()\n include_dirs = [py_incl_dir]\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"%s\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 21, "complexity": 1, "token_count": 100, "parameters": [ "name" ], "start_line": 120, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 218, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 244, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 247, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 153, "parameters": [ "self" ], "start_line": 250, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 23, "complexity": 10, "token_count": 252, "parameters": [ "self", "section", "key" ], "start_line": 276, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 300, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 303, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 306, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 309, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 316, "end_line": 325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 327, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 337, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 341, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 352, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 362, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 365, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 431, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 438, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 466, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 75, "complexity": 17, "token_count": 427, "parameters": [ "self" ], "start_line": 474, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 565, "end_line": 576, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 582, "end_line": 587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 589, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 681, "end_line": 692, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 698, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 705, "end_line": 740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 745, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 116, "parameters": [ "self" ], "start_line": 750, "end_line": 769, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 775, "end_line": 785, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 787, "end_line": 815, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 830, "end_line": 854, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 856, "end_line": 864, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 866, "end_line": 874, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 21, "complexity": 1, "token_count": 100, "parameters": [ "name" ], "start_line": 120, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 218, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 244, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 247, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 153, "parameters": [ "self" ], "start_line": 250, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 11, "complexity": 7, "token_count": 142, "parameters": [ "self", "section", "key" ], "start_line": 276, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 288, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 291, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 294, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 297, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 304, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 315, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 325, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 329, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 340, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 350, "end_line": 351, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 353, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 426, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 454, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 75, "complexity": 17, "token_count": 427, "parameters": [ "self" ], "start_line": 462, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 553, "end_line": 564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 570, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 577, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 668, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 685, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 692, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 732, "end_line": 735, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 116, "parameters": [ "self" ], "start_line": 737, "end_line": 756, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 762, "end_line": 772, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 774, "end_line": 802, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 817, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 843, "end_line": 851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 853, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 23, "complexity": 10, "token_count": 252, "parameters": [ "self", "section", "key" ], "start_line": 276, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 565, "end_line": 576, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 } ], "nloc": 767, "complexity": 153, "token_count": 3997, "diff_parsed": { "added": [ " d = os.environ[self.dir_env_var]", " if os.path.isfile(d):", " dirs = [os.path.dirname(d)] + dirs", " l = getattr(self,'_lib_names',[])", " if len(l)==1:", " b = os.path.basename(d)", " b = os.path.splitext(b)[0]", " if b[:3]=='lib':", " print 'Replacing _lib_names[0]==%r with %r' \\", " % (self._lib_names[0], b[3:])", " self._lib_names[0] = b[3:]", " else:", " dirs = d.split(os.pathsep) + dirs", " _lib_names = ['lapack']", " lapack_libs = self.get_libs('lapack_libs', self._lib_names)", " _lib_names = ['blas']", " blas_libs = self.get_libs('blas_libs', self._lib_names)" ], "deleted": [ " dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs", "", " lapack_libs = self.get_libs('lapack_libs', ['lapack'])", " blas_libs = self.get_libs('blas_libs', ['blas'])" ] } } ] }, { "hash": "ba685a615e597b3070ba54dc9771d44277e886d2", "msg": "Using ext.language to find correct linker. Fixed doubles libraries in linking command.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-11T20:04:39+00:00", "author_timezone": 0, "committer_date": "2004-02-11T20:04:39+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "d98f6378a0bb5843984e24668815e8820a6de62d" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 10, "insertions": 32, "lines": 42, "files": 5, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.10526315789473684, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_ext.py", "new_path": "scipy_distutils/command/build_ext.py", "filename": "build_ext.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -57,6 +57,9 @@ def run(self):\n if has_f_sources(ext.sources):\n need_f_compiler = 1\n break\n+ if getattr(ext,'language','c') in ['f77','f90']:\n+ need_f_compiler = 1\n+ break\n \n # Determine if C++ compiler is needed.\n need_cxx_compiler = 0\n@@ -64,6 +67,9 @@ def run(self):\n if has_cxx_sources(ext.sources):\n need_cxx_compiler = 1\n break\n+ if getattr(ext,'language','c')=='c++':\n+ need_cxx_compiler = 1\n+ break\n \n # Initialize Fortran/C++ compilers if needed.\n if need_f_compiler:\n@@ -217,10 +223,10 @@ def build_extension(self, ext):\n \n old_linker_so_0 = self.compiler.linker_so[0]\n \n- use_fortran_linker = 0\n+ use_fortran_linker = getattr(ext,'language','c') in ['f77','f90']\n c_libraries = []\n c_library_dirs = []\n- if f_sources:\n+ if use_fortran_linker or f_sources:\n use_fortran_linker = 1\n elif self.distribution.has_c_libraries(): \n build_clib = self.get_finalized_command('build_clib')\n", "added_lines": 8, "deleted_lines": 2, "source_code": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os\nimport string\nimport sys\nfrom glob import glob\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util, log\nfrom scipy_distutils.misc_util import filter_sources, has_f_sources, has_cxx_sources\n\nclass build_ext (old_build_ext):\n\n description = \"build C/C++/F extensions (compile/link to build directory)\"\n\n user_options = old_build_ext.user_options + [\n ('fcompiler=', None,\n \"specify the Fortran compiler type\"),\n ]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.fcompiler = None\n return\n\n def run(self):\n if not self.extensions:\n return\n\n if self.distribution.has_c_libraries():\n build_clib = self.get_finalized_command('build_clib')\n self.library_dirs.append(build_clib.build_clib)\n else:\n build_clib = None\n\n # Not including C libraries to the list of\n # extension libraries automatically to prevent\n # bogus linking commands. Extensions must\n # explicitly specify the C libraries that they use.\n\n save_mth = self.distribution.has_c_libraries\n self.distribution.has_c_libraries = self.distribution.return_false\n old_build_ext.run(self) # sets self.compiler\n self.distribution.has_c_libraries = save_mth\n \n # Determine if Fortran compiler is needed.\n if build_clib and build_clib.fcompiler is not None:\n need_f_compiler = 1\n else:\n need_f_compiler = 0\n for ext in self.extensions:\n if has_f_sources(ext.sources):\n need_f_compiler = 1\n break\n if getattr(ext,'language','c') in ['f77','f90']:\n need_f_compiler = 1\n break\n\n # Determine if C++ compiler is needed.\n need_cxx_compiler = 0\n for ext in self.extensions:\n if has_cxx_sources(ext.sources):\n need_cxx_compiler = 1\n break\n if getattr(ext,'language','c')=='c++':\n need_cxx_compiler = 1\n break\n\n # Initialize Fortran/C++ compilers if needed.\n if need_f_compiler:\n from scipy_distutils.fcompiler import new_fcompiler\n self.fcompiler = new_fcompiler(compiler=self.fcompiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n self.fcompiler.customize(self.distribution)\n self.fcompiler.customize_cmd(self)\n if need_cxx_compiler:\n c = self.compiler\n if c.compiler[0].find('gcc')>=0:\n if sys.version[:3]>='2.3':\n if not c.compiler_cxx:\n c.compiler_cxx = [c.compiler[0].replace('gcc','g++')]\\\n + c.compiler[1:]\n else:\n c.compiler_cxx = [c.compiler[0].replace('gcc','g++')]\\\n + c.compiler[1:]\n else:\n print 'XXX: Fix compiler_cxx for',c.__class__.__name__\n\n # Build extensions\n self.build_extensions2()\n return\n\n def build_extensions(self):\n # Hold on building extensions in old_build_ext.run()\n # until Fortran/C++ compilers are set. Building will be\n # carried out in build_extensions2()\n return\n\n def build_extensions2(self):\n old_build_ext.build_extensions(self)\n return\n\n def swig_sources(self, sources):\n # Do nothing. Swig sources have beed handled in build_src command.\n return sources\n\n def build_extension(self, ext):\n sources = ext.sources\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'ext_modules' option (extension '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % ext.name\n sources = list(sources)\n\n fullname = self.get_ext_fullname(ext.name)\n if self.inplace:\n modpath = string.split(fullname, '.')\n package = string.join(modpath[0:-1], '.')\n base = modpath[-1]\n\n build_py = self.get_finalized_command('build_py')\n package_dir = build_py.get_package_dir(package)\n ext_filename = os.path.join(package_dir,\n self.get_ext_filename(base))\n else:\n ext_filename = os.path.join(self.build_lib,\n self.get_ext_filename(fullname))\n depends = sources + ext.depends\n\n if not (self.force or newer_group(depends, ext_filename, 'newer')):\n log.debug(\"skipping '%s' extension (up-to-date)\", ext.name)\n return\n else:\n log.info(\"building '%s' extension\", ext.name)\n\n extra_args = ext.extra_compile_args or []\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n c_sources, cxx_sources, f_sources, fmodule_sources = filter_sources(ext.sources)\n\n if sys.version[:3]>='2.3':\n kws = {'depends':ext.depends}\n else:\n kws = {}\n\n c_objects = self.compiler.compile(c_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=ext.include_dirs,\n debug=self.debug,\n extra_postargs=extra_args,\n **kws)\n if cxx_sources:\n old_compiler = self.compiler.compiler_so[0]\n self.compiler.compiler_so[0] = self.compiler.compiler_cxx[0]\n c_objects += self.compiler.compile(cxx_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=ext.include_dirs,\n debug=self.debug,\n extra_postargs=extra_args,\n **kws)\n self.compiler.compiler_so[0] = old_compiler\n\n check_for_f90_modules = not not fmodule_sources\n\n if f_sources or fmodule_sources:\n extra_postargs = []\n include_dirs = ext.include_dirs[:]\n module_dirs = [] # XXX Figure out how users could change this?\n\n if check_for_f90_modules:\n module_build_dir = os.path.join(\\\n self.build_temp,os.path.dirname(\\\n self.get_ext_filename(fullname)))\n\n self.mkpath(module_build_dir)\n if self.fcompiler.module_dir_switch is None:\n existing_modules = glob('*.mod')\n extra_postargs += self.fcompiler.module_options(\\\n module_dirs,module_build_dir)\n\n f_objects = self.fcompiler.compile(fmodule_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs,\n depends=ext.depends)\n\n if check_for_f90_modules \\\n and self.fcompiler.module_dir_switch is None:\n for f in glob('*.mod'):\n if f in existing_modules:\n continue\n self.move_file(f, module_build_dir)\n\n f_objects += self.fcompiler.compile(f_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs,\n depends=ext.depends)\n else:\n f_objects = []\n\n objects = c_objects + f_objects\n\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n old_linker_so_0 = self.compiler.linker_so[0]\n\n use_fortran_linker = getattr(ext,'language','c') in ['f77','f90']\n c_libraries = []\n c_library_dirs = []\n if use_fortran_linker or f_sources:\n use_fortran_linker = 1\n elif self.distribution.has_c_libraries(): \n build_clib = self.get_finalized_command('build_clib')\n f_libs = []\n for (lib_name, build_info) in build_clib.libraries:\n if has_f_sources(build_info.get('sources',[])):\n f_libs.append(lib_name)\n if lib_name in ext.libraries:\n # XXX: how to determine if c_libraries contain\n # fortran compiled sources?\n c_libraries.extend(build_info.get('libraries',[]))\n c_library_dirs.extend(build_info.get('library_dirs',[]))\n for l in ext.libraries:\n if l in f_libs:\n use_fortran_linker = 1\n break\n\n if use_fortran_linker:\n if cxx_sources:\n # XXX: Which linker should be used, Fortran or C++?\n log.warn('mixing Fortran and C++ is untested')\n link = self.fcompiler.link_shared_object\n language = ext.language or self.fcompiler.detect_language(f_sources)\n else:\n link = self.compiler.link_shared_object\n if sys.version[:3]>='2.3':\n language = ext.language or self.compiler.detect_language(sources)\n else:\n language = ext.language\n if cxx_sources:\n self.compiler.linker_so[0] = self.compiler.compiler_cxx[0]\n\n if sys.version[:3]>='2.3':\n kws = {'target_lang':language}\n else:\n kws = {}\n\n link(objects, ext_filename,\n libraries=self.get_libraries(ext) + c_libraries,\n library_dirs=ext.library_dirs + c_library_dirs,\n runtime_library_dirs=ext.runtime_library_dirs,\n extra_postargs=extra_args,\n export_symbols=self.get_export_symbols(ext),\n debug=self.debug,\n build_temp=self.build_temp,**kws)\n\n self.compiler.linker_so[0] = old_linker_so_0\n return\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n def visit_func(filenames,dirname,names):\n if os.path.basename(dirname)=='CVS':\n return\n for name in names:\n fullname = os.path.join(dirname,name)\n if os.path.isfile(fullname):\n filenames.append(fullname)\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n sources = filter(lambda s:type(s) is StringType,ext.sources)\n filenames.extend(sources)\n filenames.extend(get_headers(get_directories(sources)))\n for d in ext.depends:\n if is_local_src_dir(d):\n os.path.walk(d,visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return 0\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os\nimport string\nimport sys\nfrom glob import glob\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util, log\nfrom scipy_distutils.misc_util import filter_sources, has_f_sources, has_cxx_sources\n\nclass build_ext (old_build_ext):\n\n description = \"build C/C++/F extensions (compile/link to build directory)\"\n\n user_options = old_build_ext.user_options + [\n ('fcompiler=', None,\n \"specify the Fortran compiler type\"),\n ]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.fcompiler = None\n return\n\n def run(self):\n if not self.extensions:\n return\n\n if self.distribution.has_c_libraries():\n build_clib = self.get_finalized_command('build_clib')\n self.library_dirs.append(build_clib.build_clib)\n else:\n build_clib = None\n\n # Not including C libraries to the list of\n # extension libraries automatically to prevent\n # bogus linking commands. Extensions must\n # explicitly specify the C libraries that they use.\n\n save_mth = self.distribution.has_c_libraries\n self.distribution.has_c_libraries = self.distribution.return_false\n old_build_ext.run(self) # sets self.compiler\n self.distribution.has_c_libraries = save_mth\n \n # Determine if Fortran compiler is needed.\n if build_clib and build_clib.fcompiler is not None:\n need_f_compiler = 1\n else:\n need_f_compiler = 0\n for ext in self.extensions:\n if has_f_sources(ext.sources):\n need_f_compiler = 1\n break\n\n # Determine if C++ compiler is needed.\n need_cxx_compiler = 0\n for ext in self.extensions:\n if has_cxx_sources(ext.sources):\n need_cxx_compiler = 1\n break\n\n # Initialize Fortran/C++ compilers if needed.\n if need_f_compiler:\n from scipy_distutils.fcompiler import new_fcompiler\n self.fcompiler = new_fcompiler(compiler=self.fcompiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n self.fcompiler.customize(self.distribution)\n self.fcompiler.customize_cmd(self)\n if need_cxx_compiler:\n c = self.compiler\n if c.compiler[0].find('gcc')>=0:\n if sys.version[:3]>='2.3':\n if not c.compiler_cxx:\n c.compiler_cxx = [c.compiler[0].replace('gcc','g++')]\\\n + c.compiler[1:]\n else:\n c.compiler_cxx = [c.compiler[0].replace('gcc','g++')]\\\n + c.compiler[1:]\n else:\n print 'XXX: Fix compiler_cxx for',c.__class__.__name__\n\n # Build extensions\n self.build_extensions2()\n return\n\n def build_extensions(self):\n # Hold on building extensions in old_build_ext.run()\n # until Fortran/C++ compilers are set. Building will be\n # carried out in build_extensions2()\n return\n\n def build_extensions2(self):\n old_build_ext.build_extensions(self)\n return\n\n def swig_sources(self, sources):\n # Do nothing. Swig sources have beed handled in build_src command.\n return sources\n\n def build_extension(self, ext):\n sources = ext.sources\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'ext_modules' option (extension '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % ext.name\n sources = list(sources)\n\n fullname = self.get_ext_fullname(ext.name)\n if self.inplace:\n modpath = string.split(fullname, '.')\n package = string.join(modpath[0:-1], '.')\n base = modpath[-1]\n\n build_py = self.get_finalized_command('build_py')\n package_dir = build_py.get_package_dir(package)\n ext_filename = os.path.join(package_dir,\n self.get_ext_filename(base))\n else:\n ext_filename = os.path.join(self.build_lib,\n self.get_ext_filename(fullname))\n depends = sources + ext.depends\n\n if not (self.force or newer_group(depends, ext_filename, 'newer')):\n log.debug(\"skipping '%s' extension (up-to-date)\", ext.name)\n return\n else:\n log.info(\"building '%s' extension\", ext.name)\n\n extra_args = ext.extra_compile_args or []\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n c_sources, cxx_sources, f_sources, fmodule_sources = filter_sources(ext.sources)\n\n if sys.version[:3]>='2.3':\n kws = {'depends':ext.depends}\n else:\n kws = {}\n\n c_objects = self.compiler.compile(c_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=ext.include_dirs,\n debug=self.debug,\n extra_postargs=extra_args,\n **kws)\n if cxx_sources:\n old_compiler = self.compiler.compiler_so[0]\n self.compiler.compiler_so[0] = self.compiler.compiler_cxx[0]\n c_objects += self.compiler.compile(cxx_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=ext.include_dirs,\n debug=self.debug,\n extra_postargs=extra_args,\n **kws)\n self.compiler.compiler_so[0] = old_compiler\n\n check_for_f90_modules = not not fmodule_sources\n\n if f_sources or fmodule_sources:\n extra_postargs = []\n include_dirs = ext.include_dirs[:]\n module_dirs = [] # XXX Figure out how users could change this?\n\n if check_for_f90_modules:\n module_build_dir = os.path.join(\\\n self.build_temp,os.path.dirname(\\\n self.get_ext_filename(fullname)))\n\n self.mkpath(module_build_dir)\n if self.fcompiler.module_dir_switch is None:\n existing_modules = glob('*.mod')\n extra_postargs += self.fcompiler.module_options(\\\n module_dirs,module_build_dir)\n\n f_objects = self.fcompiler.compile(fmodule_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs,\n depends=ext.depends)\n\n if check_for_f90_modules \\\n and self.fcompiler.module_dir_switch is None:\n for f in glob('*.mod'):\n if f in existing_modules:\n continue\n self.move_file(f, module_build_dir)\n\n f_objects += self.fcompiler.compile(f_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs,\n depends=ext.depends)\n else:\n f_objects = []\n\n objects = c_objects + f_objects\n\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n old_linker_so_0 = self.compiler.linker_so[0]\n\n use_fortran_linker = 0\n c_libraries = []\n c_library_dirs = []\n if f_sources:\n use_fortran_linker = 1\n elif self.distribution.has_c_libraries(): \n build_clib = self.get_finalized_command('build_clib')\n f_libs = []\n for (lib_name, build_info) in build_clib.libraries:\n if has_f_sources(build_info.get('sources',[])):\n f_libs.append(lib_name)\n if lib_name in ext.libraries:\n # XXX: how to determine if c_libraries contain\n # fortran compiled sources?\n c_libraries.extend(build_info.get('libraries',[]))\n c_library_dirs.extend(build_info.get('library_dirs',[]))\n for l in ext.libraries:\n if l in f_libs:\n use_fortran_linker = 1\n break\n\n if use_fortran_linker:\n if cxx_sources:\n # XXX: Which linker should be used, Fortran or C++?\n log.warn('mixing Fortran and C++ is untested')\n link = self.fcompiler.link_shared_object\n language = ext.language or self.fcompiler.detect_language(f_sources)\n else:\n link = self.compiler.link_shared_object\n if sys.version[:3]>='2.3':\n language = ext.language or self.compiler.detect_language(sources)\n else:\n language = ext.language\n if cxx_sources:\n self.compiler.linker_so[0] = self.compiler.compiler_cxx[0]\n\n if sys.version[:3]>='2.3':\n kws = {'target_lang':language}\n else:\n kws = {}\n\n link(objects, ext_filename,\n libraries=self.get_libraries(ext) + c_libraries,\n library_dirs=ext.library_dirs + c_library_dirs,\n runtime_library_dirs=ext.runtime_library_dirs,\n extra_postargs=extra_args,\n export_symbols=self.get_export_symbols(ext),\n debug=self.debug,\n build_temp=self.build_temp,**kws)\n\n self.compiler.linker_so[0] = old_linker_so_0\n return\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n def visit_func(filenames,dirname,names):\n if os.path.basename(dirname)=='CVS':\n return\n for name in names:\n fullname = os.path.join(dirname,name)\n if os.path.isfile(fullname):\n filenames.append(fullname)\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n sources = filter(lambda s:type(s) is StringType,ext.sources)\n filenames.extend(sources)\n filenames.extend(get_headers(get_directories(sources)))\n for d in ext.depends:\n if is_local_src_dir(d):\n os.path.walk(d,visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return 0\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_ext.py", "nloc": 53, "complexity": 16, "token_count": 341, "parameters": [ "self" ], "start_line": 31, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 1 }, { "name": "build_extensions", "long_name": "build_extensions( self )", "filename": "build_ext.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 100, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_extensions2", "long_name": "build_extensions2( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 106, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "swig_sources", "long_name": "swig_sources( self , sources )", "filename": "build_ext.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "sources" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 139, "complexity": 35, "token_count": 959, "parameters": [ "self", "ext" ], "start_line": 114, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 164, "top_nesting_level": 1 }, { "name": "get_source_files.visit_func", "long_name": "get_source_files.visit_func( filenames , dirname , names )", "filename": "build_ext.py", "nloc": 7, "complexity": 4, "token_count": 55, "parameters": [ "filenames", "dirname", "names" ], "start_line": 282, "end_line": 288, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 14, "complexity": 5, "token_count": 105, "parameters": [ "self" ], "start_line": 279, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "is_local_src_dir", "long_name": "is_local_src_dir( directory )", "filename": "build_ext.py", "nloc": 10, "complexity": 5, "token_count": 98, "parameters": [ "directory" ], "start_line": 301, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_ext.py", "nloc": 47, "complexity": 14, "token_count": 305, "parameters": [ "self" ], "start_line": 31, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 1 }, { "name": "build_extensions", "long_name": "build_extensions( self )", "filename": "build_ext.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 94, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_extensions2", "long_name": "build_extensions2( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "swig_sources", "long_name": "swig_sources( self , sources )", "filename": "build_ext.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "sources" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 139, "complexity": 34, "token_count": 944, "parameters": [ "self", "ext" ], "start_line": 108, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 164, "top_nesting_level": 1 }, { "name": "get_source_files.visit_func", "long_name": "get_source_files.visit_func( filenames , dirname , names )", "filename": "build_ext.py", "nloc": 7, "complexity": 4, "token_count": 55, "parameters": [ "filenames", "dirname", "names" ], "start_line": 276, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 14, "complexity": 5, "token_count": 105, "parameters": [ "self" ], "start_line": 273, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "is_local_src_dir", "long_name": "is_local_src_dir( directory )", "filename": "build_ext.py", "nloc": 10, "complexity": 5, "token_count": 98, "parameters": [ "directory" ], "start_line": 295, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "run", "long_name": "run( self )", "filename": "build_ext.py", "nloc": 53, "complexity": 16, "token_count": 341, "parameters": [ "self" ], "start_line": 31, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 139, "complexity": 35, "token_count": 959, "parameters": [ "self", "ext" ], "start_line": 114, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 164, "top_nesting_level": 1 } ], "nloc": 251, "complexity": 69, "token_count": 1693, "diff_parsed": { "added": [ " if getattr(ext,'language','c') in ['f77','f90']:", " need_f_compiler = 1", " break", " if getattr(ext,'language','c')=='c++':", " need_cxx_compiler = 1", " break", " use_fortran_linker = getattr(ext,'language','c') in ['f77','f90']", " if use_fortran_linker or f_sources:" ], "deleted": [ " use_fortran_linker = 0", " if f_sources:" ] } }, { "old_path": "scipy_distutils/gnufcompiler.py", "new_path": "scipy_distutils/gnufcompiler.py", "filename": "gnufcompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -67,7 +67,7 @@ def get_libgcc_dir(self):\n return\n \n def get_library_dirs(self):\n- opt = FCompiler.get_library_dirs(self)\n+ opt = []\n if sys.platform[:5] != 'linux':\n d = self.get_libgcc_dir()\n if d:\n@@ -75,7 +75,7 @@ def get_library_dirs(self):\n return opt\n \n def get_libraries(self):\n- opt = FCompiler.get_libraries(self)\n+ opt = []\n d = self.get_libgcc_dir()\n if d is not None:\n for g2c in ['g2c-pic','g2c']:\n", "added_lines": 2, "deleted_lines": 2, "source_code": "\nimport re\nimport os\nimport sys\n\nfrom cpuinfo import cpu\nfrom fcompiler import FCompiler\nfrom exec_command import find_executable\n\nclass GnuFCompiler(FCompiler):\n\n compiler_type = 'gnu'\n version_pattern = r'GNU Fortran ((\\(GCC[^\\)]*(\\)\\)|\\)))|)\\s*'\\\n '(?P[^\\s*\\)]+)'\n\n # 'g77 --version' results\n # SunOS: GNU Fortran (GCC 3.2) 3.2 20020814 (release)\n # Debian: GNU Fortran (GCC) 3.3.3 20040110 (prerelease) (Debian)\n # GNU Fortran 0.5.25 20010319 (prerelease)\n # Redhat: GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)\n\n for fc_exe in map(find_executable,['g77','f77']):\n if os.path.isfile(fc_exe):\n break\n executables = {\n 'version_cmd' : [fc_exe,\"--version\"],\n 'compiler_f77' : [fc_exe,\"-Wall\",\"-fno-second-underscore\"],\n 'compiler_f90' : None,\n 'compiler_fix' : None,\n 'linker_so' : [fc_exe],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"],\n }\n module_dir_switch = None\n module_include_switch = None\n\n # Cygwin: f771: warning: -fPIC ignored for target (all code is position independent)\n if os.name != 'nt' and sys.platform!='cygwin':\n pic_flags = ['-fPIC']\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if re.match(r'(darwin)', sys.platform):\n return\n return FCompiler.get_linker_so(self)\n\n def get_flags_linker_so(self):\n opt = FCompiler.get_flags_linker_so(self)\n if not re.match(r'(darwin)', sys.platform):\n opt.append(\"-shared\")\n if sys.platform[:5]=='sunos':\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work. 'man gcc' says:\n # \".. Instead of using -mimpure-text, you should compile all\n # source code with -fpic or -fPIC.\"\n opt.append('-mimpure-text')\n return opt\n\n def get_libgcc_dir(self):\n status, output = self.exec_command('%s -print-libgcc-file-name' \\\n % (self.compiler_f77[0]),use_tee=0) \n if not status:\n return os.path.dirname(output)\n return\n\n def get_library_dirs(self):\n opt = []\n if sys.platform[:5] != 'linux':\n d = self.get_libgcc_dir()\n if d:\n opt.append(d)\n return opt\n\n def get_libraries(self):\n opt = []\n d = self.get_libgcc_dir()\n if d is not None:\n for g2c in ['g2c-pic','g2c']:\n f = self.static_lib_format % (g2c, self.static_lib_extension)\n if os.path.isfile(os.path.join(d,f)):\n break\n else:\n g2c = 'g2c'\n if sys.platform=='win32':\n opt.extend(['gcc',g2c])\n else:\n opt.append(g2c)\n return opt\n\n def get_flags_debug(self):\n return ['-g']\n\n def get_flags_opt(self):\n opt = ['-O3','-funroll-loops']\n return opt\n\n def get_flags_arch(self):\n opt = []\n if sys.platform=='darwin':\n if os.name != 'posix':\n # this should presumably correspond to Apple\n if cpu.is_ppc():\n opt.append('-arch ppc')\n elif cpu.is_i386():\n opt.append('-arch i386')\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt.append('-mcpu='+a)\n opt.append('-mtune='+a)\n break \n return opt\n march_flag = 1\n # 0.5.25 corresponds to 2.95.x\n if self.get_version() == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt.append('-march=k6')\n elif cpu.is_AthlonK7():\n opt.append('-march=athlon')\n else:\n march_flag = 0\n # Note: gcc 3.2 on win32 has breakage with -march specified\n elif self.get_version() >= '3.1.1' \\\n and not sys.platform=='win32': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt.append('-march=k6')\n elif cpu.is_AthlonK6_2():\n opt.append('-march=k6-2')\n elif cpu.is_AthlonK6_3():\n opt.append('-march=k6-3')\n elif cpu.is_AthlonK7():\n opt.append('-march=athlon')\n elif cpu.is_AthlonMP():\n opt.append('-march=athlon-mp')\n # there's also: athlon-tbird, athlon-4, athlon-xp\n elif cpu.is_PentiumIV():\n opt.append('-march=pentium4')\n elif cpu.is_PentiumIII():\n opt.append('-march=pentium3')\n elif cpu.is_PentiumII():\n opt.append('-march=pentium2')\n else:\n march_flag = 0\n if cpu.has_mmx(): opt.append('-mmmx') \n if self.get_version() > '3.2.2':\n if cpu.has_sse2(): opt.append('-msse2')\n if cpu.has_sse(): opt.append('-msse')\n if cpu.has_3dnow(): opt.append('-m3dnow')\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt.append('-march=i686')\n elif cpu.is_i586():\n opt.append('-march=i586')\n elif cpu.is_i486():\n opt.append('-march=i486')\n elif cpu.is_i386():\n opt.append('-march=i386')\n if cpu.is_Intel():\n opt.extend(['-malign-double','-fomit-frame-pointer'])\n return opt\n\nif __name__ == '__main__':\n from scipy_distutils import log\n log.set_verbosity(2)\n from fcompiler import new_fcompiler\n #compiler = new_fcompiler(compiler='gnu')\n compiler = GnuFCompiler()\n compiler.customize()\n print compiler.get_version()\n", "source_code_before": "\nimport re\nimport os\nimport sys\n\nfrom cpuinfo import cpu\nfrom fcompiler import FCompiler\nfrom exec_command import find_executable\n\nclass GnuFCompiler(FCompiler):\n\n compiler_type = 'gnu'\n version_pattern = r'GNU Fortran ((\\(GCC[^\\)]*(\\)\\)|\\)))|)\\s*'\\\n '(?P[^\\s*\\)]+)'\n\n # 'g77 --version' results\n # SunOS: GNU Fortran (GCC 3.2) 3.2 20020814 (release)\n # Debian: GNU Fortran (GCC) 3.3.3 20040110 (prerelease) (Debian)\n # GNU Fortran 0.5.25 20010319 (prerelease)\n # Redhat: GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)\n\n for fc_exe in map(find_executable,['g77','f77']):\n if os.path.isfile(fc_exe):\n break\n executables = {\n 'version_cmd' : [fc_exe,\"--version\"],\n 'compiler_f77' : [fc_exe,\"-Wall\",\"-fno-second-underscore\"],\n 'compiler_f90' : None,\n 'compiler_fix' : None,\n 'linker_so' : [fc_exe],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"],\n }\n module_dir_switch = None\n module_include_switch = None\n\n # Cygwin: f771: warning: -fPIC ignored for target (all code is position independent)\n if os.name != 'nt' and sys.platform!='cygwin':\n pic_flags = ['-fPIC']\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if re.match(r'(darwin)', sys.platform):\n return\n return FCompiler.get_linker_so(self)\n\n def get_flags_linker_so(self):\n opt = FCompiler.get_flags_linker_so(self)\n if not re.match(r'(darwin)', sys.platform):\n opt.append(\"-shared\")\n if sys.platform[:5]=='sunos':\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work. 'man gcc' says:\n # \".. Instead of using -mimpure-text, you should compile all\n # source code with -fpic or -fPIC.\"\n opt.append('-mimpure-text')\n return opt\n\n def get_libgcc_dir(self):\n status, output = self.exec_command('%s -print-libgcc-file-name' \\\n % (self.compiler_f77[0]),use_tee=0) \n if not status:\n return os.path.dirname(output)\n return\n\n def get_library_dirs(self):\n opt = FCompiler.get_library_dirs(self)\n if sys.platform[:5] != 'linux':\n d = self.get_libgcc_dir()\n if d:\n opt.append(d)\n return opt\n\n def get_libraries(self):\n opt = FCompiler.get_libraries(self)\n d = self.get_libgcc_dir()\n if d is not None:\n for g2c in ['g2c-pic','g2c']:\n f = self.static_lib_format % (g2c, self.static_lib_extension)\n if os.path.isfile(os.path.join(d,f)):\n break\n else:\n g2c = 'g2c'\n if sys.platform=='win32':\n opt.extend(['gcc',g2c])\n else:\n opt.append(g2c)\n return opt\n\n def get_flags_debug(self):\n return ['-g']\n\n def get_flags_opt(self):\n opt = ['-O3','-funroll-loops']\n return opt\n\n def get_flags_arch(self):\n opt = []\n if sys.platform=='darwin':\n if os.name != 'posix':\n # this should presumably correspond to Apple\n if cpu.is_ppc():\n opt.append('-arch ppc')\n elif cpu.is_i386():\n opt.append('-arch i386')\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt.append('-mcpu='+a)\n opt.append('-mtune='+a)\n break \n return opt\n march_flag = 1\n # 0.5.25 corresponds to 2.95.x\n if self.get_version() == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt.append('-march=k6')\n elif cpu.is_AthlonK7():\n opt.append('-march=athlon')\n else:\n march_flag = 0\n # Note: gcc 3.2 on win32 has breakage with -march specified\n elif self.get_version() >= '3.1.1' \\\n and not sys.platform=='win32': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt.append('-march=k6')\n elif cpu.is_AthlonK6_2():\n opt.append('-march=k6-2')\n elif cpu.is_AthlonK6_3():\n opt.append('-march=k6-3')\n elif cpu.is_AthlonK7():\n opt.append('-march=athlon')\n elif cpu.is_AthlonMP():\n opt.append('-march=athlon-mp')\n # there's also: athlon-tbird, athlon-4, athlon-xp\n elif cpu.is_PentiumIV():\n opt.append('-march=pentium4')\n elif cpu.is_PentiumIII():\n opt.append('-march=pentium3')\n elif cpu.is_PentiumII():\n opt.append('-march=pentium2')\n else:\n march_flag = 0\n if cpu.has_mmx(): opt.append('-mmmx') \n if self.get_version() > '3.2.2':\n if cpu.has_sse2(): opt.append('-msse2')\n if cpu.has_sse(): opt.append('-msse')\n if cpu.has_3dnow(): opt.append('-m3dnow')\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt.append('-march=i686')\n elif cpu.is_i586():\n opt.append('-march=i586')\n elif cpu.is_i486():\n opt.append('-march=i486')\n elif cpu.is_i386():\n opt.append('-march=i386')\n if cpu.is_Intel():\n opt.extend(['-malign-double','-fomit-frame-pointer'])\n return opt\n\nif __name__ == '__main__':\n from scipy_distutils import log\n log.set_verbosity(2)\n from fcompiler import new_fcompiler\n #compiler = new_fcompiler(compiler='gnu')\n compiler = GnuFCompiler()\n compiler.customize()\n print compiler.get_version()\n", "methods": [ { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "gnufcompiler.py", "nloc": 4, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 41, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "gnufcompiler.py", "nloc": 7, "complexity": 3, "token_count": 52, "parameters": [ "self" ], "start_line": 48, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_libgcc_dir", "long_name": "get_libgcc_dir( self )", "filename": "gnufcompiler.py", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "self" ], "start_line": 62, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "gnufcompiler.py", "nloc": 7, "complexity": 3, "token_count": 38, "parameters": [ "self" ], "start_line": 69, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "gnufcompiler.py", "nloc": 15, "complexity": 5, "token_count": 96, "parameters": [ "self" ], "start_line": 77, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "gnufcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 93, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "gnufcompiler.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 96, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "gnufcompiler.py", "nloc": 63, "complexity": 31, "token_count": 401, "parameters": [ "self" ], "start_line": 100, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 67, "top_nesting_level": 1 } ], "methods_before": [ { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "gnufcompiler.py", "nloc": 4, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 41, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "gnufcompiler.py", "nloc": 7, "complexity": 3, "token_count": 52, "parameters": [ "self" ], "start_line": 48, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_libgcc_dir", "long_name": "get_libgcc_dir( self )", "filename": "gnufcompiler.py", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "self" ], "start_line": 62, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "gnufcompiler.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 69, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "gnufcompiler.py", "nloc": 15, "complexity": 5, "token_count": 100, "parameters": [ "self" ], "start_line": 77, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "gnufcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 93, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "gnufcompiler.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 96, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "gnufcompiler.py", "nloc": 63, "complexity": 31, "token_count": 401, "parameters": [ "self" ], "start_line": 100, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 67, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "gnufcompiler.py", "nloc": 15, "complexity": 5, "token_count": 96, "parameters": [ "self" ], "start_line": 77, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "gnufcompiler.py", "nloc": 7, "complexity": 3, "token_count": 38, "parameters": [ "self" ], "start_line": 69, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "nloc": 140, "complexity": 48, "token_count": 854, "diff_parsed": { "added": [ " opt = []", " opt = []" ], "deleted": [ " opt = FCompiler.get_library_dirs(self)", " opt = FCompiler.get_libraries(self)" ] } }, { "old_path": "scipy_distutils/laheyfcompiler.py", "new_path": "scipy_distutils/laheyfcompiler.py", "filename": "laheyfcompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -27,13 +27,13 @@ def get_flags_opt(self):\n def get_flags_debug(self):\n return ['-g','--chk','--chkglobal']\n def get_library_dirs(self):\n- opt = FCompiler.get_library_dirs(self)\n+ opt = []\n d = os.environ.get('LAHEY')\n if d:\n opt.append(os.path.join(d,'lib'))\n return opt\n def get_libraries(self):\n- opt = FCompiler.get_libraries(self)\n+ opt = []\n opt.extend(['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6'])\n return opt\n \n", "added_lines": 2, "deleted_lines": 2, "source_code": "import os\nimport sys\n\nfrom cpuinfo import cpu\nfrom fcompiler import FCompiler\n\nclass LaheyFCompiler(FCompiler):\n\n compiler_type = 'lahey'\n version_pattern = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n executables = {\n 'version_cmd' : [\"lf95\", \"--version\"],\n 'compiler_f77' : [\"lf95\", \"--fix\"],\n 'compiler_fix' : [\"lf95\", \"--fix\"],\n 'compiler_f90' : [\"lf95\"],\n 'linker_so' : [\"lf95\",\"-shared\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"]\n }\n\n module_dir_switch = None #XXX Fix me\n module_include_switch = None #XXX Fix me\n\n def get_flags_opt(self):\n return ['-O']\n def get_flags_debug(self):\n return ['-g','--chk','--chkglobal']\n def get_library_dirs(self):\n opt = []\n d = os.environ.get('LAHEY')\n if d:\n opt.append(os.path.join(d,'lib'))\n return opt\n def get_libraries(self):\n opt = []\n opt.extend(['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6'])\n return opt\n\nif __name__ == '__main__':\n from distutils import log\n log.set_verbosity(2)\n from fcompiler import new_fcompiler\n compiler = new_fcompiler(compiler='lahey')\n compiler.customize()\n print compiler.get_version()\n", "source_code_before": "import os\nimport sys\n\nfrom cpuinfo import cpu\nfrom fcompiler import FCompiler\n\nclass LaheyFCompiler(FCompiler):\n\n compiler_type = 'lahey'\n version_pattern = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n executables = {\n 'version_cmd' : [\"lf95\", \"--version\"],\n 'compiler_f77' : [\"lf95\", \"--fix\"],\n 'compiler_fix' : [\"lf95\", \"--fix\"],\n 'compiler_f90' : [\"lf95\"],\n 'linker_so' : [\"lf95\",\"-shared\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"]\n }\n\n module_dir_switch = None #XXX Fix me\n module_include_switch = None #XXX Fix me\n\n def get_flags_opt(self):\n return ['-O']\n def get_flags_debug(self):\n return ['-g','--chk','--chkglobal']\n def get_library_dirs(self):\n opt = FCompiler.get_library_dirs(self)\n d = os.environ.get('LAHEY')\n if d:\n opt.append(os.path.join(d,'lib'))\n return opt\n def get_libraries(self):\n opt = FCompiler.get_libraries(self)\n opt.extend(['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6'])\n return opt\n\nif __name__ == '__main__':\n from distutils import log\n log.set_verbosity(2)\n from fcompiler import new_fcompiler\n compiler = new_fcompiler(compiler='lahey')\n compiler.customize()\n print compiler.get_version()\n", "methods": [ { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "laheyfcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 25, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "laheyfcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 27, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "laheyfcompiler.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 29, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "laheyfcompiler.py", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 35, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 } ], "methods_before": [ { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "laheyfcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 25, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "laheyfcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 27, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "laheyfcompiler.py", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "self" ], "start_line": 29, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "laheyfcompiler.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 35, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "laheyfcompiler.py", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 35, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "laheyfcompiler.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 29, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "nloc": 39, "complexity": 5, "token_count": 214, "diff_parsed": { "added": [ " opt = []", " opt = []" ], "deleted": [ " opt = FCompiler.get_library_dirs(self)", " opt = FCompiler.get_libraries(self)" ] } }, { "old_path": "scipy_distutils/sunfcompiler.py", "new_path": "scipy_distutils/sunfcompiler.py", "filename": "sunfcompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -27,7 +27,7 @@ def get_opt(self):\n def get_arch(self):\n return ['-xtarget=generic']\n def get_libraries(self):\n- opt = FCompiler.get_libraries(self)\n+ opt = []\n opt.extend(['fsu','sunmath','mvec','f77compat'])\n return opt\n \n", "added_lines": 1, "deleted_lines": 1, "source_code": "import os\nimport sys\n\nfrom cpuinfo import cpu\nfrom fcompiler import FCompiler\n\nclass SunFCompiler(FCompiler):\n\n compiler_type = 'sun'\n version_pattern = r'(f90|f95): (Sun|Forte Developer 7) Fortran 95 (?P[^\\s]+).*'\n\n executables = {\n 'version_cmd' : [\"f90\", \"-V\"],\n 'compiler_f77' : [\"f90\", \"-f77\", \"-ftrap=%none\"],\n 'compiler_fix' : [\"f90\", \"-fixed\"],\n 'compiler_f90' : [\"f90\"],\n 'linker_so' : [\"f90\",\"-Bdynamic\",\"-G\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"]\n }\n module_dir_switch = '-moddir='\n module_include_switch = '-M'\n pic_flags = ['-xcode=pic32']\n\n def get_opt(self):\n return ['-fast','-dalign']\n def get_arch(self):\n return ['-xtarget=generic']\n def get_libraries(self):\n opt = []\n opt.extend(['fsu','sunmath','mvec','f77compat'])\n return opt\n\nif __name__ == '__main__':\n from scipy_distutils import log\n log.set_verbosity(2)\n from fcompiler import new_fcompiler\n compiler = new_fcompiler(compiler='sun')\n compiler.customize()\n print compiler.get_version()\n", "source_code_before": "import os\nimport sys\n\nfrom cpuinfo import cpu\nfrom fcompiler import FCompiler\n\nclass SunFCompiler(FCompiler):\n\n compiler_type = 'sun'\n version_pattern = r'(f90|f95): (Sun|Forte Developer 7) Fortran 95 (?P[^\\s]+).*'\n\n executables = {\n 'version_cmd' : [\"f90\", \"-V\"],\n 'compiler_f77' : [\"f90\", \"-f77\", \"-ftrap=%none\"],\n 'compiler_fix' : [\"f90\", \"-fixed\"],\n 'compiler_f90' : [\"f90\"],\n 'linker_so' : [\"f90\",\"-Bdynamic\",\"-G\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"]\n }\n module_dir_switch = '-moddir='\n module_include_switch = '-M'\n pic_flags = ['-xcode=pic32']\n\n def get_opt(self):\n return ['-fast','-dalign']\n def get_arch(self):\n return ['-xtarget=generic']\n def get_libraries(self):\n opt = FCompiler.get_libraries(self)\n opt.extend(['fsu','sunmath','mvec','f77compat'])\n return opt\n\nif __name__ == '__main__':\n from scipy_distutils import log\n log.set_verbosity(2)\n from fcompiler import new_fcompiler\n compiler = new_fcompiler(compiler='sun')\n compiler.customize()\n print compiler.get_version()\n", "methods": [ { "name": "get_opt", "long_name": "get_opt( self )", "filename": "sunfcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 25, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_arch", "long_name": "get_arch( self )", "filename": "sunfcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 27, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "sunfcompiler.py", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 29, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 } ], "methods_before": [ { "name": "get_opt", "long_name": "get_opt( self )", "filename": "sunfcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 25, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_arch", "long_name": "get_arch( self )", "filename": "sunfcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 27, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "sunfcompiler.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 29, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "sunfcompiler.py", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 29, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 } ], "nloc": 34, "complexity": 3, "token_count": 181, "diff_parsed": { "added": [ " opt = []" ], "deleted": [ " opt = FCompiler.get_libraries(self)" ] } }, { "old_path": "scipy_distutils/system_info.py", "new_path": "scipy_distutils/system_info.py", "filename": "system_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -271,6 +271,7 @@ def get_info(self):\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n+ \n return res\n \n def get_paths(self, section, key):\n@@ -505,7 +506,7 @@ def calc_info(self):\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n-\n+ info['language'] = 'c'\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n@@ -547,6 +548,9 @@ def calc_info(self):\n *********************************************************************\n \"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n+ else:\n+ info['language'] = 'f77'\n+\n self.set_info(**info)\n \n class atlas_threads_info(atlas_info):\n@@ -573,6 +577,7 @@ def calc_info(self):\n break\n else:\n return\n+ info['language'] = 'f77'\n self.set_info(**info)\n \n class lapack_src_info(system_info):\n@@ -669,7 +674,7 @@ def calc_info(self):\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n- info = {'sources':sources}\n+ info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n \n \n@@ -689,6 +694,7 @@ def calc_info(self):\n break\n else:\n return\n+ info['language'] = 'f77' # XXX: is it generally true?\n self.set_info(**info)\n \n class blas_src_info(system_info):\n@@ -736,7 +742,7 @@ def calc_info(self):\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n- info = {'sources':sources}\n+ info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n \n class x11_info(system_info):\n@@ -853,8 +859,14 @@ def combine_paths(*args,**kws):\n print '(','paths:',','.join(result),')'\n return result\n \n+language_map = {'c':0,'c++':1,'f77':2,'f90':3}\n+inv_language_map = {0:'c',1:'c++',2:'f77',3:'f90'}\n def dict_append(d,**kws):\n+ languages = []\n for k,v in kws.items():\n+ if k=='language':\n+ languages.append(v)\n+ continue\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n@@ -862,6 +874,10 @@ def dict_append(d,**kws):\n d[k].extend(v)\n else:\n d[k] = v\n+ if languages:\n+ l = inv_language_map[max([language_map.get(l,0) for l in languages])]\n+ d['language'] = l\n+ return\n \n def show_all():\n import system_info\n", "added_lines": 19, "deleted_lines": 3, "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n atlas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'atlas_threads':atlas_threads_info,\n 'lapack_atlas_threads':lapack_atlas_threads_info,\n 'lapack_atlas':lapack_atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n \n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n d = os.environ[self.dir_env_var]\n if os.path.isfile(d):\n dirs = [os.path.dirname(d)] + dirs\n l = getattr(self,'_lib_names',[])\n if len(l)==1:\n b = os.path.basename(d)\n b = os.path.splitext(b)[0]\n if b[:3]=='lib':\n print 'Replacing _lib_names[0]==%r with %r' \\\n % (self._lib_names[0], b[3:])\n self._lib_names[0] = b[3:]\n else:\n dirs = d.split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n else:\n info['language'] = 'f77'\n\n self.set_info(**info)\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n _lib_names = ['lapack']\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', self._lib_names)\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n info['language'] = 'f77'\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n _lib_names = ['blas']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', self._lib_names)\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n info['language'] = 'f77' # XXX: is it generally true?\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32','cygwin']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n py_incl_dir = get_python_inc()\n include_dirs = [py_incl_dir]\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"%s\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\nlanguage_map = {'c':0,'c++':1,'f77':2,'f90':3}\ninv_language_map = {0:'c',1:'c++',2:'f77',3:'f90'}\ndef dict_append(d,**kws):\n languages = []\n for k,v in kws.items():\n if k=='language':\n languages.append(v)\n continue\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n if languages:\n l = inv_language_map[max([language_map.get(l,0) for l in languages])]\n d['language'] = l\n return\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n atlas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'atlas_threads':atlas_threads_info,\n 'lapack_atlas_threads':lapack_atlas_threads_info,\n 'lapack_atlas':lapack_atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n d = os.environ[self.dir_env_var]\n if os.path.isfile(d):\n dirs = [os.path.dirname(d)] + dirs\n l = getattr(self,'_lib_names',[])\n if len(l)==1:\n b = os.path.basename(d)\n b = os.path.splitext(b)[0]\n if b[:3]=='lib':\n print 'Replacing _lib_names[0]==%r with %r' \\\n % (self._lib_names[0], b[3:])\n self._lib_names[0] = b[3:]\n else:\n dirs = d.split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n self.set_info(**info)\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n _lib_names = ['lapack']\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', self._lib_names)\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n _lib_names = ['blas']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', self._lib_names)\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32','cygwin']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n py_incl_dir = get_python_inc()\n include_dirs = [py_incl_dir]\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"%s\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 21, "complexity": 1, "token_count": 100, "parameters": [ "name" ], "start_line": 120, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 218, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 244, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 247, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 153, "parameters": [ "self" ], "start_line": 250, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 23, "complexity": 10, "token_count": 252, "parameters": [ "self", "section", "key" ], "start_line": 277, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 301, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 304, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 307, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 310, "end_line": 315, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 317, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 328, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 338, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 342, "end_line": 351, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 353, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 363, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 366, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 432, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 439, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 467, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 78, "complexity": 17, "token_count": 441, "parameters": [ "self" ], "start_line": 475, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 569, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 587, "end_line": 592, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 232, "parameters": [ "self" ], "start_line": 594, "end_line": 678, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 686, "end_line": 698, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 704, "end_line": 709, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 106, "parameters": [ "self" ], "start_line": 711, "end_line": 746, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 751, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 116, "parameters": [ "self" ], "start_line": 756, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 781, "end_line": 791, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 793, "end_line": 821, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 836, "end_line": 860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 17, "complexity": 9, "token_count": 128, "parameters": [ "d", "kws" ], "start_line": 864, "end_line": 880, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 882, "end_line": 890, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 21, "complexity": 1, "token_count": 100, "parameters": [ "name" ], "start_line": 120, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 218, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 244, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 247, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 153, "parameters": [ "self" ], "start_line": 250, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 23, "complexity": 10, "token_count": 252, "parameters": [ "self", "section", "key" ], "start_line": 276, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 300, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 303, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 306, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 309, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 316, "end_line": 325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 327, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 337, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 341, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 352, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 362, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 365, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 431, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 438, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 466, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 75, "complexity": 17, "token_count": 427, "parameters": [ "self" ], "start_line": 474, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 565, "end_line": 576, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 582, "end_line": 587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 589, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 681, "end_line": 692, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 698, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 705, "end_line": 740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 745, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 116, "parameters": [ "self" ], "start_line": 750, "end_line": 769, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 775, "end_line": 785, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 787, "end_line": 815, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 830, "end_line": 854, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 856, "end_line": 864, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 866, "end_line": 874, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 17, "complexity": 9, "token_count": 128, "parameters": [ "d", "kws" ], "start_line": 864, "end_line": 880, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 153, "parameters": [ "self" ], "start_line": 250, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 78, "complexity": 17, "token_count": 441, "parameters": [ "self" ], "start_line": 475, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 } ], "nloc": 782, "complexity": 156, "token_count": 4117, "diff_parsed": { "added": [ "", " info['language'] = 'c'", " else:", " info['language'] = 'f77'", "", " info['language'] = 'f77'", " info = {'sources':sources,'language':'f77'}", " info['language'] = 'f77' # XXX: is it generally true?", " info = {'sources':sources,'language':'f77'}", "language_map = {'c':0,'c++':1,'f77':2,'f90':3}", "inv_language_map = {0:'c',1:'c++',2:'f77',3:'f90'}", " languages = []", " if k=='language':", " languages.append(v)", " continue", " if languages:", " l = inv_language_map[max([language_map.get(l,0) for l in languages])]", " d['language'] = l", " return" ], "deleted": [ "", " info = {'sources':sources}", " info = {'sources':sources}" ] } } ] }, { "hash": "0fd21ac1fa99608fd0d60764ea42688c2c7e7d96", "msg": "Merging build_src branch with HEAD.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-12T15:55:59+00:00", "author_timezone": 0, "committer_date": "2004-02-12T15:55:59+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": true, "parents": [ "e404137498444ef2807195408a4ec7de66b83ab9", "ba685a615e597b3070ba54dc9771d44277e886d2" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 3307, "insertions": 924, "lines": 4231, "files": 23, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null }, { "hash": "18518be6ea10c4e19e919575bc7292a564837f75", "msg": "Extension may specify f2py_options.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-12T17:32:42+00:00", "author_timezone": 0, "committer_date": "2004-02-12T17:32:42+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "0fd21ac1fa99608fd0d60764ea42688c2c7e7d96" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/command/build_src.py", "new_path": "scipy_distutils/command/build_src.py", "filename": "build_src.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -199,7 +199,7 @@ def f2py_sources(self, sources, extension):\n \n map(self.mkpath, target_dirs)\n \n- f2py_options = self.f2pyflags[:]\n+ f2py_options = extension.f2py_options + self.f2pyflags\n if f2py_sources:\n assert len(f2py_sources)==1,\\\n 'only one .pyf file is allowed per extension module but got'\\\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\" Build swig, f2py, weave, sources.\n\"\"\"\n\nimport os\nimport re\n\nfrom distutils.cmd import Command\nfrom distutils.command import build_ext, build_py\nfrom distutils.util import convert_path\nfrom distutils.dep_util import newer_group, newer\n\nfrom scipy_distutils import log\nfrom scipy_distutils.misc_util import fortran_ext_match\n\n\nclass build_src(build_ext.build_ext):\n\n description = \"build sources from SWIG, F2PY files or a function\"\n\n user_options = [\n ('build-src=', 'd', \"directory to \\\"build\\\" sources to\"),\n ('f2pyflags=', None, \"additonal flags to f2py\"),\n ('swigflags=', None, \"additional flags to swig\"),\n ('force', 'f', \"forcibly build everything (ignore file timestamps)\"),\n ('inplace', 'i',\n \"ignore build-lib and put compiled extensions into the source \" +\n \"directory alongside your pure Python modules\"),\n ]\n\n boolean_options = ['force','inplace']\n\n help_options = []\n\n def initialize_options(self):\n self.extensions = None\n self.package = None\n self.py_modules = None\n self.build_src = None\n self.build_lib = None\n self.build_base = None\n self.force = None\n self.inplace = 0\n self.package_dir = None\n self.f2pyflags = None\n self.swigflags = None\n return\n\n def finalize_options(self):\n self.set_undefined_options('build',\n ('build_base', 'build_base'),\n ('build_lib', 'build_lib'),\n ('force', 'force'))\n if self.package is None:\n self.package = self.distribution.ext_package\n self.extensions = self.distribution.ext_modules\n self.py_modules = self.distribution.py_modules\n if self.build_src is None:\n self.build_src = os.path.join(self.build_base, 'src')\n\n # py_modules is used in build_py.find_package_modules\n self.py_modules = {}\n\n if self.f2pyflags is None:\n self.f2pyflags = []\n else:\n self.f2pyflags = self.f2pyflags.split() # XXX spaces??\n\n if self.swigflags is None:\n self.swigflags = []\n else:\n self.swigflags = self.swigflags.split() # XXX spaces??\n return\n\n def run(self):\n if not self.extensions:\n return\n self.build_sources()\n return\n\n def build_sources(self):\n self.check_extensions_list(self.extensions)\n\n for ext in self.extensions:\n self.build_extension_sources(ext)\n return\n\n def build_extension_sources(self, ext):\n fullname = self.get_ext_fullname(ext.name)\n modpath = fullname.split('.')\n package = '.'.join(modpath[0:-1])\n\n sources = list(ext.sources)\n\n sources = self.generate_sources(sources, ext)\n\n sources = self.swig_sources(sources, ext)\n\n sources = self.f2py_sources(sources, ext)\n\n sources, py_files = self.filter_py_files(sources)\n\n if not self.py_modules.has_key(package):\n self.py_modules[package] = []\n modules = []\n for f in py_files:\n module = os.path.splitext(os.path.basename(f))[0]\n modules.append((package, module, f))\n self.py_modules[package] += modules\n\n ext.sources = sources\n return\n\n def generate_sources(self, sources, extension):\n new_sources = []\n func_sources = []\n for source in sources:\n if type(source) is type(''):\n new_sources.append(source)\n else:\n func_sources.append(source)\n if not func_sources:\n return new_sources\n if self.inplace:\n build_dir = '.'\n else:\n build_dir = self.build_src\n self.mkpath(build_dir)\n for func in func_sources:\n source = func(extension, build_dir)\n if type(source) is type([]):\n [log.info(' adding %s to sources.' % (s)) for s in source]\n new_sources.extend(source)\n else:\n log.info(' adding %s to sources.' % (source))\n new_sources.append(source)\n return new_sources\n\n def filter_py_files(self, sources):\n new_sources = []\n py_files = []\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext=='.py': \n py_files.append(source)\n else:\n new_sources.append(source)\n return new_sources, py_files\n\n def f2py_sources(self, sources, extension):\n new_sources = []\n f2py_sources = []\n f_sources = []\n f2py_targets = {}\n target_dirs = []\n ext_name = extension.name.split('.')[-1]\n skip_f2py = 0\n\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == '.pyf': # F2PY interface file\n if self.inplace:\n target_dir = os.path.dirname(base)\n else:\n target_dir = os.path.join(self.build_src,\n os.path.dirname(base))\n if os.path.isfile(source):\n name = get_f2py_modulename(source)\n assert name==ext_name,'mismatch of extension names: '\\\n +source+' provides'\\\n ' '+`name`+' but expected '+`ext_name`\n target_file = os.path.join(target_dir,name+'module.c')\n else:\n log.info(' source %s does not exist: skipping f2py\\'ing.' \\\n % (source))\n name = ext_name\n skip_f2py = 1\n target_file = os.path.join(target_dir,name+'module.c')\n if not os.path.isfile(target_file):\n log.info(' target %s does not exist:\\n '\\\n 'Assuming %smodule.c was generated with '\\\n '\"build_src --inplace\" command.' \\\n % (target_file, name))\n target_dir = os.path.dirname(base)\n target_file = os.path.join(target_dir,name+'module.c')\n assert os.path.isfile(target_file),`target_file`+' missing'\n log.info(' Yes! Using %s as up-to-date target.' \\\n % (target_file))\n target_dirs.append(target_dir)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n new_sources.append(target_file)\n elif fortran_ext_match(ext):\n f_sources.append(source)\n else:\n new_sources.append(source)\n\n if not (f2py_sources or f_sources):\n return new_sources\n\n map(self.mkpath, target_dirs)\n\n f2py_options = extension.f2py_options + self.f2pyflags\n if f2py_sources:\n assert len(f2py_sources)==1,\\\n 'only one .pyf file is allowed per extension module but got'\\\n ' more:'+`f2py_sources`\n source = f2py_sources[0]\n target_file = f2py_targets[source]\n target_dir = os.path.dirname(target_file)\n depends = [source] + extension.depends\n if (self.force or newer_group(depends, target_file,'newer')) \\\n and not skip_f2py:\n log.info(\" f2py'ing %s\", source)\n import f2py2e\n f2py2e.run_main(f2py_options + ['--build-dir',target_dir,source])\n else:\n log.info(\" skipping '%s' f2py interface (up-to-date)\" % (source))\n else:\n #XXX TODO: --inplace support for sdist command\n target_dir = self.build_src\n target_file = os.path.join(target_dir,ext_name + 'module.c')\n new_sources.append(target_file)\n depends = f_sources + extension.depends\n if (self.force or newer_group(depends, target_file, 'newer')) \\\n and not skip_f2py:\n import f2py2e\n log.info(\" f2py'ing fortran files for '%s'\" % (target_file))\n self.mkpath(target_dir)\n f2py2e.run_main(f2py_options + ['--lower',\n '--build-dir',target_dir]+\\\n ['-m',ext_name]+f_sources)\n else:\n log.info(\" skipping f2py fortran files for '%s' (up-to-date)\" % (target_file))\n\n assert os.path.isfile(target_file),`target_file`+' missing'\n\n target_c = os.path.join(self.build_src,'fortranobject.c')\n target_h = os.path.join(self.build_src,'fortranobject.h')\n log.info(' adding %s to sources.' % (target_c))\n new_sources.append(target_c)\n if self.build_src not in extension.include_dirs:\n log.info(\" adding %s to extension '%s' include_dirs.\"\\\n % (self.build_src,extension.name))\n extension.include_dirs.append(self.build_src)\n\n if not skip_f2py:\n import f2py2e\n d = os.path.dirname(f2py2e.__file__)\n source_c = os.path.join(d,'src','fortranobject.c')\n source_h = os.path.join(d,'src','fortranobject.h')\n if newer(source_c,target_c) or newer(source_h,target_h):\n self.mkpath(os.path.dirname(target_c))\n self.copy_file(source_c,target_c)\n self.copy_file(source_h,target_h)\n else:\n assert os.path.isfile(target_c),`target_c` + ' missing'\n assert os.path.isfile(target_h),`target_h` + ' missing'\n \n for name_ext in ['-f2pywrappers.f','-f2pywrappers2.f90']:\n filename = os.path.join(target_dir,ext_name + name_ext)\n if os.path.isfile(filename):\n log.info(' adding %s to sources.' % (filename))\n f_sources.append(filename)\n\n return new_sources + f_sources\n\n def swig_sources(self, sources, extension):\n new_sources = []\n swig_sources = []\n swig_targets = {}\n target_dirs = []\n py_files = [] # swig generated .py files\n target_ext = '.c'\n typ = None\n is_cpp = 0\n skip_swig = 0\n ext_name = extension.name.split('.')[-1]\n\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == '.i': # SWIG interface file\n if self.inplace:\n target_dir = os.path.dirname(base)\n else:\n target_dir = os.path.join(self.build_src,\n os.path.dirname(base))\n if os.path.isfile(source):\n name = get_swig_modulename(source)\n assert name==ext_name[1:],'mismatch of extension names: '\\\n +source+' provides'\\\n ' '+`name`+' but expected '+`ext_name[1:]`\n if typ is None:\n typ = get_swig_target(source)\n is_cpp = typ=='c++'\n if is_cpp:\n target_ext = '.cpp'\n else:\n assert typ == get_swig_target(source),`typ`\n target_file = os.path.join(target_dir,'%s_wrap%s' \\\n % (name, target_ext))\n else:\n log.info(' source %s does not exist: skipping swig\\'ing.' \\\n % (source))\n name = ext_name[1:]\n skip_swig = 1\n target_file = _find_swig_target(target_dir, name)\n if not os.path.isfile(target_file):\n log.info(' target %s does not exist:\\n '\\\n 'Assuming %s_wrap.{c,cpp} was generated with '\\\n '\"build_src --inplace\" command.' \\\n % (target_file, name))\n target_dir = os.path.dirname(base)\n target_file = _find_swig_target(target_dir, name)\n assert os.path.isfile(target_file),`target_file`+' missing'\n log.info(' Yes! Using %s as up-to-date target.' \\\n % (target_file))\n target_dirs.append(target_dir)\n new_sources.append(target_file)\n py_files.append(os.path.join(target_dir,name+'.py'))\n swig_sources.append(source)\n swig_targets[source] = new_sources[-1]\n\n else:\n new_sources.append(source)\n\n if not swig_sources:\n return new_sources\n\n if skip_swig:\n return new_sources + py_files\n \n map(self.mkpath, target_dirs)\n swig = self.find_swig()\n swig_cmd = [swig, \"-python\"]\n if is_cpp:\n swig_cmd.append('-c++')\n for d in extension.include_dirs:\n swig_cmd.append('-I'+d)\n for source in swig_sources:\n target = swig_targets[source]\n depends = [source] + extension.depends\n if self.force or newer_group(depends, target, 'newer'):\n log.info(\" swigging %s to %s\", source, target)\n self.spawn(swig_cmd + self.swigflags + [\"-o\", target, source])\n else:\n log.info(\" skipping '%s' swig interface (up-to-date)\" \\\n % (source))\n\n return new_sources + py_files\n\n#### SWIG related auxiliary functions ####\n_swig_module_name_match = re.compile(r'\\s*%module\\s*(?P[\\w_]+)',\n re.I).match\n_has_c_header = re.compile(r'-[*]-\\s*c\\s*-[*]-',re.I).search\n_has_cpp_header = re.compile(r'-[*]-\\s*c[+][+]\\s*-[*]-',re.I).search\n\ndef get_swig_target(source):\n f = open(source,'r')\n result = 'c'\n line = f.readline()\n if _has_cpp_header(line):\n result = 'c++'\n if _has_c_header(line):\n result = 'c'\n f.close()\n return result\n\ndef get_swig_modulename(source):\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = _swig_module_name_match(line)\n if m:\n name = m.group('name')\n break\n f.close()\n return name\n\ndef _find_swig_target(target_dir,name):\n for ext in ['.cpp','.c']:\n target = os.path.join(target_dir,'%s_wrap%s' % (name, ext))\n if os.path.isfile(target):\n break\n return target\n\n#### F2PY related auxiliary functions ####\n\n_f2py_module_name_match = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',\n re.I).match\n_f2py_user_module_name_match = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\n\ndef get_f2py_modulename(source):\n name = None\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = _f2py_module_name_match(line)\n if m:\n if _f2py_user_module_name_match(line): # skip *__user__* names\n continue\n name = m.group('name')\n break\n f.close()\n return name\n\n##########################################\n", "source_code_before": "\"\"\" Build swig, f2py, weave, sources.\n\"\"\"\n\nimport os\nimport re\n\nfrom distutils.cmd import Command\nfrom distutils.command import build_ext, build_py\nfrom distutils.util import convert_path\nfrom distutils.dep_util import newer_group, newer\n\nfrom scipy_distutils import log\nfrom scipy_distutils.misc_util import fortran_ext_match\n\n\nclass build_src(build_ext.build_ext):\n\n description = \"build sources from SWIG, F2PY files or a function\"\n\n user_options = [\n ('build-src=', 'd', \"directory to \\\"build\\\" sources to\"),\n ('f2pyflags=', None, \"additonal flags to f2py\"),\n ('swigflags=', None, \"additional flags to swig\"),\n ('force', 'f', \"forcibly build everything (ignore file timestamps)\"),\n ('inplace', 'i',\n \"ignore build-lib and put compiled extensions into the source \" +\n \"directory alongside your pure Python modules\"),\n ]\n\n boolean_options = ['force','inplace']\n\n help_options = []\n\n def initialize_options(self):\n self.extensions = None\n self.package = None\n self.py_modules = None\n self.build_src = None\n self.build_lib = None\n self.build_base = None\n self.force = None\n self.inplace = 0\n self.package_dir = None\n self.f2pyflags = None\n self.swigflags = None\n return\n\n def finalize_options(self):\n self.set_undefined_options('build',\n ('build_base', 'build_base'),\n ('build_lib', 'build_lib'),\n ('force', 'force'))\n if self.package is None:\n self.package = self.distribution.ext_package\n self.extensions = self.distribution.ext_modules\n self.py_modules = self.distribution.py_modules\n if self.build_src is None:\n self.build_src = os.path.join(self.build_base, 'src')\n\n # py_modules is used in build_py.find_package_modules\n self.py_modules = {}\n\n if self.f2pyflags is None:\n self.f2pyflags = []\n else:\n self.f2pyflags = self.f2pyflags.split() # XXX spaces??\n\n if self.swigflags is None:\n self.swigflags = []\n else:\n self.swigflags = self.swigflags.split() # XXX spaces??\n return\n\n def run(self):\n if not self.extensions:\n return\n self.build_sources()\n return\n\n def build_sources(self):\n self.check_extensions_list(self.extensions)\n\n for ext in self.extensions:\n self.build_extension_sources(ext)\n return\n\n def build_extension_sources(self, ext):\n fullname = self.get_ext_fullname(ext.name)\n modpath = fullname.split('.')\n package = '.'.join(modpath[0:-1])\n\n sources = list(ext.sources)\n\n sources = self.generate_sources(sources, ext)\n\n sources = self.swig_sources(sources, ext)\n\n sources = self.f2py_sources(sources, ext)\n\n sources, py_files = self.filter_py_files(sources)\n\n if not self.py_modules.has_key(package):\n self.py_modules[package] = []\n modules = []\n for f in py_files:\n module = os.path.splitext(os.path.basename(f))[0]\n modules.append((package, module, f))\n self.py_modules[package] += modules\n\n ext.sources = sources\n return\n\n def generate_sources(self, sources, extension):\n new_sources = []\n func_sources = []\n for source in sources:\n if type(source) is type(''):\n new_sources.append(source)\n else:\n func_sources.append(source)\n if not func_sources:\n return new_sources\n if self.inplace:\n build_dir = '.'\n else:\n build_dir = self.build_src\n self.mkpath(build_dir)\n for func in func_sources:\n source = func(extension, build_dir)\n if type(source) is type([]):\n [log.info(' adding %s to sources.' % (s)) for s in source]\n new_sources.extend(source)\n else:\n log.info(' adding %s to sources.' % (source))\n new_sources.append(source)\n return new_sources\n\n def filter_py_files(self, sources):\n new_sources = []\n py_files = []\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext=='.py': \n py_files.append(source)\n else:\n new_sources.append(source)\n return new_sources, py_files\n\n def f2py_sources(self, sources, extension):\n new_sources = []\n f2py_sources = []\n f_sources = []\n f2py_targets = {}\n target_dirs = []\n ext_name = extension.name.split('.')[-1]\n skip_f2py = 0\n\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == '.pyf': # F2PY interface file\n if self.inplace:\n target_dir = os.path.dirname(base)\n else:\n target_dir = os.path.join(self.build_src,\n os.path.dirname(base))\n if os.path.isfile(source):\n name = get_f2py_modulename(source)\n assert name==ext_name,'mismatch of extension names: '\\\n +source+' provides'\\\n ' '+`name`+' but expected '+`ext_name`\n target_file = os.path.join(target_dir,name+'module.c')\n else:\n log.info(' source %s does not exist: skipping f2py\\'ing.' \\\n % (source))\n name = ext_name\n skip_f2py = 1\n target_file = os.path.join(target_dir,name+'module.c')\n if not os.path.isfile(target_file):\n log.info(' target %s does not exist:\\n '\\\n 'Assuming %smodule.c was generated with '\\\n '\"build_src --inplace\" command.' \\\n % (target_file, name))\n target_dir = os.path.dirname(base)\n target_file = os.path.join(target_dir,name+'module.c')\n assert os.path.isfile(target_file),`target_file`+' missing'\n log.info(' Yes! Using %s as up-to-date target.' \\\n % (target_file))\n target_dirs.append(target_dir)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n new_sources.append(target_file)\n elif fortran_ext_match(ext):\n f_sources.append(source)\n else:\n new_sources.append(source)\n\n if not (f2py_sources or f_sources):\n return new_sources\n\n map(self.mkpath, target_dirs)\n\n f2py_options = self.f2pyflags[:]\n if f2py_sources:\n assert len(f2py_sources)==1,\\\n 'only one .pyf file is allowed per extension module but got'\\\n ' more:'+`f2py_sources`\n source = f2py_sources[0]\n target_file = f2py_targets[source]\n target_dir = os.path.dirname(target_file)\n depends = [source] + extension.depends\n if (self.force or newer_group(depends, target_file,'newer')) \\\n and not skip_f2py:\n log.info(\" f2py'ing %s\", source)\n import f2py2e\n f2py2e.run_main(f2py_options + ['--build-dir',target_dir,source])\n else:\n log.info(\" skipping '%s' f2py interface (up-to-date)\" % (source))\n else:\n #XXX TODO: --inplace support for sdist command\n target_dir = self.build_src\n target_file = os.path.join(target_dir,ext_name + 'module.c')\n new_sources.append(target_file)\n depends = f_sources + extension.depends\n if (self.force or newer_group(depends, target_file, 'newer')) \\\n and not skip_f2py:\n import f2py2e\n log.info(\" f2py'ing fortran files for '%s'\" % (target_file))\n self.mkpath(target_dir)\n f2py2e.run_main(f2py_options + ['--lower',\n '--build-dir',target_dir]+\\\n ['-m',ext_name]+f_sources)\n else:\n log.info(\" skipping f2py fortran files for '%s' (up-to-date)\" % (target_file))\n\n assert os.path.isfile(target_file),`target_file`+' missing'\n\n target_c = os.path.join(self.build_src,'fortranobject.c')\n target_h = os.path.join(self.build_src,'fortranobject.h')\n log.info(' adding %s to sources.' % (target_c))\n new_sources.append(target_c)\n if self.build_src not in extension.include_dirs:\n log.info(\" adding %s to extension '%s' include_dirs.\"\\\n % (self.build_src,extension.name))\n extension.include_dirs.append(self.build_src)\n\n if not skip_f2py:\n import f2py2e\n d = os.path.dirname(f2py2e.__file__)\n source_c = os.path.join(d,'src','fortranobject.c')\n source_h = os.path.join(d,'src','fortranobject.h')\n if newer(source_c,target_c) or newer(source_h,target_h):\n self.mkpath(os.path.dirname(target_c))\n self.copy_file(source_c,target_c)\n self.copy_file(source_h,target_h)\n else:\n assert os.path.isfile(target_c),`target_c` + ' missing'\n assert os.path.isfile(target_h),`target_h` + ' missing'\n \n for name_ext in ['-f2pywrappers.f','-f2pywrappers2.f90']:\n filename = os.path.join(target_dir,ext_name + name_ext)\n if os.path.isfile(filename):\n log.info(' adding %s to sources.' % (filename))\n f_sources.append(filename)\n\n return new_sources + f_sources\n\n def swig_sources(self, sources, extension):\n new_sources = []\n swig_sources = []\n swig_targets = {}\n target_dirs = []\n py_files = [] # swig generated .py files\n target_ext = '.c'\n typ = None\n is_cpp = 0\n skip_swig = 0\n ext_name = extension.name.split('.')[-1]\n\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == '.i': # SWIG interface file\n if self.inplace:\n target_dir = os.path.dirname(base)\n else:\n target_dir = os.path.join(self.build_src,\n os.path.dirname(base))\n if os.path.isfile(source):\n name = get_swig_modulename(source)\n assert name==ext_name[1:],'mismatch of extension names: '\\\n +source+' provides'\\\n ' '+`name`+' but expected '+`ext_name[1:]`\n if typ is None:\n typ = get_swig_target(source)\n is_cpp = typ=='c++'\n if is_cpp:\n target_ext = '.cpp'\n else:\n assert typ == get_swig_target(source),`typ`\n target_file = os.path.join(target_dir,'%s_wrap%s' \\\n % (name, target_ext))\n else:\n log.info(' source %s does not exist: skipping swig\\'ing.' \\\n % (source))\n name = ext_name[1:]\n skip_swig = 1\n target_file = _find_swig_target(target_dir, name)\n if not os.path.isfile(target_file):\n log.info(' target %s does not exist:\\n '\\\n 'Assuming %s_wrap.{c,cpp} was generated with '\\\n '\"build_src --inplace\" command.' \\\n % (target_file, name))\n target_dir = os.path.dirname(base)\n target_file = _find_swig_target(target_dir, name)\n assert os.path.isfile(target_file),`target_file`+' missing'\n log.info(' Yes! Using %s as up-to-date target.' \\\n % (target_file))\n target_dirs.append(target_dir)\n new_sources.append(target_file)\n py_files.append(os.path.join(target_dir,name+'.py'))\n swig_sources.append(source)\n swig_targets[source] = new_sources[-1]\n\n else:\n new_sources.append(source)\n\n if not swig_sources:\n return new_sources\n\n if skip_swig:\n return new_sources + py_files\n \n map(self.mkpath, target_dirs)\n swig = self.find_swig()\n swig_cmd = [swig, \"-python\"]\n if is_cpp:\n swig_cmd.append('-c++')\n for d in extension.include_dirs:\n swig_cmd.append('-I'+d)\n for source in swig_sources:\n target = swig_targets[source]\n depends = [source] + extension.depends\n if self.force or newer_group(depends, target, 'newer'):\n log.info(\" swigging %s to %s\", source, target)\n self.spawn(swig_cmd + self.swigflags + [\"-o\", target, source])\n else:\n log.info(\" skipping '%s' swig interface (up-to-date)\" \\\n % (source))\n\n return new_sources + py_files\n\n#### SWIG related auxiliary functions ####\n_swig_module_name_match = re.compile(r'\\s*%module\\s*(?P[\\w_]+)',\n re.I).match\n_has_c_header = re.compile(r'-[*]-\\s*c\\s*-[*]-',re.I).search\n_has_cpp_header = re.compile(r'-[*]-\\s*c[+][+]\\s*-[*]-',re.I).search\n\ndef get_swig_target(source):\n f = open(source,'r')\n result = 'c'\n line = f.readline()\n if _has_cpp_header(line):\n result = 'c++'\n if _has_c_header(line):\n result = 'c'\n f.close()\n return result\n\ndef get_swig_modulename(source):\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = _swig_module_name_match(line)\n if m:\n name = m.group('name')\n break\n f.close()\n return name\n\ndef _find_swig_target(target_dir,name):\n for ext in ['.cpp','.c']:\n target = os.path.join(target_dir,'%s_wrap%s' % (name, ext))\n if os.path.isfile(target):\n break\n return target\n\n#### F2PY related auxiliary functions ####\n\n_f2py_module_name_match = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',\n re.I).match\n_f2py_user_module_name_match = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\n\ndef get_f2py_modulename(source):\n name = None\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = _f2py_module_name_match(line)\n if m:\n if _f2py_user_module_name_match(line): # skip *__user__* names\n continue\n name = m.group('name')\n break\n f.close()\n return name\n\n##########################################\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_src.py", "nloc": 13, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 34, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_src.py", "nloc": 21, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 48, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_src.py", "nloc": 5, "complexity": 2, "token_count": 18, "parameters": [ "self" ], "start_line": 74, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_sources", "long_name": "build_sources( self )", "filename": "build_src.py", "nloc": 5, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 80, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "build_extension_sources", "long_name": "build_extension_sources( self , ext )", "filename": "build_src.py", "nloc": 18, "complexity": 3, "token_count": 162, "parameters": [ "self", "ext" ], "start_line": 87, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "generate_sources", "long_name": "generate_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 24, "complexity": 8, "token_count": 141, "parameters": [ "self", "sources", "extension" ], "start_line": 113, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "filter_py_files", "long_name": "filter_py_files( self , sources )", "filename": "build_src.py", "nloc": 10, "complexity": 3, "token_count": 57, "parameters": [ "self", "sources" ], "start_line": 138, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 107, "complexity": 22, "token_count": 827, "parameters": [ "self", "sources", "extension" ], "start_line": 149, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 117, "top_nesting_level": 1 }, { "name": "swig_sources", "long_name": "swig_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 77, "complexity": 15, "token_count": 512, "parameters": [ "self", "sources", "extension" ], "start_line": 267, "end_line": 349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 83, "top_nesting_level": 1 }, { "name": "get_swig_target", "long_name": "get_swig_target( source )", "filename": "build_src.py", "nloc": 10, "complexity": 3, "token_count": 48, "parameters": [ "source" ], "start_line": 357, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "get_swig_modulename", "long_name": "get_swig_modulename( source )", "filename": "build_src.py", "nloc": 10, "complexity": 3, "token_count": 57, "parameters": [ "source" ], "start_line": 368, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "_find_swig_target", "long_name": "_find_swig_target( target_dir , name )", "filename": "build_src.py", "nloc": 6, "complexity": 3, "token_count": 47, "parameters": [ "target_dir", "name" ], "start_line": 379, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "get_f2py_modulename", "long_name": "get_f2py_modulename( source )", "filename": "build_src.py", "nloc": 13, "complexity": 4, "token_count": 65, "parameters": [ "source" ], "start_line": 393, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_src.py", "nloc": 13, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 34, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_src.py", "nloc": 21, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 48, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_src.py", "nloc": 5, "complexity": 2, "token_count": 18, "parameters": [ "self" ], "start_line": 74, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_sources", "long_name": "build_sources( self )", "filename": "build_src.py", "nloc": 5, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 80, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "build_extension_sources", "long_name": "build_extension_sources( self , ext )", "filename": "build_src.py", "nloc": 18, "complexity": 3, "token_count": 162, "parameters": [ "self", "ext" ], "start_line": 87, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "generate_sources", "long_name": "generate_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 24, "complexity": 8, "token_count": 141, "parameters": [ "self", "sources", "extension" ], "start_line": 113, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "filter_py_files", "long_name": "filter_py_files( self , sources )", "filename": "build_src.py", "nloc": 10, "complexity": 3, "token_count": 57, "parameters": [ "self", "sources" ], "start_line": 138, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 107, "complexity": 22, "token_count": 826, "parameters": [ "self", "sources", "extension" ], "start_line": 149, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 117, "top_nesting_level": 1 }, { "name": "swig_sources", "long_name": "swig_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 77, "complexity": 15, "token_count": 512, "parameters": [ "self", "sources", "extension" ], "start_line": 267, "end_line": 349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 83, "top_nesting_level": 1 }, { "name": "get_swig_target", "long_name": "get_swig_target( source )", "filename": "build_src.py", "nloc": 10, "complexity": 3, "token_count": 48, "parameters": [ "source" ], "start_line": 357, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "get_swig_modulename", "long_name": "get_swig_modulename( source )", "filename": "build_src.py", "nloc": 10, "complexity": 3, "token_count": 57, "parameters": [ "source" ], "start_line": 368, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "_find_swig_target", "long_name": "_find_swig_target( target_dir , name )", "filename": "build_src.py", "nloc": 6, "complexity": 3, "token_count": 47, "parameters": [ "target_dir", "name" ], "start_line": 379, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "get_f2py_modulename", "long_name": "get_f2py_modulename( source )", "filename": "build_src.py", "nloc": 13, "complexity": 4, "token_count": 65, "parameters": [ "source" ], "start_line": 393, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 107, "complexity": 22, "token_count": 827, "parameters": [ "self", "sources", "extension" ], "start_line": 149, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 117, "top_nesting_level": 1 } ], "nloc": 350, "complexity": 74, "token_count": 2368, "diff_parsed": { "added": [ " f2py_options = extension.f2py_options + self.f2pyflags" ], "deleted": [ " f2py_options = self.f2pyflags[:]" ] } } ] }, { "hash": "ff9090a202eb1f66f58962615c2a8b3a003c106b", "msg": "Fixed 'invalid distribution option 'fortran_libraries'' error", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-13T12:42:38+00:00", "author_timezone": 0, "committer_date": "2004-02-13T12:42:38+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "18518be6ea10c4e19e919575bc7292a564837f75" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 2, "insertions": 3, "lines": 5, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/core.py", "new_path": "scipy_distutils/core.py", "filename": "core.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -38,8 +38,9 @@ def setup(**attr):\n if not new_attr.has_key('distclass'):\n new_attr['distclass'] = distclass \n \n- fortran_libraries = new_attr.get('fortran_libraries',[])\n- if fortran_libraries:\n+ fortran_libraries = new_attr.get('fortran_libraries',None)\n+\n+ if fortran_libraries is not None:\n print 64*'*'+\"\"\"\n Using fortran_libraries setup option is depreciated\n ---------------------------------------------------\n", "added_lines": 3, "deleted_lines": 2, "source_code": "\nfrom distutils.core import *\nfrom distutils.core import setup as old_setup\n\nfrom scipy_distutils.dist import Distribution\nfrom scipy_distutils.extension import Extension\nfrom scipy_distutils.command import build\nfrom scipy_distutils.command import build_py\nfrom scipy_distutils.command import config_compiler\nfrom scipy_distutils.command import build_ext\nfrom scipy_distutils.command import build_clib\nfrom scipy_distutils.command import build_src\nfrom scipy_distutils.command import sdist\nfrom scipy_distutils.command import install_data\nfrom scipy_distutils.command import install\nfrom scipy_distutils.command import install_headers\n\n\ndef setup(**attr):\n\n distclass = Distribution\n cmdclass = {'build': build.build,\n 'build_src': build_src.build_src,\n 'config_fc': config_compiler.config_fc,\n 'build_ext': build_ext.build_ext,\n 'build_py': build_py.build_py, \n 'build_clib': build_clib.build_clib,\n 'sdist': sdist.sdist,\n 'install_data': install_data.install_data,\n 'install': install.install,\n 'install_headers': install_headers.install_headers\n }\n new_attr = attr.copy()\n if new_attr.has_key('cmdclass'):\n cmdclass.update(new_attr['cmdclass']) \n new_attr['cmdclass'] = cmdclass\n \n if not new_attr.has_key('distclass'):\n new_attr['distclass'] = distclass \n\n fortran_libraries = new_attr.get('fortran_libraries',None)\n\n if fortran_libraries is not None:\n print 64*'*'+\"\"\"\n Using fortran_libraries setup option is depreciated\n ---------------------------------------------------\n Use libraries option instead. Yes, scipy_distutils\n now supports Fortran sources in libraries.\n\"\"\"+64*'*'\n new_attr['libraries'].extend(fortran_libraries)\n del new_attr['fortran_libraries']\n\n return old_setup(**new_attr)\n", "source_code_before": "\nfrom distutils.core import *\nfrom distutils.core import setup as old_setup\n\nfrom scipy_distutils.dist import Distribution\nfrom scipy_distutils.extension import Extension\nfrom scipy_distutils.command import build\nfrom scipy_distutils.command import build_py\nfrom scipy_distutils.command import config_compiler\nfrom scipy_distutils.command import build_ext\nfrom scipy_distutils.command import build_clib\nfrom scipy_distutils.command import build_src\nfrom scipy_distutils.command import sdist\nfrom scipy_distutils.command import install_data\nfrom scipy_distutils.command import install\nfrom scipy_distutils.command import install_headers\n\n\ndef setup(**attr):\n\n distclass = Distribution\n cmdclass = {'build': build.build,\n 'build_src': build_src.build_src,\n 'config_fc': config_compiler.config_fc,\n 'build_ext': build_ext.build_ext,\n 'build_py': build_py.build_py, \n 'build_clib': build_clib.build_clib,\n 'sdist': sdist.sdist,\n 'install_data': install_data.install_data,\n 'install': install.install,\n 'install_headers': install_headers.install_headers\n }\n new_attr = attr.copy()\n if new_attr.has_key('cmdclass'):\n cmdclass.update(new_attr['cmdclass']) \n new_attr['cmdclass'] = cmdclass\n \n if not new_attr.has_key('distclass'):\n new_attr['distclass'] = distclass \n\n fortran_libraries = new_attr.get('fortran_libraries',[])\n if fortran_libraries:\n print 64*'*'+\"\"\"\n Using fortran_libraries setup option is depreciated\n ---------------------------------------------------\n Use libraries option instead. Yes, scipy_distutils\n now supports Fortran sources in libraries.\n\"\"\"+64*'*'\n new_attr['libraries'].extend(fortran_libraries)\n del new_attr['fortran_libraries']\n\n return old_setup(**new_attr)\n", "methods": [ { "name": "setup", "long_name": "setup( ** attr )", "filename": "core.py", "nloc": 30, "complexity": 4, "token_count": 163, "parameters": [ "attr" ], "start_line": 19, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 } ], "methods_before": [ { "name": "setup", "long_name": "setup( ** attr )", "filename": "core.py", "nloc": 30, "complexity": 4, "token_count": 161, "parameters": [ "attr" ], "start_line": 19, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "setup", "long_name": "setup( ** attr )", "filename": "core.py", "nloc": 30, "complexity": 4, "token_count": 163, "parameters": [ "attr" ], "start_line": 19, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 } ], "nloc": 44, "complexity": 4, "token_count": 250, "diff_parsed": { "added": [ " fortran_libraries = new_attr.get('fortran_libraries',None)", "", " if fortran_libraries is not None:" ], "deleted": [ " fortran_libraries = new_attr.get('fortran_libraries',[])", " if fortran_libraries:" ] } } ] }, { "hash": "b4e50841564d2784f9be309c79244b76ff910b98", "msg": "Using prefix where Numeric is installed first.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-13T14:18:33+00:00", "author_timezone": 0, "committer_date": "2004-02-13T14:18:33+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "ff9090a202eb1f66f58962615c2a8b3a003c106b" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 1, "insertions": 12, "lines": 13, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/system_info.py", "new_path": "scipy_distutils/system_info.py", "filename": "system_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -780,8 +780,19 @@ class numpy_info(system_info):\n \n def __init__(self):\n from distutils.sysconfig import get_python_inc\n+ include_dirs = []\n+ try:\n+ module = __import__(self.modulename)\n+ prefix = []\n+ for name in module.__file__.split(os.sep):\n+ if name=='lib':\n+ break\n+ prefix.append(name)\n+ include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n+ except ImportError:\n+ pass\n py_incl_dir = get_python_inc()\n- include_dirs = [py_incl_dir]\n+ include_dirs.append(py_incl_dir)\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n", "added_lines": 12, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n atlas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'atlas_threads':atlas_threads_info,\n 'lapack_atlas_threads':lapack_atlas_threads_info,\n 'lapack_atlas':lapack_atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n \n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n d = os.environ[self.dir_env_var]\n if os.path.isfile(d):\n dirs = [os.path.dirname(d)] + dirs\n l = getattr(self,'_lib_names',[])\n if len(l)==1:\n b = os.path.basename(d)\n b = os.path.splitext(b)[0]\n if b[:3]=='lib':\n print 'Replacing _lib_names[0]==%r with %r' \\\n % (self._lib_names[0], b[3:])\n self._lib_names[0] = b[3:]\n else:\n dirs = d.split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n else:\n info['language'] = 'f77'\n\n self.set_info(**info)\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n _lib_names = ['lapack']\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', self._lib_names)\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n info['language'] = 'f77'\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n _lib_names = ['blas']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', self._lib_names)\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n info['language'] = 'f77' # XXX: is it generally true?\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32','cygwin']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n include_dirs = []\n try:\n module = __import__(self.modulename)\n prefix = []\n for name in module.__file__.split(os.sep):\n if name=='lib':\n break\n prefix.append(name)\n include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n except ImportError:\n pass\n py_incl_dir = get_python_inc()\n include_dirs.append(py_incl_dir)\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"%s\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\nlanguage_map = {'c':0,'c++':1,'f77':2,'f90':3}\ninv_language_map = {0:'c',1:'c++',2:'f77',3:'f90'}\ndef dict_append(d,**kws):\n languages = []\n for k,v in kws.items():\n if k=='language':\n languages.append(v)\n continue\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n if languages:\n l = inv_language_map[max([language_map.get(l,0) for l in languages])]\n d['language'] = l\n return\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n atlas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'atlas_threads':atlas_threads_info,\n 'lapack_atlas_threads':lapack_atlas_threads_info,\n 'lapack_atlas':lapack_atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n \n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n d = os.environ[self.dir_env_var]\n if os.path.isfile(d):\n dirs = [os.path.dirname(d)] + dirs\n l = getattr(self,'_lib_names',[])\n if len(l)==1:\n b = os.path.basename(d)\n b = os.path.splitext(b)[0]\n if b[:3]=='lib':\n print 'Replacing _lib_names[0]==%r with %r' \\\n % (self._lib_names[0], b[3:])\n self._lib_names[0] = b[3:]\n else:\n dirs = d.split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n else:\n info['language'] = 'f77'\n\n self.set_info(**info)\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n _lib_names = ['lapack']\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', self._lib_names)\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n info['language'] = 'f77'\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n _lib_names = ['blas']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', self._lib_names)\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n info['language'] = 'f77' # XXX: is it generally true?\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32','cygwin']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n py_incl_dir = get_python_inc()\n include_dirs = [py_incl_dir]\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"%s\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\nlanguage_map = {'c':0,'c++':1,'f77':2,'f90':3}\ninv_language_map = {0:'c',1:'c++',2:'f77',3:'f90'}\ndef dict_append(d,**kws):\n languages = []\n for k,v in kws.items():\n if k=='language':\n languages.append(v)\n continue\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n if languages:\n l = inv_language_map[max([language_map.get(l,0) for l in languages])]\n d['language'] = l\n return\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 21, "complexity": 1, "token_count": 100, "parameters": [ "name" ], "start_line": 120, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 218, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 244, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 247, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 153, "parameters": [ "self" ], "start_line": 250, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 23, "complexity": 10, "token_count": 252, "parameters": [ "self", "section", "key" ], "start_line": 277, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 301, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 304, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 307, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 310, "end_line": 315, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 317, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 328, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 338, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 342, "end_line": 351, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 353, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 363, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 366, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 432, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 439, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 467, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 78, "complexity": 17, "token_count": 441, "parameters": [ "self" ], "start_line": 475, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 569, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 587, "end_line": 592, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 232, "parameters": [ "self" ], "start_line": 594, "end_line": 678, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 686, "end_line": 698, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 704, "end_line": 709, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 106, "parameters": [ "self" ], "start_line": 711, "end_line": 746, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 751, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 116, "parameters": [ "self" ], "start_line": 756, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 139, "parameters": [ "self" ], "start_line": 781, "end_line": 802, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 804, "end_line": 832, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 847, "end_line": 871, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 17, "complexity": 9, "token_count": 128, "parameters": [ "d", "kws" ], "start_line": 875, "end_line": 891, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 893, "end_line": 901, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 21, "complexity": 1, "token_count": 100, "parameters": [ "name" ], "start_line": 120, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 218, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 244, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 247, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 153, "parameters": [ "self" ], "start_line": 250, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 23, "complexity": 10, "token_count": 252, "parameters": [ "self", "section", "key" ], "start_line": 277, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 301, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 304, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 307, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 310, "end_line": 315, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 317, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 328, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 338, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 342, "end_line": 351, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 353, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 363, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 366, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 432, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 439, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 467, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 78, "complexity": 17, "token_count": 441, "parameters": [ "self" ], "start_line": 475, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 569, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 587, "end_line": 592, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 232, "parameters": [ "self" ], "start_line": 594, "end_line": 678, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 686, "end_line": 698, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 704, "end_line": 709, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 106, "parameters": [ "self" ], "start_line": 711, "end_line": 746, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 751, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 116, "parameters": [ "self" ], "start_line": 756, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 781, "end_line": 791, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 793, "end_line": 821, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 836, "end_line": 860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 17, "complexity": 9, "token_count": 128, "parameters": [ "d", "kws" ], "start_line": 864, "end_line": 880, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 882, "end_line": 890, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 139, "parameters": [ "self" ], "start_line": 781, "end_line": 802, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 } ], "nloc": 793, "complexity": 159, "token_count": 4184, "diff_parsed": { "added": [ " include_dirs = []", " try:", " module = __import__(self.modulename)", " prefix = []", " for name in module.__file__.split(os.sep):", " if name=='lib':", " break", " prefix.append(name)", " include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))", " except ImportError:", " pass", " include_dirs.append(py_incl_dir)" ], "deleted": [ " include_dirs = [py_incl_dir]" ] } } ] }, { "hash": "c74322b996d922f02bcc51d52a0d23083da3f072", "msg": "Disableing scipy_distutils hooks in case distutils has been imported before, otherwise I cannot predict what will happen..", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-02-13T15:44:35+00:00", "author_timezone": 0, "committer_date": "2004-02-13T15:44:35+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "b4e50841564d2784f9be309c79244b76ff910b98" ], "project_name": "repo_copy", "project_path": "/tmp/tmpbqgekc6k/repo_copy", "deletions": 10, "insertions": 11, "lines": 21, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/__init__.py", "new_path": "scipy_distutils/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -10,13 +10,14 @@\n \n import sys\n \n-# Replace distutils.ccompiler with scipy_distutils.ccompiler\n-assert not sys.modules.has_key('distutils.ccompiler'),\\\n- 'distutils has been imported before scipy_distutils'\n-import ccompiler\n-sys.modules['distutils.ccompiler'] = ccompiler\n-\n-assert not sys.modules.has_key('distutils.unixccompiler'),\\\n- 'cannot override distutils.unixccompiler'\n-import unixccompiler\n-sys.modules['distutils.unixccompiler'] = unixccompiler\n+if not sys.modules.has_key('distutils'):\n+ # Replace distutils.ccompiler with scipy_distutils.ccompiler\n+ assert not sys.modules.has_key('distutils.ccompiler'),\\\n+ 'distutils has been imported before scipy_distutils'\n+ import ccompiler\n+ sys.modules['distutils.ccompiler'] = ccompiler\n+ \n+ assert not sys.modules.has_key('distutils.unixccompiler'),\\\n+ 'cannot override distutils.unixccompiler'\n+ import unixccompiler\n+ sys.modules['distutils.unixccompiler'] = unixccompiler\n", "added_lines": 11, "deleted_lines": 10, "source_code": "\"\"\"scipy_distutils\n\n Modified version of distutils to handle fortran source code, f2py,\n and other issues in the scipy build process.\n\"\"\"\n\n# Need to do something here to get distutils subsumed...\n\nfrom scipy_distutils_version import scipy_distutils_version as __version__\n\nimport sys\n\nif not sys.modules.has_key('distutils'):\n # Replace distutils.ccompiler with scipy_distutils.ccompiler\n assert not sys.modules.has_key('distutils.ccompiler'),\\\n 'distutils has been imported before scipy_distutils'\n import ccompiler\n sys.modules['distutils.ccompiler'] = ccompiler\n \n assert not sys.modules.has_key('distutils.unixccompiler'),\\\n 'cannot override distutils.unixccompiler'\n import unixccompiler\n sys.modules['distutils.unixccompiler'] = unixccompiler\n", "source_code_before": "\"\"\"scipy_distutils\n\n Modified version of distutils to handle fortran source code, f2py,\n and other issues in the scipy build process.\n\"\"\"\n\n# Need to do something here to get distutils subsumed...\n\nfrom scipy_distutils_version import scipy_distutils_version as __version__\n\nimport sys\n\n# Replace distutils.ccompiler with scipy_distutils.ccompiler\nassert not sys.modules.has_key('distutils.ccompiler'),\\\n 'distutils has been imported before scipy_distutils'\nimport ccompiler\nsys.modules['distutils.ccompiler'] = ccompiler\n\nassert not sys.modules.has_key('distutils.unixccompiler'),\\\n 'cannot override distutils.unixccompiler'\nimport unixccompiler\nsys.modules['distutils.unixccompiler'] = unixccompiler\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 16, "complexity": 0, "token_count": 66, "diff_parsed": { "added": [ "if not sys.modules.has_key('distutils'):", " # Replace distutils.ccompiler with scipy_distutils.ccompiler", " assert not sys.modules.has_key('distutils.ccompiler'),\\", " 'distutils has been imported before scipy_distutils'", " import ccompiler", " sys.modules['distutils.ccompiler'] = ccompiler", "", " assert not sys.modules.has_key('distutils.unixccompiler'),\\", " 'cannot override distutils.unixccompiler'", " import unixccompiler", " sys.modules['distutils.unixccompiler'] = unixccompiler" ], "deleted": [ "# Replace distutils.ccompiler with scipy_distutils.ccompiler", "assert not sys.modules.has_key('distutils.ccompiler'),\\", " 'distutils has been imported before scipy_distutils'", "import ccompiler", "sys.modules['distutils.ccompiler'] = ccompiler", "", "assert not sys.modules.has_key('distutils.unixccompiler'),\\", " 'cannot override distutils.unixccompiler'", "import unixccompiler", "sys.modules['distutils.unixccompiler'] = unixccompiler" ] } } ] } ]