[ { "hash": "2b514abd3d8590aac40c400fc6f043a36e136bed", "msg": "Sun version of anydbm (and maybe others) croaked whenever db's were opened with more the one mode flag such as 'cr', or 'cw'. Now only one mode is allowed at a time, and 'c' is used whenever a db needs to be created.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-01-06T21:15:43+00:00", "author_timezone": 0, "committer_date": "2002-01-06T21:15:43+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "0074d56dca0d99f7bed07ea9d7bf61dbde828209" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 6, "insertions": 9, "lines": 15, "files": 2, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/catalog.py", "new_path": "weave/catalog.py", "filename": "catalog.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -189,14 +189,16 @@ def get_catalog(module_path,mode='r'):\n If module_path is a directory, the function catalog returned is\n from that directory. If module_path is an actual module_name,\n then the function catalog returned is from its parent directory.\n- mode uses the standard 'c' = create, 'r' = read, 'w' = write\n- file open modes.\n+ mode uses the standard 'c' = create, 'n' = new, 'r' = read, \n+ 'w' = write file open modes available for anydbm databases.\n \n See catalog_path() for more information on module_path.\n \"\"\"\n+ if mode not in ['c','r','w','n']:\n+ msg = \" mode must be 'c', 'n', 'r', or 'w'. See anydbm for more info\"\n+ raise ValueError, msg\n catalog_file = catalog_path(module_path)\n- #print catalog_file\n- #sh = shelve.open(catalog_file,mode)\n+ #print catalog_file,mode\n try:\n sh = shelve.open(catalog_file,mode)\n except: # not sure how to pin down which error to catch yet\n@@ -542,7 +544,7 @@ def add_function_persistent(self,code,function):\n matter what the user's Python path is.\n \"\"\" \n # add function to data in first writable catalog\n- mode = 'cw' # create, write\n+ mode = 'c' # create if doesn't exist, otherwise, use existing\n cat_file = self.get_writable_dir()\n cat = get_catalog(cat_file,mode)\n if cat is None:\n", "added_lines": 7, "deleted_lines": 5, "source_code": "\"\"\" Track relationships between compiled extension functions & code fragments\n\n catalog keeps track of which compiled(or even standard) functions are \n related to which code fragments. It also stores these relationships\n to disk so they are remembered between Python sessions. When \n \n a = 1\n compiler.inline('printf(\"printed from C: %d\",a);',['a'] )\n \n is called, inline() first looks to see if it has seen the code \n 'printf(\"printed from C\");' before. If not, it calls \n \n catalog.get_functions('printf(\"printed from C: %d\", a);')\n \n which returns a list of all the function objects that have been compiled\n for the code fragment. Multiple functions can occur because the code\n could be compiled for different types for 'a' (although not likely in\n this case). The catalog first looks in its cache and quickly returns\n a list of the functions if possible. If the cache lookup fails, it then\n looks through possibly multiple catalog files on disk and fills its\n cache with all the functions that match the code fragment. \n \n In case where the code fragment hasn't been compiled, inline() compiles\n the code and then adds it to the catalog:\n \n function = \n catalog.add_function('printf(\"printed from C: %d\", a);',function)\n \n add_function() adds function to the front of the cache. function,\n along with the path information to its module, are also stored in a\n persistent catalog for future use by python sessions. \n\"\"\" \n\nimport os,sys,string\nimport shelve\n\ndef getmodule(object):\n \"\"\" Discover the name of the module where object was defined.\n \n This is an augmented version of inspect.getmodule that can discover \n the parent module for extension functions.\n \"\"\"\n import inspect\n value = inspect.getmodule(object)\n if value is None:\n #walk trough all modules looking for function\n for name,mod in sys.modules.items():\n # try except used because of some comparison failures\n # in wxPoint code. Need to review this\n try:\n if mod and object in mod.__dict__.values():\n value = mod\n # if it is a built-in module, keep looking to see\n # if a non-builtin also has it. Otherwise quit and\n # consider the module found. (ain't perfect, but will \n # have to do for now).\n if string.find('(built-in)',str(mod)) is -1:\n break\n \n except TypeError:\n pass \n return value\n\ndef expr_to_filename(expr):\n \"\"\" Convert an arbitrary expr string to a valid file name.\n \n The name is based on the md5 check sum for the string and\n Something that was a little more human readable would be \n nice, but the computer doesn't seem to care.\n \"\"\"\n import md5\n base = 'sc_'\n return base + md5.new(expr).hexdigest()\n\ndef unique_file(d,expr):\n \"\"\" Generate a unqiue file name based on expr in directory d\n \n This is meant for use with building extension modules, so\n a file name is considered unique if none of the following\n extension '.cpp','.o','.so','module.so','.py', or '.pyd'\n exists in directory d. The fully qualified path to the\n new name is returned. You'll need to append your own\n extension to it before creating files.\n \"\"\"\n files = os.listdir(d)\n #base = 'scipy_compile'\n base = expr_to_filename(expr)\n for i in range(1000000):\n fname = base + `i`\n if not (fname+'.cpp' in files or\n fname+'.o' in files or\n fname+'.so' in files or\n fname+'module.so' in files or\n fname+'.py' in files or\n fname+'.pyd' in files):\n break\n return os.path.join(d,fname)\n \ndef default_dir():\n \"\"\" Return a default location to store compiled files and catalogs.\n \n XX is the Python version number in all paths listed below\n On windows, the default location is the temporary directory\n returned by gettempdir()/pythonXX.\n \n On Unix, ~/.pythonXX_compiled is the default location. If it doesn't\n exist, it is created. The directory is marked rwx------.\n \n If for some reason it isn't possible to build a default directory\n in the user's home, /tmp/_pythonXX_compiled is used. If it \n doesn't exist, it is created. The directory is marked rwx------\n to try and keep people from being able to sneak a bad module\n in on you. \n \"\"\"\n import tempfile \n python_name = \"python%d%d_compiled\" % tuple(sys.version_info[:2]) \n if sys.platform != 'win32':\n try:\n path = os.path.join(os.environ['HOME'],'.' + python_name)\n except KeyError:\n temp_dir = `os.getuid()` + '_' + python_name\n path = os.path.join(tempfile.gettempdir(),temp_dir) \n else:\n path = os.path.join(tempfile.gettempdir(),python_name)\n \n if not os.path.exists(path):\n os.mkdir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not os.access(path,os.W_OK):\n print 'warning: default directory is not write accessible.'\n print 'defualt:', path\n return path\n\ndef default_temp_dir():\n path = os.path.join(default_dir(),'temp')\n if not os.path.exists(path):\n os.mkdir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not os.access(path,os.W_OK):\n print 'warning: default directory is not write accessible.'\n print 'defualt:', path\n return path\n\n \ndef os_dependent_catalog_name():\n \"\"\" Generate catalog name dependent on OS and Python version being used.\n \n This allows multiple platforms to have catalog files in the\n same directory without stepping on each other. For now, it \n bases the name of the value returned by sys.platform and the\n version of python being run. If this isn't enough to descriminate\n on some platforms, we can try to add other info. It has \n occured to me that if we get fancy enough to optimize for different\n architectures, then chip type might be added to the catalog name also.\n \"\"\"\n version = '%d%d' % sys.version_info[:2]\n return sys.platform+version+'compiled_catalog'\n \ndef catalog_path(module_path):\n \"\"\" Return the full path name for the catalog file in the given directory.\n \n module_path can either be a file name or a path name. If it is a \n file name, the catalog file name in its parent directory is returned.\n If it is a directory, the catalog file in that directory is returned.\n\n If module_path doesn't exist, None is returned. Note though, that the\n catalog file does *not* have to exist, only its parent. '~', shell\n variables, and relative ('.' and '..') paths are all acceptable.\n \n catalog file names are os dependent (based on sys.platform), so this \n should support multiple platforms sharing the same disk space \n (NFS mounts). See os_dependent_catalog_name() for more info.\n \"\"\"\n module_path = os.path.expanduser(module_path)\n module_path = os.path.expandvars(module_path)\n module_path = os.path.abspath(module_path)\n if not os.path.exists(module_path):\n catalog_file = None\n elif not os.path.isdir(module_path):\n module_path,dummy = os.path.split(module_path)\n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n else: \n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n return catalog_file\n\ndef get_catalog(module_path,mode='r'):\n \"\"\" Return a function catalog (shelve object) from the path module_path\n\n If module_path is a directory, the function catalog returned is\n from that directory. If module_path is an actual module_name,\n then the function catalog returned is from its parent directory.\n mode uses the standard 'c' = create, 'n' = new, 'r' = read, \n 'w' = write file open modes available for anydbm databases.\n \n See catalog_path() for more information on module_path.\n \"\"\"\n if mode not in ['c','r','w','n']:\n msg = \" mode must be 'c', 'n', 'r', or 'w'. See anydbm for more info\"\n raise ValueError, msg\n catalog_file = catalog_path(module_path)\n #print catalog_file,mode\n try:\n sh = shelve.open(catalog_file,mode)\n except: # not sure how to pin down which error to catch yet\n sh = None\n return sh\n\nclass catalog:\n \"\"\" Stores information about compiled functions both in cache and on disk.\n \n catalog stores (code, list_of_function) pairs so that all the functions\n that have been compiled for code are available for calling (usually in\n inline or blitz).\n \n catalog keeps a dictionary of previously accessed code values cached \n for quick access. It also handles the looking up of functions compiled \n in previously called Python sessions on disk in function catalogs. \n catalog searches the directories in the PYTHONCOMPILED environment \n variable in order loading functions that correspond to the given code \n fragment. A default directory is also searched for catalog functions. \n On unix, the default directory is usually '~/.pythonxx_compiled' where \n xx is the version of Python used. On windows, it is the directory \n returned by temfile.gettempdir(). Functions closer to the front are of \n the variable list are guaranteed to be closer to the front of the \n function list so that they will be called first. See \n get_cataloged_functions() for more info on how the search order is \n traversed.\n \n Catalog also handles storing information about compiled functions to\n a catalog. When writing this information, the first writable catalog\n file in PYTHONCOMPILED path is used. If a writable catalog is not\n found, it is written to the catalog in the default directory. This\n directory should always be writable.\n \"\"\"\n def __init__(self,user_path_list=None):\n \"\"\" Create a catalog for storing/searching for compiled functions. \n \n user_path_list contains directories that should be searched \n first for function catalogs. They will come before the path\n entries in the PYTHONCOMPILED environment varilable.\n \"\"\"\n if type(user_path_list) == type('string'):\n self.user_path_list = [user_path_list]\n elif user_path_list:\n self.user_path_list = user_path_list\n else:\n self.user_path_list = []\n self.cache = {}\n self.module_dir = None\n self.paths_added = 0\n \n def set_module_directory(self,module_dir):\n \"\"\" Set the path that will replace 'MODULE' in catalog searches.\n \n You should call clear_module_directory() when your finished\n working with it.\n \"\"\"\n self.module_dir = module_dir\n def get_module_directory(self):\n \"\"\" Return the path used to replace the 'MODULE' in searches.\n \"\"\"\n return self.module_dir\n def clear_module_directory(self):\n \"\"\" Reset 'MODULE' path to None so that it is ignored in searches. \n \"\"\"\n self.module_dir = None\n \n def get_environ_path(self):\n \"\"\" Return list of paths from 'PYTHONCOMPILED' environment variable.\n \n On Unix the path in PYTHONCOMPILED is a ':' separated list of\n directories. On Windows, a ';' separated list is used. \n \"\"\"\n paths = []\n if os.environ.has_key('PYTHONCOMPILED'):\n path_string = os.environ['PYTHONCOMPILED'] \n if sys.platform == 'win32':\n #probably should also look in registry\n paths = path_string.split(';')\n else: \n paths = path_string.split(':')\n return paths \n\n def build_search_order(self):\n \"\"\" Returns a list of paths that are searched for catalogs. \n \n Values specified in the catalog constructor are searched first,\n then values found in the PYTHONCOMPILED environment variable.\n The directory returned by default_dir() is always returned at\n the end of the list.\n \n There is a 'magic' path name called 'MODULE' that is replaced\n by the directory defined by set_module_directory(). If the\n module directory hasn't been set, 'MODULE' is ignored.\n \"\"\"\n \n paths = self.user_path_list + self.get_environ_path()\n search_order = []\n for path in paths:\n if path == 'MODULE':\n if self.module_dir:\n search_order.append(self.module_dir)\n else:\n search_order.append(path)\n search_order.append(default_dir())\n return search_order\n\n def get_catalog_files(self):\n \"\"\" Returns catalog file list in correct search order.\n \n Some of the catalog files may not currently exists.\n However, all will be valid locations for a catalog\n to be created (if you have write permission).\n \"\"\"\n files = map(catalog_path,self.build_search_order())\n files = filter(lambda x: x is not None,files)\n return files\n\n def get_existing_files(self):\n \"\"\" Returns all existing catalog file list in correct search order.\n \"\"\"\n files = self.get_catalog_files()\n existing_files = filter(os.path.exists,files)\n return existing_files\n\n def get_writable_file(self,existing_only=0):\n \"\"\" Return the name of the first writable catalog file.\n \n Its parent directory must also be writable. This is so that\n compiled modules can be written to the same directory.\n \"\"\"\n # note: both file and its parent directory must be writeable\n if existing_only:\n files = self.get_existing_files()\n else:\n files = self.get_catalog_files()\n # filter for (file exists and is writable) OR directory is writable\n def file_test(x):\n from os import access, F_OK, W_OK\n return (access(x,F_OK) and access(x,W_OK) or\n access(os.path.dirname(x),W_OK))\n writable = filter(file_test,files)\n if writable:\n file = writable[0]\n else:\n file = None\n return file\n \n def get_writable_dir(self):\n \"\"\" Return the parent directory of first writable catalog file.\n \n The returned directory has write access.\n \"\"\"\n return os.path.dirname(self.get_writable_file())\n \n def unique_module_name(self,code,module_dir=None):\n \"\"\" Return full path to unique file name that in writable location.\n \n The directory for the file is the first writable directory in \n the catalog search path. The unique file name is derived from\n the code fragment. If, module_dir is specified, it is used\n to replace 'MODULE' in the search path.\n \"\"\"\n if module_dir is not None:\n self.set_module_directory(module_dir)\n try:\n d = self.get_writable_dir()\n finally:\n if module_dir is not None:\n self.clear_module_directory()\n return unique_file(d,code)\n\n def path_key(self,code):\n \"\"\" Return key for path information for functions associated with code.\n \"\"\"\n return '__path__' + code\n \n def configure_path(self,cat,code):\n \"\"\" Add the python path for the given code to the sys.path\n \n unconfigure_path() should be called as soon as possible after\n imports associated with code are finished so that sys.path \n is restored to normal.\n \"\"\"\n try:\n paths = cat[self.path_key(code)]\n self.paths_added = len(paths)\n sys.path = paths + sys.path\n except:\n self.paths_added = 0 \n \n def unconfigure_path(self):\n \"\"\" Restores sys.path to normal after calls to configure_path()\n \n Remove the previously added paths from sys.path\n \"\"\"\n sys.path = sys.path[self.paths_added:]\n self.paths_added = 0\n\n def get_cataloged_functions(self,code):\n \"\"\" Load all functions associated with code from catalog search path.\n \n Sometimes there can be trouble loading a function listed in a\n catalog file because the actual module that holds the function \n has been moved or deleted. When this happens, that catalog file\n is \"repaired\", meaning the entire entry for this function is \n removed from the file. This only affects the catalog file that\n has problems -- not the others in the search path.\n \n The \"repair\" behavior may not be needed, but I'll keep it for now.\n \"\"\"\n mode = 'r'\n cat = None\n function_list = []\n for path in self.build_search_order():\n cat = get_catalog(path,mode)\n if cat is not None and cat.has_key(code):\n # set up the python path so that modules for this\n # function can be loaded.\n self.configure_path(cat,code)\n try: \n function_list += cat[code]\n except: #SystemError and ImportError so far seen \n # problems loading a function from the catalog. Try to\n # repair the cause.\n cat.close()\n self.repair_catalog(path,code)\n self.unconfigure_path() \n return function_list\n\n\n def repair_catalog(self,catalog_path,code):\n \"\"\" Remove entry for code from catalog_path\n \n Occasionally catalog entries could get corrupted. An example\n would be when a module that had functions in the catalog was\n deleted or moved on the disk. The best current repair method is \n just to trash the entire catalog entry for this piece of code. \n This may loose function entries that are valid, but thats life.\n \n catalog_path must be writable for repair. If it isn't, the\n function exists with a warning. \n \"\"\"\n writable_cat = None\n if not os.path.exists(catalog_path):\n return\n try:\n writable_cat = get_catalog(catalog_path,'w')\n except:\n print 'warning: unable to repair catalog entry\\n %s\\n in\\n %s' % \\\n (code,catalog_path)\n return \n if writable_cat.has_key(code):\n print 'repairing catalog by removing key'\n del writable_cat[code]\n \n # it is possible that the path key doesn't exist (if the function registered\n # was a built-in function), so we have to check if the path exists before\n # arbitrarily deleting it.\n path_key = self.path_key(code) \n if writable_cat.has_key(path_key):\n del writable_cat[path_key] \n \n def get_functions_fast(self,code):\n \"\"\" Return list of functions for code from the cache.\n \n Return an empty list if the code entry is not found.\n \"\"\"\n return self.cache.get(code,[])\n \n def get_functions(self,code,module_dir=None):\n \"\"\" Return the list of functions associated with this code fragment.\n \n The cache is first searched for the function. If an entry\n in the cache is not found, then catalog files on disk are \n searched for the entry. This is slooooow, but only happens\n once per code object. All the functions found in catalog files\n on a cache miss are loaded into the cache to speed up future calls.\n The search order is as follows:\n \n 1. user specified path (from catalog initialization)\n 2. directories from the PYTHONCOMPILED environment variable\n 3. The temporary directory on your platform.\n\n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n # Fast!! try cache first.\n if self.cache.has_key(code):\n return self.cache[code]\n \n # 2. Slow!! read previously compiled functions from disk.\n try:\n self.set_module_directory(module_dir)\n function_list = self.get_cataloged_functions(code)\n if code:\n function_list\n # put function_list in cache to save future lookups.\n if function_list:\n self.cache[code] = function_list\n # return function_list, empty or otherwise.\n finally:\n self.clear_module_directory()\n return function_list\n\n def add_function(self,code,function,module_dir=None):\n \"\"\" Adds a function to the catalog.\n \n The function is added to the cache as well as the first\n writable file catalog found in the search path. If no\n code entry exists in the cache, the on disk catalogs\n are loaded into the cache and function is added to the\n beginning of the function list.\n \n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n\n # 1. put it in the cache.\n if self.cache.has_key(code):\n if function not in self.cache[code]:\n self.cache[code].insert(0,function)\n else: \n # Load functions and put this one up front\n self.cache[code] = self.get_functions(code) \n self.fast_cache(code,function)\n \n # 2. Store the function entry to disk. \n try:\n self.set_module_directory(module_dir)\n self.add_function_persistent(code,function)\n finally:\n self.clear_module_directory()\n \n def add_function_persistent(self,code,function):\n \"\"\" Store the code->function relationship to disk.\n \n Two pieces of information are needed for loading functions\n from disk -- the function pickle (which conveniently stores\n the module name, etc.) and the path to its module's directory.\n The latter is needed so that the function can be loaded no\n matter what the user's Python path is.\n \"\"\" \n # add function to data in first writable catalog\n mode = 'c' # create if doesn't exist, otherwise, use existing\n cat_file = self.get_writable_dir()\n cat = get_catalog(cat_file,mode)\n if cat is None:\n cat_dir = default_dir()\n cat = get_catalog(cat_file,mode)\n if cat is None:\n cat_dir = default_dir() \n cat_file = catalog_path(cat_dir)\n print 'problems with default catalog -- removing'\n os.remove(cat_file)\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n raise ValueError, 'Failed to access a catalog for storing functions' \n function_list = [function] + cat.get(code,[])\n cat[code] = function_list\n \n # now add needed path information for loading function\n module = getmodule(function)\n try:\n # built in modules don't have the __file__ extension, so this\n # will fail. Just pass in this case since path additions aren't\n # needed for built-in modules.\n mod_path,f=os.path.split(os.path.abspath(module.__file__))\n pkey = self.path_key(code)\n cat[pkey] = [mod_path] + cat.get(pkey,[])\n except:\n pass\n\n def fast_cache(self,code,function):\n \"\"\" Move function to the front of the cache entry for code\n \n If future calls to the function have the same type signature,\n this will speed up access significantly because the first\n function call is correct.\n \n Note: The cache added to the inline_tools module is significantly\n faster than always calling get_functions, so this isn't\n as necessary as it used to be. Still, it's probably worth\n doing. \n \"\"\"\n try:\n if self.cache[code][0] == function:\n return\n except: # KeyError, IndexError \n pass\n try:\n self.cache[code].remove(function)\n except ValueError:\n pass\n # put new function at the beginning of the list to search.\n self.cache[code].insert(0,function)\n \ndef test():\n from scipy_test import module_test\n module_test(__name__,__file__)\n\ndef test_suite():\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__) \n", "source_code_before": "\"\"\" Track relationships between compiled extension functions & code fragments\n\n catalog keeps track of which compiled(or even standard) functions are \n related to which code fragments. It also stores these relationships\n to disk so they are remembered between Python sessions. When \n \n a = 1\n compiler.inline('printf(\"printed from C: %d\",a);',['a'] )\n \n is called, inline() first looks to see if it has seen the code \n 'printf(\"printed from C\");' before. If not, it calls \n \n catalog.get_functions('printf(\"printed from C: %d\", a);')\n \n which returns a list of all the function objects that have been compiled\n for the code fragment. Multiple functions can occur because the code\n could be compiled for different types for 'a' (although not likely in\n this case). The catalog first looks in its cache and quickly returns\n a list of the functions if possible. If the cache lookup fails, it then\n looks through possibly multiple catalog files on disk and fills its\n cache with all the functions that match the code fragment. \n \n In case where the code fragment hasn't been compiled, inline() compiles\n the code and then adds it to the catalog:\n \n function = \n catalog.add_function('printf(\"printed from C: %d\", a);',function)\n \n add_function() adds function to the front of the cache. function,\n along with the path information to its module, are also stored in a\n persistent catalog for future use by python sessions. \n\"\"\" \n\nimport os,sys,string\nimport shelve\n\ndef getmodule(object):\n \"\"\" Discover the name of the module where object was defined.\n \n This is an augmented version of inspect.getmodule that can discover \n the parent module for extension functions.\n \"\"\"\n import inspect\n value = inspect.getmodule(object)\n if value is None:\n #walk trough all modules looking for function\n for name,mod in sys.modules.items():\n # try except used because of some comparison failures\n # in wxPoint code. Need to review this\n try:\n if mod and object in mod.__dict__.values():\n value = mod\n # if it is a built-in module, keep looking to see\n # if a non-builtin also has it. Otherwise quit and\n # consider the module found. (ain't perfect, but will \n # have to do for now).\n if string.find('(built-in)',str(mod)) is -1:\n break\n \n except TypeError:\n pass \n return value\n\ndef expr_to_filename(expr):\n \"\"\" Convert an arbitrary expr string to a valid file name.\n \n The name is based on the md5 check sum for the string and\n Something that was a little more human readable would be \n nice, but the computer doesn't seem to care.\n \"\"\"\n import md5\n base = 'sc_'\n return base + md5.new(expr).hexdigest()\n\ndef unique_file(d,expr):\n \"\"\" Generate a unqiue file name based on expr in directory d\n \n This is meant for use with building extension modules, so\n a file name is considered unique if none of the following\n extension '.cpp','.o','.so','module.so','.py', or '.pyd'\n exists in directory d. The fully qualified path to the\n new name is returned. You'll need to append your own\n extension to it before creating files.\n \"\"\"\n files = os.listdir(d)\n #base = 'scipy_compile'\n base = expr_to_filename(expr)\n for i in range(1000000):\n fname = base + `i`\n if not (fname+'.cpp' in files or\n fname+'.o' in files or\n fname+'.so' in files or\n fname+'module.so' in files or\n fname+'.py' in files or\n fname+'.pyd' in files):\n break\n return os.path.join(d,fname)\n \ndef default_dir():\n \"\"\" Return a default location to store compiled files and catalogs.\n \n XX is the Python version number in all paths listed below\n On windows, the default location is the temporary directory\n returned by gettempdir()/pythonXX.\n \n On Unix, ~/.pythonXX_compiled is the default location. If it doesn't\n exist, it is created. The directory is marked rwx------.\n \n If for some reason it isn't possible to build a default directory\n in the user's home, /tmp/_pythonXX_compiled is used. If it \n doesn't exist, it is created. The directory is marked rwx------\n to try and keep people from being able to sneak a bad module\n in on you. \n \"\"\"\n import tempfile \n python_name = \"python%d%d_compiled\" % tuple(sys.version_info[:2]) \n if sys.platform != 'win32':\n try:\n path = os.path.join(os.environ['HOME'],'.' + python_name)\n except KeyError:\n temp_dir = `os.getuid()` + '_' + python_name\n path = os.path.join(tempfile.gettempdir(),temp_dir) \n else:\n path = os.path.join(tempfile.gettempdir(),python_name)\n \n if not os.path.exists(path):\n os.mkdir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not os.access(path,os.W_OK):\n print 'warning: default directory is not write accessible.'\n print 'defualt:', path\n return path\n\ndef default_temp_dir():\n path = os.path.join(default_dir(),'temp')\n if not os.path.exists(path):\n os.mkdir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not os.access(path,os.W_OK):\n print 'warning: default directory is not write accessible.'\n print 'defualt:', path\n return path\n\n \ndef os_dependent_catalog_name():\n \"\"\" Generate catalog name dependent on OS and Python version being used.\n \n This allows multiple platforms to have catalog files in the\n same directory without stepping on each other. For now, it \n bases the name of the value returned by sys.platform and the\n version of python being run. If this isn't enough to descriminate\n on some platforms, we can try to add other info. It has \n occured to me that if we get fancy enough to optimize for different\n architectures, then chip type might be added to the catalog name also.\n \"\"\"\n version = '%d%d' % sys.version_info[:2]\n return sys.platform+version+'compiled_catalog'\n \ndef catalog_path(module_path):\n \"\"\" Return the full path name for the catalog file in the given directory.\n \n module_path can either be a file name or a path name. If it is a \n file name, the catalog file name in its parent directory is returned.\n If it is a directory, the catalog file in that directory is returned.\n\n If module_path doesn't exist, None is returned. Note though, that the\n catalog file does *not* have to exist, only its parent. '~', shell\n variables, and relative ('.' and '..') paths are all acceptable.\n \n catalog file names are os dependent (based on sys.platform), so this \n should support multiple platforms sharing the same disk space \n (NFS mounts). See os_dependent_catalog_name() for more info.\n \"\"\"\n module_path = os.path.expanduser(module_path)\n module_path = os.path.expandvars(module_path)\n module_path = os.path.abspath(module_path)\n if not os.path.exists(module_path):\n catalog_file = None\n elif not os.path.isdir(module_path):\n module_path,dummy = os.path.split(module_path)\n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n else: \n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n return catalog_file\n\ndef get_catalog(module_path,mode='r'):\n \"\"\" Return a function catalog (shelve object) from the path module_path\n\n If module_path is a directory, the function catalog returned is\n from that directory. If module_path is an actual module_name,\n then the function catalog returned is from its parent directory.\n mode uses the standard 'c' = create, 'r' = read, 'w' = write\n file open modes.\n \n See catalog_path() for more information on module_path.\n \"\"\"\n catalog_file = catalog_path(module_path)\n #print catalog_file\n #sh = shelve.open(catalog_file,mode)\n try:\n sh = shelve.open(catalog_file,mode)\n except: # not sure how to pin down which error to catch yet\n sh = None\n return sh\n\nclass catalog:\n \"\"\" Stores information about compiled functions both in cache and on disk.\n \n catalog stores (code, list_of_function) pairs so that all the functions\n that have been compiled for code are available for calling (usually in\n inline or blitz).\n \n catalog keeps a dictionary of previously accessed code values cached \n for quick access. It also handles the looking up of functions compiled \n in previously called Python sessions on disk in function catalogs. \n catalog searches the directories in the PYTHONCOMPILED environment \n variable in order loading functions that correspond to the given code \n fragment. A default directory is also searched for catalog functions. \n On unix, the default directory is usually '~/.pythonxx_compiled' where \n xx is the version of Python used. On windows, it is the directory \n returned by temfile.gettempdir(). Functions closer to the front are of \n the variable list are guaranteed to be closer to the front of the \n function list so that they will be called first. See \n get_cataloged_functions() for more info on how the search order is \n traversed.\n \n Catalog also handles storing information about compiled functions to\n a catalog. When writing this information, the first writable catalog\n file in PYTHONCOMPILED path is used. If a writable catalog is not\n found, it is written to the catalog in the default directory. This\n directory should always be writable.\n \"\"\"\n def __init__(self,user_path_list=None):\n \"\"\" Create a catalog for storing/searching for compiled functions. \n \n user_path_list contains directories that should be searched \n first for function catalogs. They will come before the path\n entries in the PYTHONCOMPILED environment varilable.\n \"\"\"\n if type(user_path_list) == type('string'):\n self.user_path_list = [user_path_list]\n elif user_path_list:\n self.user_path_list = user_path_list\n else:\n self.user_path_list = []\n self.cache = {}\n self.module_dir = None\n self.paths_added = 0\n \n def set_module_directory(self,module_dir):\n \"\"\" Set the path that will replace 'MODULE' in catalog searches.\n \n You should call clear_module_directory() when your finished\n working with it.\n \"\"\"\n self.module_dir = module_dir\n def get_module_directory(self):\n \"\"\" Return the path used to replace the 'MODULE' in searches.\n \"\"\"\n return self.module_dir\n def clear_module_directory(self):\n \"\"\" Reset 'MODULE' path to None so that it is ignored in searches. \n \"\"\"\n self.module_dir = None\n \n def get_environ_path(self):\n \"\"\" Return list of paths from 'PYTHONCOMPILED' environment variable.\n \n On Unix the path in PYTHONCOMPILED is a ':' separated list of\n directories. On Windows, a ';' separated list is used. \n \"\"\"\n paths = []\n if os.environ.has_key('PYTHONCOMPILED'):\n path_string = os.environ['PYTHONCOMPILED'] \n if sys.platform == 'win32':\n #probably should also look in registry\n paths = path_string.split(';')\n else: \n paths = path_string.split(':')\n return paths \n\n def build_search_order(self):\n \"\"\" Returns a list of paths that are searched for catalogs. \n \n Values specified in the catalog constructor are searched first,\n then values found in the PYTHONCOMPILED environment variable.\n The directory returned by default_dir() is always returned at\n the end of the list.\n \n There is a 'magic' path name called 'MODULE' that is replaced\n by the directory defined by set_module_directory(). If the\n module directory hasn't been set, 'MODULE' is ignored.\n \"\"\"\n \n paths = self.user_path_list + self.get_environ_path()\n search_order = []\n for path in paths:\n if path == 'MODULE':\n if self.module_dir:\n search_order.append(self.module_dir)\n else:\n search_order.append(path)\n search_order.append(default_dir())\n return search_order\n\n def get_catalog_files(self):\n \"\"\" Returns catalog file list in correct search order.\n \n Some of the catalog files may not currently exists.\n However, all will be valid locations for a catalog\n to be created (if you have write permission).\n \"\"\"\n files = map(catalog_path,self.build_search_order())\n files = filter(lambda x: x is not None,files)\n return files\n\n def get_existing_files(self):\n \"\"\" Returns all existing catalog file list in correct search order.\n \"\"\"\n files = self.get_catalog_files()\n existing_files = filter(os.path.exists,files)\n return existing_files\n\n def get_writable_file(self,existing_only=0):\n \"\"\" Return the name of the first writable catalog file.\n \n Its parent directory must also be writable. This is so that\n compiled modules can be written to the same directory.\n \"\"\"\n # note: both file and its parent directory must be writeable\n if existing_only:\n files = self.get_existing_files()\n else:\n files = self.get_catalog_files()\n # filter for (file exists and is writable) OR directory is writable\n def file_test(x):\n from os import access, F_OK, W_OK\n return (access(x,F_OK) and access(x,W_OK) or\n access(os.path.dirname(x),W_OK))\n writable = filter(file_test,files)\n if writable:\n file = writable[0]\n else:\n file = None\n return file\n \n def get_writable_dir(self):\n \"\"\" Return the parent directory of first writable catalog file.\n \n The returned directory has write access.\n \"\"\"\n return os.path.dirname(self.get_writable_file())\n \n def unique_module_name(self,code,module_dir=None):\n \"\"\" Return full path to unique file name that in writable location.\n \n The directory for the file is the first writable directory in \n the catalog search path. The unique file name is derived from\n the code fragment. If, module_dir is specified, it is used\n to replace 'MODULE' in the search path.\n \"\"\"\n if module_dir is not None:\n self.set_module_directory(module_dir)\n try:\n d = self.get_writable_dir()\n finally:\n if module_dir is not None:\n self.clear_module_directory()\n return unique_file(d,code)\n\n def path_key(self,code):\n \"\"\" Return key for path information for functions associated with code.\n \"\"\"\n return '__path__' + code\n \n def configure_path(self,cat,code):\n \"\"\" Add the python path for the given code to the sys.path\n \n unconfigure_path() should be called as soon as possible after\n imports associated with code are finished so that sys.path \n is restored to normal.\n \"\"\"\n try:\n paths = cat[self.path_key(code)]\n self.paths_added = len(paths)\n sys.path = paths + sys.path\n except:\n self.paths_added = 0 \n \n def unconfigure_path(self):\n \"\"\" Restores sys.path to normal after calls to configure_path()\n \n Remove the previously added paths from sys.path\n \"\"\"\n sys.path = sys.path[self.paths_added:]\n self.paths_added = 0\n\n def get_cataloged_functions(self,code):\n \"\"\" Load all functions associated with code from catalog search path.\n \n Sometimes there can be trouble loading a function listed in a\n catalog file because the actual module that holds the function \n has been moved or deleted. When this happens, that catalog file\n is \"repaired\", meaning the entire entry for this function is \n removed from the file. This only affects the catalog file that\n has problems -- not the others in the search path.\n \n The \"repair\" behavior may not be needed, but I'll keep it for now.\n \"\"\"\n mode = 'r'\n cat = None\n function_list = []\n for path in self.build_search_order():\n cat = get_catalog(path,mode)\n if cat is not None and cat.has_key(code):\n # set up the python path so that modules for this\n # function can be loaded.\n self.configure_path(cat,code)\n try: \n function_list += cat[code]\n except: #SystemError and ImportError so far seen \n # problems loading a function from the catalog. Try to\n # repair the cause.\n cat.close()\n self.repair_catalog(path,code)\n self.unconfigure_path() \n return function_list\n\n\n def repair_catalog(self,catalog_path,code):\n \"\"\" Remove entry for code from catalog_path\n \n Occasionally catalog entries could get corrupted. An example\n would be when a module that had functions in the catalog was\n deleted or moved on the disk. The best current repair method is \n just to trash the entire catalog entry for this piece of code. \n This may loose function entries that are valid, but thats life.\n \n catalog_path must be writable for repair. If it isn't, the\n function exists with a warning. \n \"\"\"\n writable_cat = None\n if not os.path.exists(catalog_path):\n return\n try:\n writable_cat = get_catalog(catalog_path,'w')\n except:\n print 'warning: unable to repair catalog entry\\n %s\\n in\\n %s' % \\\n (code,catalog_path)\n return \n if writable_cat.has_key(code):\n print 'repairing catalog by removing key'\n del writable_cat[code]\n \n # it is possible that the path key doesn't exist (if the function registered\n # was a built-in function), so we have to check if the path exists before\n # arbitrarily deleting it.\n path_key = self.path_key(code) \n if writable_cat.has_key(path_key):\n del writable_cat[path_key] \n \n def get_functions_fast(self,code):\n \"\"\" Return list of functions for code from the cache.\n \n Return an empty list if the code entry is not found.\n \"\"\"\n return self.cache.get(code,[])\n \n def get_functions(self,code,module_dir=None):\n \"\"\" Return the list of functions associated with this code fragment.\n \n The cache is first searched for the function. If an entry\n in the cache is not found, then catalog files on disk are \n searched for the entry. This is slooooow, but only happens\n once per code object. All the functions found in catalog files\n on a cache miss are loaded into the cache to speed up future calls.\n The search order is as follows:\n \n 1. user specified path (from catalog initialization)\n 2. directories from the PYTHONCOMPILED environment variable\n 3. The temporary directory on your platform.\n\n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n # Fast!! try cache first.\n if self.cache.has_key(code):\n return self.cache[code]\n \n # 2. Slow!! read previously compiled functions from disk.\n try:\n self.set_module_directory(module_dir)\n function_list = self.get_cataloged_functions(code)\n if code:\n function_list\n # put function_list in cache to save future lookups.\n if function_list:\n self.cache[code] = function_list\n # return function_list, empty or otherwise.\n finally:\n self.clear_module_directory()\n return function_list\n\n def add_function(self,code,function,module_dir=None):\n \"\"\" Adds a function to the catalog.\n \n The function is added to the cache as well as the first\n writable file catalog found in the search path. If no\n code entry exists in the cache, the on disk catalogs\n are loaded into the cache and function is added to the\n beginning of the function list.\n \n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n\n # 1. put it in the cache.\n if self.cache.has_key(code):\n if function not in self.cache[code]:\n self.cache[code].insert(0,function)\n else: \n # Load functions and put this one up front\n self.cache[code] = self.get_functions(code) \n self.fast_cache(code,function)\n \n # 2. Store the function entry to disk. \n try:\n self.set_module_directory(module_dir)\n self.add_function_persistent(code,function)\n finally:\n self.clear_module_directory()\n \n def add_function_persistent(self,code,function):\n \"\"\" Store the code->function relationship to disk.\n \n Two pieces of information are needed for loading functions\n from disk -- the function pickle (which conveniently stores\n the module name, etc.) and the path to its module's directory.\n The latter is needed so that the function can be loaded no\n matter what the user's Python path is.\n \"\"\" \n # add function to data in first writable catalog\n mode = 'cw' # create, write\n cat_file = self.get_writable_dir()\n cat = get_catalog(cat_file,mode)\n if cat is None:\n cat_dir = default_dir()\n cat = get_catalog(cat_file,mode)\n if cat is None:\n cat_dir = default_dir() \n cat_file = catalog_path(cat_dir)\n print 'problems with default catalog -- removing'\n os.remove(cat_file)\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n raise ValueError, 'Failed to access a catalog for storing functions' \n function_list = [function] + cat.get(code,[])\n cat[code] = function_list\n \n # now add needed path information for loading function\n module = getmodule(function)\n try:\n # built in modules don't have the __file__ extension, so this\n # will fail. Just pass in this case since path additions aren't\n # needed for built-in modules.\n mod_path,f=os.path.split(os.path.abspath(module.__file__))\n pkey = self.path_key(code)\n cat[pkey] = [mod_path] + cat.get(pkey,[])\n except:\n pass\n\n def fast_cache(self,code,function):\n \"\"\" Move function to the front of the cache entry for code\n \n If future calls to the function have the same type signature,\n this will speed up access significantly because the first\n function call is correct.\n \n Note: The cache added to the inline_tools module is significantly\n faster than always calling get_functions, so this isn't\n as necessary as it used to be. Still, it's probably worth\n doing. \n \"\"\"\n try:\n if self.cache[code][0] == function:\n return\n except: # KeyError, IndexError \n pass\n try:\n self.cache[code].remove(function)\n except ValueError:\n pass\n # put new function at the beginning of the list to search.\n self.cache[code].insert(0,function)\n \ndef test():\n from scipy_test import module_test\n module_test(__name__,__file__)\n\ndef test_suite():\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__) \n", "methods": [ { "name": "getmodule", "long_name": "getmodule( object )", "filename": "catalog.py", "nloc": 13, "complexity": 7, "token_count": 75, "parameters": [ "object" ], "start_line": 37, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expr_to_filename", "long_name": "expr_to_filename( expr )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "expr" ], "start_line": 64, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "unique_file", "long_name": "unique_file( d , expr )", "filename": "catalog.py", "nloc": 13, "complexity": 8, "token_count": 89, "parameters": [ "d", "expr" ], "start_line": 75, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "default_dir", "long_name": "default_dir( )", "filename": "catalog.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [], "start_line": 99, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "default_temp_dir", "long_name": "default_temp_dir( )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 134, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "os_dependent_catalog_name", "long_name": "os_dependent_catalog_name( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 145, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "catalog_path", "long_name": "catalog_path( module_path )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "module_path" ], "start_line": 159, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "get_catalog", "long_name": "get_catalog( module_path , mode = 'r' )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 56, "parameters": [ "module_path", "mode" ], "start_line": 186, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , user_path_list = None )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 60, "parameters": [ "self", "user_path_list" ], "start_line": 235, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "set_module_directory", "long_name": "set_module_directory( self , module_dir )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "module_dir" ], "start_line": 252, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_module_directory", "long_name": "get_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 259, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_module_directory", "long_name": "clear_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 263, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_environ_path", "long_name": "get_environ_path( self )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 268, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "build_search_order", "long_name": "build_search_order( self )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 62, "parameters": [ "self" ], "start_line": 284, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_catalog_files", "long_name": "get_catalog_files( self )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 308, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_existing_files", "long_name": "get_existing_files( self )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 319, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_writable_file.file_test", "long_name": "get_writable_file.file_test( x )", "filename": "catalog.py", "nloc": 4, "complexity": 3, "token_count": 43, "parameters": [ "x" ], "start_line": 338, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "get_writable_file", "long_name": "get_writable_file( self , existing_only = 0 )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 55, "parameters": [ "self", "existing_only" ], "start_line": 326, "end_line": 347, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_writable_dir", "long_name": "get_writable_dir( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 349, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "unique_module_name", "long_name": "unique_module_name( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "self", "code", "module_dir" ], "start_line": 356, "end_line": 371, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "path_key", "long_name": "path_key( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "code" ], "start_line": 373, "end_line": 376, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configure_path", "long_name": "configure_path( self , cat , code )", "filename": "catalog.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "cat", "code" ], "start_line": 378, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "unconfigure_path", "long_name": "unconfigure_path( self )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 392, "end_line": 398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_cataloged_functions", "long_name": "get_cataloged_functions( self , code )", "filename": "catalog.py", "nloc": 15, "complexity": 5, "token_count": 86, "parameters": [ "self", "code" ], "start_line": 400, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "repair_catalog", "long_name": "repair_catalog( self , catalog_path , code )", "filename": "catalog.py", "nloc": 16, "complexity": 5, "token_count": 83, "parameters": [ "self", "catalog_path", "code" ], "start_line": 432, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_functions_fast", "long_name": "get_functions_fast( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "code" ], "start_line": 464, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_functions", "long_name": "get_functions( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 13, "complexity": 5, "token_count": 69, "parameters": [ "self", "code", "module_dir" ], "start_line": 471, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , code , function , module_dir = None )", "filename": "catalog.py", "nloc": 12, "complexity": 4, "token_count": 94, "parameters": [ "self", "code", "function", "module_dir" ], "start_line": 507, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "add_function_persistent", "long_name": "add_function_persistent( self , code , function )", "filename": "catalog.py", "nloc": 24, "complexity": 5, "token_count": 166, "parameters": [ "self", "code", "function" ], "start_line": 537, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "fast_cache", "long_name": "fast_cache( self , code , function )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 59, "parameters": [ "self", "code", "function" ], "start_line": 576, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 600, "end_line": 602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 604, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "getmodule", "long_name": "getmodule( object )", "filename": "catalog.py", "nloc": 13, "complexity": 7, "token_count": 75, "parameters": [ "object" ], "start_line": 37, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expr_to_filename", "long_name": "expr_to_filename( expr )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "expr" ], "start_line": 64, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "unique_file", "long_name": "unique_file( d , expr )", "filename": "catalog.py", "nloc": 13, "complexity": 8, "token_count": 89, "parameters": [ "d", "expr" ], "start_line": 75, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "default_dir", "long_name": "default_dir( )", "filename": "catalog.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [], "start_line": 99, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "default_temp_dir", "long_name": "default_temp_dir( )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 134, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "os_dependent_catalog_name", "long_name": "os_dependent_catalog_name( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 145, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "catalog_path", "long_name": "catalog_path( module_path )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "module_path" ], "start_line": 159, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "get_catalog", "long_name": "get_catalog( module_path , mode = 'r' )", "filename": "catalog.py", "nloc": 7, "complexity": 2, "token_count": 35, "parameters": [ "module_path", "mode" ], "start_line": 186, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , user_path_list = None )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 60, "parameters": [ "self", "user_path_list" ], "start_line": 233, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "set_module_directory", "long_name": "set_module_directory( self , module_dir )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "module_dir" ], "start_line": 250, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_module_directory", "long_name": "get_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 257, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_module_directory", "long_name": "clear_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 261, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_environ_path", "long_name": "get_environ_path( self )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 266, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "build_search_order", "long_name": "build_search_order( self )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 62, "parameters": [ "self" ], "start_line": 282, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_catalog_files", "long_name": "get_catalog_files( self )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 306, "end_line": 315, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_existing_files", "long_name": "get_existing_files( self )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 317, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_writable_file.file_test", "long_name": "get_writable_file.file_test( x )", "filename": "catalog.py", "nloc": 4, "complexity": 3, "token_count": 43, "parameters": [ "x" ], "start_line": 336, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "get_writable_file", "long_name": "get_writable_file( self , existing_only = 0 )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 55, "parameters": [ "self", "existing_only" ], "start_line": 324, "end_line": 345, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_writable_dir", "long_name": "get_writable_dir( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 347, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "unique_module_name", "long_name": "unique_module_name( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "self", "code", "module_dir" ], "start_line": 354, "end_line": 369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "path_key", "long_name": "path_key( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "code" ], "start_line": 371, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configure_path", "long_name": "configure_path( self , cat , code )", "filename": "catalog.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "cat", "code" ], "start_line": 376, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "unconfigure_path", "long_name": "unconfigure_path( self )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 390, "end_line": 396, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_cataloged_functions", "long_name": "get_cataloged_functions( self , code )", "filename": "catalog.py", "nloc": 15, "complexity": 5, "token_count": 86, "parameters": [ "self", "code" ], "start_line": 398, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "repair_catalog", "long_name": "repair_catalog( self , catalog_path , code )", "filename": "catalog.py", "nloc": 16, "complexity": 5, "token_count": 83, "parameters": [ "self", "catalog_path", "code" ], "start_line": 430, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_functions_fast", "long_name": "get_functions_fast( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "code" ], "start_line": 462, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_functions", "long_name": "get_functions( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 13, "complexity": 5, "token_count": 69, "parameters": [ "self", "code", "module_dir" ], "start_line": 469, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , code , function , module_dir = None )", "filename": "catalog.py", "nloc": 12, "complexity": 4, "token_count": 94, "parameters": [ "self", "code", "function", "module_dir" ], "start_line": 505, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "add_function_persistent", "long_name": "add_function_persistent( self , code , function )", "filename": "catalog.py", "nloc": 24, "complexity": 5, "token_count": 166, "parameters": [ "self", "code", "function" ], "start_line": 535, "end_line": 572, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "fast_cache", "long_name": "fast_cache( self , code , function )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 59, "parameters": [ "self", "code", "function" ], "start_line": 574, "end_line": 596, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 598, "end_line": 600, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 602, "end_line": 604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "add_function_persistent", "long_name": "add_function_persistent( self , code , function )", "filename": "catalog.py", "nloc": 24, "complexity": 5, "token_count": 166, "parameters": [ "self", "code", "function" ], "start_line": 537, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "get_catalog", "long_name": "get_catalog( module_path , mode = 'r' )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 56, "parameters": [ "module_path", "mode" ], "start_line": 186, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 } ], "nloc": 324, "complexity": 92, "token_count": 1756, "diff_parsed": { "added": [ " mode uses the standard 'c' = create, 'n' = new, 'r' = read,", " 'w' = write file open modes available for anydbm databases.", " if mode not in ['c','r','w','n']:", " msg = \" mode must be 'c', 'n', 'r', or 'w'. See anydbm for more info\"", " raise ValueError, msg", " #print catalog_file,mode", " mode = 'c' # create if doesn't exist, otherwise, use existing" ], "deleted": [ " mode uses the standard 'c' = create, 'r' = read, 'w' = write", " file open modes.", " #print catalog_file", " #sh = shelve.open(catalog_file,mode)", " mode = 'cw' # create, write" ] } }, { "old_path": "weave/tests/test_catalog.py", "new_path": "weave/tests/test_catalog.py", "filename": "test_catalog.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -99,7 +99,7 @@ def check_nonexistent_catalog_is_none(self):\n assert(catalog is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n- catalog = get_catalog(pardir,'cr')\n+ catalog = get_catalog(pardir,'c')\n assert(catalog is not None)\n \n class test_catalog(unittest.TestCase):\n@@ -204,6 +204,7 @@ def check_get_existing_files2(self):\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n+ print 'files:', files\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n", "added_lines": 2, "deleted_lines": 1, "source_code": "import unittest\nimport sys, os\n\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nfrom catalog import *\n# not sure why, but was having problems with which catalog was being called.\nimport catalog\n#catalog = catalog.catalog\nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\n\nclass test_default_dir(unittest.TestCase):\n def check_is_writable(self):\n path = default_dir()\n name = os.path.join(path,'dummy_catalog')\n test_file = open(name,'w')\n try:\n test_file.write('making sure default location is writable\\n')\n finally:\n test_file.close()\n os.remove(name)\n\nclass test_os_dependent_catalog_name(unittest.TestCase): \n pass\n \nclass test_catalog_path(unittest.TestCase): \n def check_default(self):\n in_path = default_dir()\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n assert(f == os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n assert(f == os_dependent_catalog_name()) \n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n assert(f == os_dependent_catalog_name())\n def check_module(self):\n # hand it a module and see if it uses the parent directory\n # of the module.\n path = catalog_path(os.__file__)\n d,f = os.path.split(os.__file__)\n d2,f = os.path.split(path)\n assert (d2 == d)\n def check_path(self):\n # use os.__file__ to get a usable directory.\n in_path,f = os.path.split(os.__file__)\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert (d == in_path)\n def check_bad_path(self):\n # stupid_path_name\n in_path = 'stupid_path_name'\n path = catalog_path(in_path)\n assert (path is None)\n\nclass test_get_catalog(unittest.TestCase):\n \"\"\" This only tests whether new catalogs are created correctly.\n And whether non-existent return None correctly with read mode.\n Putting catalogs in the right place is all tested with\n catalog_dir tests.\n \"\"\"\n def get_test_dir(self,erase = 0):\n # make sure tempdir catalog doesn't exist\n import tempfile\n temp = tempfile.gettempdir()\n pardir = os.path.join(temp,'catalog_test'+tempfile.gettempprefix())\n if not os.path.exists(pardir):\n os.mkdir(pardir)\n catalog_file = os.path.join(pardir,os_dependent_catalog_name()+'.dat')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,os_dependent_catalog_name()+'.dir')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,os_dependent_catalog_name())\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n return pardir\n def check_nonexistent_catalog_is_none(self):\n pardir = self.get_test_dir(erase=1)\n catalog = get_catalog(pardir)\n assert(catalog is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n catalog = get_catalog(pardir,'c')\n assert(catalog is not None)\n\nclass test_catalog(unittest.TestCase):\n\n def clear_environ(self):\n if os.environ.has_key('PYTHONCOMPILED'):\n self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED']\n del os.environ['PYTHONCOMPILED']\n else: \n self.old_PYTHONCOMPILED = None\n def reset_environ(self):\n if self.old_PYTHONCOMPILED:\n os.environ['PYTHONCOMPILED'] = self.old_PYTHONCOMPILED\n self.old_PYTHONCOMPILED = None\n def setUp(self):\n self.clear_environ() \n def tearDown(self):\n self.reset_environ()\n \n def check_set_module_directory(self):\n q = catalog.catalog()\n q.set_module_directory('bob')\n r = q.get_module_directory()\n assert (r == 'bob')\n def check_clear_module_directory(self):\n q = catalog.catalog()\n r = q.get_module_directory()\n assert (r == None)\n q.set_module_directory('bob')\n r = q.clear_module_directory()\n assert (r == None)\n def check_get_environ_path(self):\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('path1','path2','path3'))\n q = catalog.catalog()\n path = q.get_environ_path() \n assert(path == ['path1','path2','path3'])\n def check_build_search_order1(self): \n \"\"\" MODULE in search path should be replaced by module_dir.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n q.set_module_directory('second')\n order = q.build_search_order()\n assert(order == ['first','second','third',default_dir()])\n def check_build_search_order2(self): \n \"\"\" MODULE in search path should be removed if module_dir==None.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n order = q.build_search_order()\n assert(order == ['first','third',default_dir()]) \n def check_build_search_order3(self):\n \"\"\" If MODULE is absent, module_dir shouldn't be in search path.\n \"\"\" \n q = catalog.catalog(['first','second'])\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second',default_dir()])\n def check_build_search_order4(self):\n \"\"\" Make sure environment variable is getting used.\n \"\"\" \n q = catalog.catalog(['first','second'])\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second','third','fourth','fifth',default_dir()])\n \n def check_catalog_files1(self):\n \"\"\" Be sure we get at least one file even without specifying the path.\n \"\"\"\n q = catalog.catalog()\n files = q.get_catalog_files()\n assert(len(files) == 1)\n\n def check_catalog_files2(self):\n \"\"\" Ignore bad paths in the path.\n \"\"\"\n q = catalog.catalog()\n os.environ['PYTHONCOMPILED'] = '_some_bad_path_'\n files = q.get_catalog_files()\n assert(len(files) == 1)\n \n def check_get_existing_files1(self):\n \"\"\" Shouldn't get any files when temp doesn't exist and no path set. \n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 0)\n def check_get_existing_files2(self):\n \"\"\" Shouldn't get a single file from the temp dir.\n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n # create a dummy file\n import os \n q.add_function('code', os.getpid)\n del q\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n print 'files:', files\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n \"\"\" There should always be a writable file -- even if it is in temp\n \"\"\"\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_with_bad_path(self):\n \"\"\" There should always be a writable file -- even if search paths contain\n bad values.\n \"\"\"\n if sys.platform == 'win32': sep = ';'\n else: sep = ':' \n os.environ['PYTHONCOMPILED'] = sep.join(('_bad_path_name_'))\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_dir(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n d = q.get_writable_dir()\n file = os.path.join(d,'some_silly_file')\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file)\n def check_unique_module_name(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n file = q.unique_module_name('bob')\n cfile1 = file+'.cpp'\n assert(not os.path.exists(cfile1))\n #make sure it is writable\n try:\n f = open(cfile1,'w')\n f.write('bob')\n finally: \n f.close()\n # try again with same code fragment -- should get unique name\n file = q.unique_module_name('bob')\n cfile2 = file+'.cpp'\n assert(not os.path.exists(cfile2+'.cpp'))\n os.remove(cfile1)\n def check_add_function_persistent1(self):\n \"\"\" Test persisting a function in the default catalog\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog()\n mod_name = q.unique_module_name('bob')\n d,f = os.path.split(mod_name)\n module_name, funcs = simple_module(d,f,'f')\n for i in funcs:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n os.remove(module_name)\n # any way to clean modules???\n restore_temp_catalog()\n for i in funcs:\n assert(i in pfuncs) \n \n def not_sure_about_this_check_add_function_persistent2(self):\n \"\"\" Test ordering of persistent functions\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog() \n \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name1, funcs1 = simple_module(d,f,'f')\n for i in funcs1:\n q.add_function_persistent('code',i)\n \n d = empty_temp_dir()\n q = catalog(d) \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name2, funcs2 = simple_module(d,f,'f')\n for i in funcs2:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n \n os.remove(module_name1)\n os.remove(module_name2)\n cleanup_temp_dir(d)\n restore_temp_catalog()\n # any way to clean modules???\n for i in funcs1:\n assert(i in pfuncs) \n for i in funcs2:\n assert(i in pfuncs)\n # make sure functions occur in correct order for\n # lookup \n all_funcs = zip(funcs1,funcs2)\n print all_funcs\n for a,b in all_funcs:\n assert(pfuncs.index(a) > pfuncs.index(b))\n \n assert(len(pfuncs) == 4)\n\n def check_add_function_ordered(self):\n clear_temp_catalog()\n q = catalog.catalog()\n import string\n \n q.add_function('f',string.upper) \n q.add_function('f',string.lower)\n q.add_function('ff',string.find) \n q.add_function('ff',string.replace)\n q.add_function('fff',string.atof)\n q.add_function('fff',string.atoi)\n del q\n\n # now we're gonna make a new catalog with same code\n # but different functions in a specified module directory\n env_dir = empty_temp_dir()\n r = catalog.catalog(env_dir)\n r.add_function('ff',os.abort)\n r.add_function('ff',os.chdir)\n r.add_function('fff',os.access)\n r.add_function('fff',os.open)\n del r\n # now we're gonna make a new catalog with same code\n # but different functions in a user specified directory\n user_dir = empty_temp_dir()\n s = catalog.catalog(user_dir)\n import re\n s.add_function('fff',re.match)\n s.add_function('fff',re.purge)\n del s\n\n # open new catalog and make sure it retreives the functions\n # from d catalog instead of the temp catalog (made by q)\n os.environ['PYTHONCOMPILED'] = env_dir\n t = catalog.catalog(user_dir)\n funcs1 = t.get_functions('f')\n funcs2 = t.get_functions('ff')\n funcs3 = t.get_functions('fff')\n restore_temp_catalog()\n # make sure everything is read back in the correct order\n assert(funcs1 == [string.lower,string.upper])\n assert(funcs2 == [os.chdir,os.abort,string.replace,string.find])\n assert(funcs3 == [re.purge,re.match,os.open,\n os.access,string.atoi,string.atof])\n cleanup_temp_dir(user_dir)\n cleanup_temp_dir(env_dir)\n \n \ndef test_suite():\n suites = []\n suites.append( unittest.makeSuite(test_default_dir,'check_'))\n suites.append( unittest.makeSuite(test_os_dependent_catalog_name,'check_'))\n suites.append( unittest.makeSuite(test_catalog_path,'check_'))\n suites.append( unittest.makeSuite(test_get_catalog,'check_'))\n suites.append( unittest.makeSuite(test_catalog,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test():\n all_tests = test_suite()\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\n\nif __name__ == '__main__':\n test()\n", "source_code_before": "import unittest\nimport sys, os\n\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nfrom catalog import *\n# not sure why, but was having problems with which catalog was being called.\nimport catalog\n#catalog = catalog.catalog\nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\n\nclass test_default_dir(unittest.TestCase):\n def check_is_writable(self):\n path = default_dir()\n name = os.path.join(path,'dummy_catalog')\n test_file = open(name,'w')\n try:\n test_file.write('making sure default location is writable\\n')\n finally:\n test_file.close()\n os.remove(name)\n\nclass test_os_dependent_catalog_name(unittest.TestCase): \n pass\n \nclass test_catalog_path(unittest.TestCase): \n def check_default(self):\n in_path = default_dir()\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n assert(f == os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n assert(f == os_dependent_catalog_name()) \n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n assert(f == os_dependent_catalog_name())\n def check_module(self):\n # hand it a module and see if it uses the parent directory\n # of the module.\n path = catalog_path(os.__file__)\n d,f = os.path.split(os.__file__)\n d2,f = os.path.split(path)\n assert (d2 == d)\n def check_path(self):\n # use os.__file__ to get a usable directory.\n in_path,f = os.path.split(os.__file__)\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert (d == in_path)\n def check_bad_path(self):\n # stupid_path_name\n in_path = 'stupid_path_name'\n path = catalog_path(in_path)\n assert (path is None)\n\nclass test_get_catalog(unittest.TestCase):\n \"\"\" This only tests whether new catalogs are created correctly.\n And whether non-existent return None correctly with read mode.\n Putting catalogs in the right place is all tested with\n catalog_dir tests.\n \"\"\"\n def get_test_dir(self,erase = 0):\n # make sure tempdir catalog doesn't exist\n import tempfile\n temp = tempfile.gettempdir()\n pardir = os.path.join(temp,'catalog_test'+tempfile.gettempprefix())\n if not os.path.exists(pardir):\n os.mkdir(pardir)\n catalog_file = os.path.join(pardir,os_dependent_catalog_name()+'.dat')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,os_dependent_catalog_name()+'.dir')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,os_dependent_catalog_name())\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n return pardir\n def check_nonexistent_catalog_is_none(self):\n pardir = self.get_test_dir(erase=1)\n catalog = get_catalog(pardir)\n assert(catalog is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n catalog = get_catalog(pardir,'cr')\n assert(catalog is not None)\n\nclass test_catalog(unittest.TestCase):\n\n def clear_environ(self):\n if os.environ.has_key('PYTHONCOMPILED'):\n self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED']\n del os.environ['PYTHONCOMPILED']\n else: \n self.old_PYTHONCOMPILED = None\n def reset_environ(self):\n if self.old_PYTHONCOMPILED:\n os.environ['PYTHONCOMPILED'] = self.old_PYTHONCOMPILED\n self.old_PYTHONCOMPILED = None\n def setUp(self):\n self.clear_environ() \n def tearDown(self):\n self.reset_environ()\n \n def check_set_module_directory(self):\n q = catalog.catalog()\n q.set_module_directory('bob')\n r = q.get_module_directory()\n assert (r == 'bob')\n def check_clear_module_directory(self):\n q = catalog.catalog()\n r = q.get_module_directory()\n assert (r == None)\n q.set_module_directory('bob')\n r = q.clear_module_directory()\n assert (r == None)\n def check_get_environ_path(self):\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('path1','path2','path3'))\n q = catalog.catalog()\n path = q.get_environ_path() \n assert(path == ['path1','path2','path3'])\n def check_build_search_order1(self): \n \"\"\" MODULE in search path should be replaced by module_dir.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n q.set_module_directory('second')\n order = q.build_search_order()\n assert(order == ['first','second','third',default_dir()])\n def check_build_search_order2(self): \n \"\"\" MODULE in search path should be removed if module_dir==None.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n order = q.build_search_order()\n assert(order == ['first','third',default_dir()]) \n def check_build_search_order3(self):\n \"\"\" If MODULE is absent, module_dir shouldn't be in search path.\n \"\"\" \n q = catalog.catalog(['first','second'])\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second',default_dir()])\n def check_build_search_order4(self):\n \"\"\" Make sure environment variable is getting used.\n \"\"\" \n q = catalog.catalog(['first','second'])\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second','third','fourth','fifth',default_dir()])\n \n def check_catalog_files1(self):\n \"\"\" Be sure we get at least one file even without specifying the path.\n \"\"\"\n q = catalog.catalog()\n files = q.get_catalog_files()\n assert(len(files) == 1)\n\n def check_catalog_files2(self):\n \"\"\" Ignore bad paths in the path.\n \"\"\"\n q = catalog.catalog()\n os.environ['PYTHONCOMPILED'] = '_some_bad_path_'\n files = q.get_catalog_files()\n assert(len(files) == 1)\n \n def check_get_existing_files1(self):\n \"\"\" Shouldn't get any files when temp doesn't exist and no path set. \n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 0)\n def check_get_existing_files2(self):\n \"\"\" Shouldn't get a single file from the temp dir.\n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n # create a dummy file\n import os \n q.add_function('code', os.getpid)\n del q\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n \"\"\" There should always be a writable file -- even if it is in temp\n \"\"\"\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_with_bad_path(self):\n \"\"\" There should always be a writable file -- even if search paths contain\n bad values.\n \"\"\"\n if sys.platform == 'win32': sep = ';'\n else: sep = ':' \n os.environ['PYTHONCOMPILED'] = sep.join(('_bad_path_name_'))\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_dir(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n d = q.get_writable_dir()\n file = os.path.join(d,'some_silly_file')\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file)\n def check_unique_module_name(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n file = q.unique_module_name('bob')\n cfile1 = file+'.cpp'\n assert(not os.path.exists(cfile1))\n #make sure it is writable\n try:\n f = open(cfile1,'w')\n f.write('bob')\n finally: \n f.close()\n # try again with same code fragment -- should get unique name\n file = q.unique_module_name('bob')\n cfile2 = file+'.cpp'\n assert(not os.path.exists(cfile2+'.cpp'))\n os.remove(cfile1)\n def check_add_function_persistent1(self):\n \"\"\" Test persisting a function in the default catalog\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog()\n mod_name = q.unique_module_name('bob')\n d,f = os.path.split(mod_name)\n module_name, funcs = simple_module(d,f,'f')\n for i in funcs:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n os.remove(module_name)\n # any way to clean modules???\n restore_temp_catalog()\n for i in funcs:\n assert(i in pfuncs) \n \n def not_sure_about_this_check_add_function_persistent2(self):\n \"\"\" Test ordering of persistent functions\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog() \n \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name1, funcs1 = simple_module(d,f,'f')\n for i in funcs1:\n q.add_function_persistent('code',i)\n \n d = empty_temp_dir()\n q = catalog(d) \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name2, funcs2 = simple_module(d,f,'f')\n for i in funcs2:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n \n os.remove(module_name1)\n os.remove(module_name2)\n cleanup_temp_dir(d)\n restore_temp_catalog()\n # any way to clean modules???\n for i in funcs1:\n assert(i in pfuncs) \n for i in funcs2:\n assert(i in pfuncs)\n # make sure functions occur in correct order for\n # lookup \n all_funcs = zip(funcs1,funcs2)\n print all_funcs\n for a,b in all_funcs:\n assert(pfuncs.index(a) > pfuncs.index(b))\n \n assert(len(pfuncs) == 4)\n\n def check_add_function_ordered(self):\n clear_temp_catalog()\n q = catalog.catalog()\n import string\n \n q.add_function('f',string.upper) \n q.add_function('f',string.lower)\n q.add_function('ff',string.find) \n q.add_function('ff',string.replace)\n q.add_function('fff',string.atof)\n q.add_function('fff',string.atoi)\n del q\n\n # now we're gonna make a new catalog with same code\n # but different functions in a specified module directory\n env_dir = empty_temp_dir()\n r = catalog.catalog(env_dir)\n r.add_function('ff',os.abort)\n r.add_function('ff',os.chdir)\n r.add_function('fff',os.access)\n r.add_function('fff',os.open)\n del r\n # now we're gonna make a new catalog with same code\n # but different functions in a user specified directory\n user_dir = empty_temp_dir()\n s = catalog.catalog(user_dir)\n import re\n s.add_function('fff',re.match)\n s.add_function('fff',re.purge)\n del s\n\n # open new catalog and make sure it retreives the functions\n # from d catalog instead of the temp catalog (made by q)\n os.environ['PYTHONCOMPILED'] = env_dir\n t = catalog.catalog(user_dir)\n funcs1 = t.get_functions('f')\n funcs2 = t.get_functions('ff')\n funcs3 = t.get_functions('fff')\n restore_temp_catalog()\n # make sure everything is read back in the correct order\n assert(funcs1 == [string.lower,string.upper])\n assert(funcs2 == [os.chdir,os.abort,string.replace,string.find])\n assert(funcs3 == [re.purge,re.match,os.open,\n os.access,string.atoi,string.atof])\n cleanup_temp_dir(user_dir)\n cleanup_temp_dir(env_dir)\n \n \ndef test_suite():\n suites = []\n suites.append( unittest.makeSuite(test_default_dir,'check_'))\n suites.append( unittest.makeSuite(test_os_dependent_catalog_name,'check_'))\n suites.append( unittest.makeSuite(test_catalog_path,'check_'))\n suites.append( unittest.makeSuite(test_get_catalog,'check_'))\n suites.append( unittest.makeSuite(test_catalog,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test():\n all_tests = test_suite()\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\n\nif __name__ == '__main__':\n test()\n", "methods": [ { "name": "check_is_writable", "long_name": "check_is_writable( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 51, "parameters": [ "self" ], "start_line": 21, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_current", "long_name": "check_current( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 47, "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": "check_user", "long_name": "check_user( path )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 54, "parameters": [ "path" ], "start_line": 47, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_module", "long_name": "check_module( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 54, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_path", "long_name": "check_path( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_bad_path", "long_name": "check_bad_path( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 67, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_test_dir", "long_name": "get_test_dir( self , erase = 0 )", "filename": "test_catalog.py", "nloc": 16, "complexity": 8, "token_count": 155, "parameters": [ "self", "erase" ], "start_line": 79, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_nonexistent_catalog_is_none", "long_name": "check_nonexistent_catalog_is_none( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 96, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_create_catalog", "long_name": "check_create_catalog( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 100, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_environ", "long_name": "clear_environ( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 107, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "reset_environ", "long_name": "reset_environ( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self" ], "start_line": 113, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "setUp", "long_name": "setUp( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 117, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "tearDown", "long_name": "tearDown( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 119, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_set_module_directory", "long_name": "check_set_module_directory( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 122, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_clear_module_directory", "long_name": "check_clear_module_directory( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 127, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_environ_path", "long_name": "check_get_environ_path( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 65, "parameters": [ "self" ], "start_line": 134, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order1", "long_name": "check_build_search_order1( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 141, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order2", "long_name": "check_build_search_order2( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 148, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_build_search_order3", "long_name": "check_build_search_order3( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 154, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order4", "long_name": "check_build_search_order4( self )", "filename": "test_catalog.py", "nloc": 8, "complexity": 2, "token_count": 85, "parameters": [ "self" ], "start_line": 161, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_catalog_files1", "long_name": "check_catalog_files1( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 172, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_catalog_files2", "long_name": "check_catalog_files2( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 179, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_existing_files1", "long_name": "check_get_existing_files1( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 187, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_get_existing_files2", "long_name": "check_get_existing_files2( self )", "filename": "test_catalog.py", "nloc": 11, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 195, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_access_writable_file", "long_name": "check_access_writable_file( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 49, "parameters": [ "self" ], "start_line": 210, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_writable_with_bad_path", "long_name": "check_writable_with_bad_path( self )", "filename": "test_catalog.py", "nloc": 12, "complexity": 3, "token_count": 79, "parameters": [ "self" ], "start_line": 221, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_writable_dir", "long_name": "check_writable_dir( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "self" ], "start_line": 236, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_unique_module_name", "long_name": "check_unique_module_name( self )", "filename": "test_catalog.py", "nloc": 14, "complexity": 2, "token_count": 94, "parameters": [ "self" ], "start_line": 248, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_add_function_persistent1", "long_name": "check_add_function_persistent1( self )", "filename": "test_catalog.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self" ], "start_line": 266, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "not_sure_about_this_check_add_function_persistent2", "long_name": "not_sure_about_this_check_add_function_persistent2( self )", "filename": "test_catalog.py", "nloc": 29, "complexity": 6, "token_count": 208, "parameters": [ "self" ], "start_line": 283, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_add_function_ordered", "long_name": "check_add_function_ordered( self )", "filename": "test_catalog.py", "nloc": 36, "complexity": 1, "token_count": 288, "parameters": [ "self" ], "start_line": 322, "end_line": 367, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "test_catalog.py", "nloc": 9, "complexity": 1, "token_count": 83, "parameters": [], "start_line": 370, "end_line": 379, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 381, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_is_writable", "long_name": "check_is_writable( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 51, "parameters": [ "self" ], "start_line": 21, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_current", "long_name": "check_current( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 47, "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": "check_user", "long_name": "check_user( path )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 54, "parameters": [ "path" ], "start_line": 47, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_module", "long_name": "check_module( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 54, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_path", "long_name": "check_path( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_bad_path", "long_name": "check_bad_path( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 67, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_test_dir", "long_name": "get_test_dir( self , erase = 0 )", "filename": "test_catalog.py", "nloc": 16, "complexity": 8, "token_count": 155, "parameters": [ "self", "erase" ], "start_line": 79, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_nonexistent_catalog_is_none", "long_name": "check_nonexistent_catalog_is_none( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 96, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_create_catalog", "long_name": "check_create_catalog( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 100, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_environ", "long_name": "clear_environ( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 107, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "reset_environ", "long_name": "reset_environ( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self" ], "start_line": 113, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "setUp", "long_name": "setUp( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 117, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "tearDown", "long_name": "tearDown( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 119, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_set_module_directory", "long_name": "check_set_module_directory( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 122, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_clear_module_directory", "long_name": "check_clear_module_directory( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 127, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_environ_path", "long_name": "check_get_environ_path( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 65, "parameters": [ "self" ], "start_line": 134, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order1", "long_name": "check_build_search_order1( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 141, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order2", "long_name": "check_build_search_order2( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 148, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_build_search_order3", "long_name": "check_build_search_order3( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 154, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order4", "long_name": "check_build_search_order4( self )", "filename": "test_catalog.py", "nloc": 8, "complexity": 2, "token_count": 85, "parameters": [ "self" ], "start_line": 161, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_catalog_files1", "long_name": "check_catalog_files1( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 172, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_catalog_files2", "long_name": "check_catalog_files2( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 179, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_existing_files1", "long_name": "check_get_existing_files1( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 187, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_get_existing_files2", "long_name": "check_get_existing_files2( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 195, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_access_writable_file", "long_name": "check_access_writable_file( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 49, "parameters": [ "self" ], "start_line": 209, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_writable_with_bad_path", "long_name": "check_writable_with_bad_path( self )", "filename": "test_catalog.py", "nloc": 12, "complexity": 3, "token_count": 79, "parameters": [ "self" ], "start_line": 220, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_writable_dir", "long_name": "check_writable_dir( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "self" ], "start_line": 235, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_unique_module_name", "long_name": "check_unique_module_name( self )", "filename": "test_catalog.py", "nloc": 14, "complexity": 2, "token_count": 94, "parameters": [ "self" ], "start_line": 247, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_add_function_persistent1", "long_name": "check_add_function_persistent1( self )", "filename": "test_catalog.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self" ], "start_line": 265, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "not_sure_about_this_check_add_function_persistent2", "long_name": "not_sure_about_this_check_add_function_persistent2( self )", "filename": "test_catalog.py", "nloc": 29, "complexity": 6, "token_count": 208, "parameters": [ "self" ], "start_line": 282, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_add_function_ordered", "long_name": "check_add_function_ordered( self )", "filename": "test_catalog.py", "nloc": 36, "complexity": 1, "token_count": 288, "parameters": [ "self" ], "start_line": 321, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "test_catalog.py", "nloc": 9, "complexity": 1, "token_count": 83, "parameters": [], "start_line": 369, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 380, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_create_catalog", "long_name": "check_create_catalog( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 100, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_get_existing_files2", "long_name": "check_get_existing_files2( self )", "filename": "test_catalog.py", "nloc": 11, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 195, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 } ], "nloc": 308, "complexity": 59, "token_count": 2222, "diff_parsed": { "added": [ " catalog = get_catalog(pardir,'c')", " print 'files:', files" ], "deleted": [ " catalog = get_catalog(pardir,'cr')" ] } } ] }, { "hash": "fcae4225269b490f5f644540d5592639190a67e5", "msg": "added -mimpure-text to link args on Sun OS to fix issues with libstdc++.a. see:\nhttp://mail.python.org/pipermail/python-dev/2001-March/013510.html", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-01-07T03:28:12+00:00", "author_timezone": 0, "committer_date": "2002-01-07T03:28:12+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "2b514abd3d8590aac40c400fc6f043a36e136bed" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 0, "insertions": 10, "lines": 10, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "weave/build_tools.py", "new_path": "weave/build_tools.py", "filename": "build_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -150,6 +150,16 @@ def build_extension(module_path,compiler_name = '',build_dir = None,\n if compiler_name != 'msvc':\n libraries = kw.get('libraries',[])\n kw['libraries'] = ['stdc++'] + libraries \n+ \n+ # SunOS specific\n+ # fix for issue with linking to libstdc++.a. see:\n+ # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n+ platform = sys.platform\n+ version = sys.version.lower()\n+ if platform[:5] == 'sunos' version.find('gcc') != -1:\n+ extra_link_args = kw.get('extra_link_args',[])\n+ kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n+ \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n", "added_lines": 10, "deleted_lines": 0, "source_code": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n compiler_name = choose_compiler(compiler_name)\n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1: verb = 1 \n else: verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n # add module to the needed source code files and build extension\n # FIX this is g++ specific. It probably should be fixed for other\n # Unices/compilers. Find a generic solution\n if compiler_name != 'msvc':\n libraries = kw.get('libraries',[])\n kw['libraries'] = ['stdc++'] + libraries \n \n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n \n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists():\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('gcc -v')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system('gcc -v')\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist or is \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist or is \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\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, verbose, \n dry_run, force)\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 # **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 self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -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 \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 # 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 # 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 import lib2def as lib2def\n #libfile, deffile = parse_cmd()\n #if deffile == 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 \ndef test():\n from scipy_test import module_test\n module_test(__name__,__file__)\n\ndef test_suite():\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__) \n\n\n\n", "source_code_before": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n compiler_name = choose_compiler(compiler_name)\n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1: verb = 1 \n else: verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n # add module to the needed source code files and build extension\n # FIX this is g++ specific. It probably should be fixed for other\n # Unices/compilers. Find a generic solution\n if compiler_name != 'msvc':\n libraries = kw.get('libraries',[])\n kw['libraries'] = ['stdc++'] + libraries \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n \n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists():\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('gcc -v')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system('gcc -v')\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist or is \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist or is \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\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, verbose, \n dry_run, force)\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 # **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 self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -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 \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 # 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 # 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 import lib2def as lib2def\n #libfile, deffile = parse_cmd()\n #if deffile == 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 \ndef test():\n from scipy_test import module_test\n module_test(__name__,__file__)\n\ndef test_suite():\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__) \n\n\n\n", "methods": [ { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 52, "complexity": 9, "token_count": 389, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 27, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 168, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 197, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 209, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 212, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 220, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( )", "filename": "build_tools.py", "nloc": 11, "complexity": 3, "token_count": 61, "parameters": [], "start_line": 243, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 264, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 283, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 299, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 336, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 390, "end_line": 398, "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": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 400, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 435, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 47, "complexity": 8, "token_count": 336, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 27, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 158, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 187, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 199, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 202, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 210, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( )", "filename": "build_tools.py", "nloc": 11, "complexity": 3, "token_count": 61, "parameters": [], "start_line": 233, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 254, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 273, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 289, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 326, "end_line": 368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 380, "end_line": 388, "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": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 390, "end_line": 416, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 421, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 425, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 52, "complexity": 9, "token_count": 389, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 27, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 168, "top_nesting_level": 0 } ], "nloc": 221, "complexity": 54, "token_count": 1363, "diff_parsed": { "added": [ "", " # SunOS specific", " # fix for issue with linking to libstdc++.a. see:", " # http://mail.python.org/pipermail/python-dev/2001-March/013510.html", " platform = sys.platform", " version = sys.version.lower()", " if platform[:5] == 'sunos' version.find('gcc') != -1:", " extra_link_args = kw.get('extra_link_args',[])", " kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args", "" ], "deleted": [] } } ] }, { "hash": "a12726debee9d108487b30f891c21685f8dd402d", "msg": "oops -- missed 'and' in during last check in.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-01-07T03:30:14+00:00", "author_timezone": 0, "committer_date": "2002-01-07T03:30:14+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "fcae4225269b490f5f644540d5592639190a67e5" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/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": "weave/build_tools.py", "new_path": "weave/build_tools.py", "filename": "build_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -156,7 +156,7 @@ def build_extension(module_path,compiler_name = '',build_dir = None,\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n- if platform[:5] == 'sunos' version.find('gcc') != -1:\n+ if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n compiler_name = choose_compiler(compiler_name)\n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1: verb = 1 \n else: verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n # add module to the needed source code files and build extension\n # FIX this is g++ specific. It probably should be fixed for other\n # Unices/compilers. Find a generic solution\n if compiler_name != 'msvc':\n libraries = kw.get('libraries',[])\n kw['libraries'] = ['stdc++'] + libraries \n \n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n \n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists():\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('gcc -v')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system('gcc -v')\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist or is \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist or is \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\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, verbose, \n dry_run, force)\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 # **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 self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -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 \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 # 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 # 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 import lib2def as lib2def\n #libfile, deffile = parse_cmd()\n #if deffile == 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 \ndef test():\n from scipy_test import module_test\n module_test(__name__,__file__)\n\ndef test_suite():\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__) \n\n\n\n", "source_code_before": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n compiler_name = choose_compiler(compiler_name)\n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1: verb = 1 \n else: verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n # add module to the needed source code files and build extension\n # FIX this is g++ specific. It probably should be fixed for other\n # Unices/compilers. Find a generic solution\n if compiler_name != 'msvc':\n libraries = kw.get('libraries',[])\n kw['libraries'] = ['stdc++'] + libraries \n \n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n \n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists():\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('gcc -v')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system('gcc -v')\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist or is \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist or is \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\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, verbose, \n dry_run, force)\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 # **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 self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -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 \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 # 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 # 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 import lib2def as lib2def\n #libfile, deffile = parse_cmd()\n #if deffile == 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 \ndef test():\n from scipy_test import module_test\n module_test(__name__,__file__)\n\ndef test_suite():\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__) \n\n\n\n", "methods": [ { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 52, "complexity": 10, "token_count": 390, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 27, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 168, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 197, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 209, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 212, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 220, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( )", "filename": "build_tools.py", "nloc": 11, "complexity": 3, "token_count": 61, "parameters": [], "start_line": 243, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 264, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 283, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 299, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 336, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 390, "end_line": 398, "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": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 400, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 435, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 52, "complexity": 9, "token_count": 389, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 27, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 168, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 197, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 209, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 212, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 220, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( )", "filename": "build_tools.py", "nloc": 11, "complexity": 3, "token_count": 61, "parameters": [], "start_line": 243, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 264, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 283, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 299, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 336, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 390, "end_line": 398, "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": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 400, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 435, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 52, "complexity": 10, "token_count": 390, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 27, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 168, "top_nesting_level": 0 } ], "nloc": 221, "complexity": 55, "token_count": 1364, "diff_parsed": { "added": [ " if platform[:5] == 'sunos' and version.find('gcc') != -1:" ], "deleted": [ " if platform[:5] == 'sunos' version.find('gcc') != -1:" ] } } ] }, { "hash": "20246d094c9e39337597a7d8b38612c92b0d5646", "msg": "got rid of from catalog import * in test code that forced restarts for testing to reflect code changes", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-01-07T03:39:58+00:00", "author_timezone": 0, "committer_date": "2002-01-07T03:39:58+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "a12726debee9d108487b30f891c21685f8dd402d" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 14, "insertions": 17, "lines": 31, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/tests/test_catalog.py", "new_path": "weave/tests/test_catalog.py", "filename": "test_catalog.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -34,13 +34,13 @@ class test_os_dependent_catalog_name(unittest.TestCase):\n class test_catalog_path(unittest.TestCase): \n def check_default(self):\n in_path = default_dir()\n- path = catalog_path(in_path)\n+ path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n assert(f == os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n- path = catalog_path(in_path)\n+ path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n assert(f == os_dependent_catalog_name()) \n@@ -50,24 +50,24 @@ def check_user(path):\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n- assert(f == os_dependent_catalog_name())\n+ assert(f == catalog.os_dependent_catalog_name())\n def check_module(self):\n # hand it a module and see if it uses the parent directory\n # of the module.\n- path = catalog_path(os.__file__)\n+ path = catalog.catalog_path(os.__file__)\n d,f = os.path.split(os.__file__)\n d2,f = os.path.split(path)\n assert (d2 == d)\n def check_path(self):\n # use os.__file__ to get a usable directory.\n in_path,f = os.path.split(os.__file__)\n- path = catalog_path(in_path)\n+ path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert (d == in_path)\n def check_bad_path(self):\n # stupid_path_name\n in_path = 'stupid_path_name'\n- path = catalog_path(in_path)\n+ path = catalog.catalog_path(in_path)\n assert (path is None)\n \n class test_get_catalog(unittest.TestCase):\n@@ -83,24 +83,27 @@ def get_test_dir(self,erase = 0):\n pardir = os.path.join(temp,'catalog_test'+tempfile.gettempprefix())\n if not os.path.exists(pardir):\n os.mkdir(pardir)\n- catalog_file = os.path.join(pardir,os_dependent_catalog_name()+'.dat')\n+ catalog_file = os.path.join(pardir,\n+ catalog.os_dependent_catalog_name()+'.dat')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n- catalog_file = os.path.join(pardir,os_dependent_catalog_name()+'.dir')\n+ catalog_file = os.path.join(pardir,\n+ catalog.os_dependent_catalog_name()+'.dir')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n- catalog_file = os.path.join(pardir,os_dependent_catalog_name())\n+ catalog_file = os.path.join(pardir,\n+ catalog.os_dependent_catalog_name())\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n return pardir\n def check_nonexistent_catalog_is_none(self):\n pardir = self.get_test_dir(erase=1)\n- catalog = get_catalog(pardir)\n- assert(catalog is None)\n+ cat = catalog.get_catalog(pardir)\n+ assert(cat is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n- catalog = get_catalog(pardir,'c')\n- assert(catalog is not None)\n+ cat = catalog.get_catalog(pardir,'c')\n+ assert(cat is not None)\n \n class test_catalog(unittest.TestCase):\n \n@@ -293,7 +296,7 @@ def not_sure_about_this_check_add_function_persistent2(self):\n q.add_function_persistent('code',i)\n \n d = empty_temp_dir()\n- q = catalog(d) \n+ q = catalog.catalog(d) \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name2, funcs2 = simple_module(d,f,'f')\n", "added_lines": 17, "deleted_lines": 14, "source_code": "import unittest\nimport sys, os\n\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nfrom catalog import *\n# not sure why, but was having problems with which catalog was being called.\nimport catalog\n#catalog = catalog.catalog\nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\n\nclass test_default_dir(unittest.TestCase):\n def check_is_writable(self):\n path = default_dir()\n name = os.path.join(path,'dummy_catalog')\n test_file = open(name,'w')\n try:\n test_file.write('making sure default location is writable\\n')\n finally:\n test_file.close()\n os.remove(name)\n\nclass test_os_dependent_catalog_name(unittest.TestCase): \n pass\n \nclass test_catalog_path(unittest.TestCase): \n def check_default(self):\n in_path = default_dir()\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n assert(f == os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n assert(f == os_dependent_catalog_name()) \n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n assert(f == catalog.os_dependent_catalog_name())\n def check_module(self):\n # hand it a module and see if it uses the parent directory\n # of the module.\n path = catalog.catalog_path(os.__file__)\n d,f = os.path.split(os.__file__)\n d2,f = os.path.split(path)\n assert (d2 == d)\n def check_path(self):\n # use os.__file__ to get a usable directory.\n in_path,f = os.path.split(os.__file__)\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert (d == in_path)\n def check_bad_path(self):\n # stupid_path_name\n in_path = 'stupid_path_name'\n path = catalog.catalog_path(in_path)\n assert (path is None)\n\nclass test_get_catalog(unittest.TestCase):\n \"\"\" This only tests whether new catalogs are created correctly.\n And whether non-existent return None correctly with read mode.\n Putting catalogs in the right place is all tested with\n catalog_dir tests.\n \"\"\"\n def get_test_dir(self,erase = 0):\n # make sure tempdir catalog doesn't exist\n import tempfile\n temp = tempfile.gettempdir()\n pardir = os.path.join(temp,'catalog_test'+tempfile.gettempprefix())\n if not os.path.exists(pardir):\n os.mkdir(pardir)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name()+'.dat')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name()+'.dir')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name())\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n return pardir\n def check_nonexistent_catalog_is_none(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir)\n assert(cat is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir,'c')\n assert(cat is not None)\n\nclass test_catalog(unittest.TestCase):\n\n def clear_environ(self):\n if os.environ.has_key('PYTHONCOMPILED'):\n self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED']\n del os.environ['PYTHONCOMPILED']\n else: \n self.old_PYTHONCOMPILED = None\n def reset_environ(self):\n if self.old_PYTHONCOMPILED:\n os.environ['PYTHONCOMPILED'] = self.old_PYTHONCOMPILED\n self.old_PYTHONCOMPILED = None\n def setUp(self):\n self.clear_environ() \n def tearDown(self):\n self.reset_environ()\n \n def check_set_module_directory(self):\n q = catalog.catalog()\n q.set_module_directory('bob')\n r = q.get_module_directory()\n assert (r == 'bob')\n def check_clear_module_directory(self):\n q = catalog.catalog()\n r = q.get_module_directory()\n assert (r == None)\n q.set_module_directory('bob')\n r = q.clear_module_directory()\n assert (r == None)\n def check_get_environ_path(self):\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('path1','path2','path3'))\n q = catalog.catalog()\n path = q.get_environ_path() \n assert(path == ['path1','path2','path3'])\n def check_build_search_order1(self): \n \"\"\" MODULE in search path should be replaced by module_dir.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n q.set_module_directory('second')\n order = q.build_search_order()\n assert(order == ['first','second','third',default_dir()])\n def check_build_search_order2(self): \n \"\"\" MODULE in search path should be removed if module_dir==None.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n order = q.build_search_order()\n assert(order == ['first','third',default_dir()]) \n def check_build_search_order3(self):\n \"\"\" If MODULE is absent, module_dir shouldn't be in search path.\n \"\"\" \n q = catalog.catalog(['first','second'])\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second',default_dir()])\n def check_build_search_order4(self):\n \"\"\" Make sure environment variable is getting used.\n \"\"\" \n q = catalog.catalog(['first','second'])\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second','third','fourth','fifth',default_dir()])\n \n def check_catalog_files1(self):\n \"\"\" Be sure we get at least one file even without specifying the path.\n \"\"\"\n q = catalog.catalog()\n files = q.get_catalog_files()\n assert(len(files) == 1)\n\n def check_catalog_files2(self):\n \"\"\" Ignore bad paths in the path.\n \"\"\"\n q = catalog.catalog()\n os.environ['PYTHONCOMPILED'] = '_some_bad_path_'\n files = q.get_catalog_files()\n assert(len(files) == 1)\n \n def check_get_existing_files1(self):\n \"\"\" Shouldn't get any files when temp doesn't exist and no path set. \n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 0)\n def check_get_existing_files2(self):\n \"\"\" Shouldn't get a single file from the temp dir.\n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n # create a dummy file\n import os \n q.add_function('code', os.getpid)\n del q\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n print 'files:', files\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n \"\"\" There should always be a writable file -- even if it is in temp\n \"\"\"\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_with_bad_path(self):\n \"\"\" There should always be a writable file -- even if search paths contain\n bad values.\n \"\"\"\n if sys.platform == 'win32': sep = ';'\n else: sep = ':' \n os.environ['PYTHONCOMPILED'] = sep.join(('_bad_path_name_'))\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_dir(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n d = q.get_writable_dir()\n file = os.path.join(d,'some_silly_file')\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file)\n def check_unique_module_name(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n file = q.unique_module_name('bob')\n cfile1 = file+'.cpp'\n assert(not os.path.exists(cfile1))\n #make sure it is writable\n try:\n f = open(cfile1,'w')\n f.write('bob')\n finally: \n f.close()\n # try again with same code fragment -- should get unique name\n file = q.unique_module_name('bob')\n cfile2 = file+'.cpp'\n assert(not os.path.exists(cfile2+'.cpp'))\n os.remove(cfile1)\n def check_add_function_persistent1(self):\n \"\"\" Test persisting a function in the default catalog\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog()\n mod_name = q.unique_module_name('bob')\n d,f = os.path.split(mod_name)\n module_name, funcs = simple_module(d,f,'f')\n for i in funcs:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n os.remove(module_name)\n # any way to clean modules???\n restore_temp_catalog()\n for i in funcs:\n assert(i in pfuncs) \n \n def not_sure_about_this_check_add_function_persistent2(self):\n \"\"\" Test ordering of persistent functions\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog() \n \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name1, funcs1 = simple_module(d,f,'f')\n for i in funcs1:\n q.add_function_persistent('code',i)\n \n d = empty_temp_dir()\n q = catalog.catalog(d) \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name2, funcs2 = simple_module(d,f,'f')\n for i in funcs2:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n \n os.remove(module_name1)\n os.remove(module_name2)\n cleanup_temp_dir(d)\n restore_temp_catalog()\n # any way to clean modules???\n for i in funcs1:\n assert(i in pfuncs) \n for i in funcs2:\n assert(i in pfuncs)\n # make sure functions occur in correct order for\n # lookup \n all_funcs = zip(funcs1,funcs2)\n print all_funcs\n for a,b in all_funcs:\n assert(pfuncs.index(a) > pfuncs.index(b))\n \n assert(len(pfuncs) == 4)\n\n def check_add_function_ordered(self):\n clear_temp_catalog()\n q = catalog.catalog()\n import string\n \n q.add_function('f',string.upper) \n q.add_function('f',string.lower)\n q.add_function('ff',string.find) \n q.add_function('ff',string.replace)\n q.add_function('fff',string.atof)\n q.add_function('fff',string.atoi)\n del q\n\n # now we're gonna make a new catalog with same code\n # but different functions in a specified module directory\n env_dir = empty_temp_dir()\n r = catalog.catalog(env_dir)\n r.add_function('ff',os.abort)\n r.add_function('ff',os.chdir)\n r.add_function('fff',os.access)\n r.add_function('fff',os.open)\n del r\n # now we're gonna make a new catalog with same code\n # but different functions in a user specified directory\n user_dir = empty_temp_dir()\n s = catalog.catalog(user_dir)\n import re\n s.add_function('fff',re.match)\n s.add_function('fff',re.purge)\n del s\n\n # open new catalog and make sure it retreives the functions\n # from d catalog instead of the temp catalog (made by q)\n os.environ['PYTHONCOMPILED'] = env_dir\n t = catalog.catalog(user_dir)\n funcs1 = t.get_functions('f')\n funcs2 = t.get_functions('ff')\n funcs3 = t.get_functions('fff')\n restore_temp_catalog()\n # make sure everything is read back in the correct order\n assert(funcs1 == [string.lower,string.upper])\n assert(funcs2 == [os.chdir,os.abort,string.replace,string.find])\n assert(funcs3 == [re.purge,re.match,os.open,\n os.access,string.atoi,string.atof])\n cleanup_temp_dir(user_dir)\n cleanup_temp_dir(env_dir)\n \n \ndef test_suite():\n suites = []\n suites.append( unittest.makeSuite(test_default_dir,'check_'))\n suites.append( unittest.makeSuite(test_os_dependent_catalog_name,'check_'))\n suites.append( unittest.makeSuite(test_catalog_path,'check_'))\n suites.append( unittest.makeSuite(test_get_catalog,'check_'))\n suites.append( unittest.makeSuite(test_catalog,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test():\n all_tests = test_suite()\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\n\nif __name__ == '__main__':\n test()\n", "source_code_before": "import unittest\nimport sys, os\n\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nfrom catalog import *\n# not sure why, but was having problems with which catalog was being called.\nimport catalog\n#catalog = catalog.catalog\nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\n\nclass test_default_dir(unittest.TestCase):\n def check_is_writable(self):\n path = default_dir()\n name = os.path.join(path,'dummy_catalog')\n test_file = open(name,'w')\n try:\n test_file.write('making sure default location is writable\\n')\n finally:\n test_file.close()\n os.remove(name)\n\nclass test_os_dependent_catalog_name(unittest.TestCase): \n pass\n \nclass test_catalog_path(unittest.TestCase): \n def check_default(self):\n in_path = default_dir()\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n assert(f == os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n assert(f == os_dependent_catalog_name()) \n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n assert(f == os_dependent_catalog_name())\n def check_module(self):\n # hand it a module and see if it uses the parent directory\n # of the module.\n path = catalog_path(os.__file__)\n d,f = os.path.split(os.__file__)\n d2,f = os.path.split(path)\n assert (d2 == d)\n def check_path(self):\n # use os.__file__ to get a usable directory.\n in_path,f = os.path.split(os.__file__)\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert (d == in_path)\n def check_bad_path(self):\n # stupid_path_name\n in_path = 'stupid_path_name'\n path = catalog_path(in_path)\n assert (path is None)\n\nclass test_get_catalog(unittest.TestCase):\n \"\"\" This only tests whether new catalogs are created correctly.\n And whether non-existent return None correctly with read mode.\n Putting catalogs in the right place is all tested with\n catalog_dir tests.\n \"\"\"\n def get_test_dir(self,erase = 0):\n # make sure tempdir catalog doesn't exist\n import tempfile\n temp = tempfile.gettempdir()\n pardir = os.path.join(temp,'catalog_test'+tempfile.gettempprefix())\n if not os.path.exists(pardir):\n os.mkdir(pardir)\n catalog_file = os.path.join(pardir,os_dependent_catalog_name()+'.dat')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,os_dependent_catalog_name()+'.dir')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,os_dependent_catalog_name())\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n return pardir\n def check_nonexistent_catalog_is_none(self):\n pardir = self.get_test_dir(erase=1)\n catalog = get_catalog(pardir)\n assert(catalog is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n catalog = get_catalog(pardir,'c')\n assert(catalog is not None)\n\nclass test_catalog(unittest.TestCase):\n\n def clear_environ(self):\n if os.environ.has_key('PYTHONCOMPILED'):\n self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED']\n del os.environ['PYTHONCOMPILED']\n else: \n self.old_PYTHONCOMPILED = None\n def reset_environ(self):\n if self.old_PYTHONCOMPILED:\n os.environ['PYTHONCOMPILED'] = self.old_PYTHONCOMPILED\n self.old_PYTHONCOMPILED = None\n def setUp(self):\n self.clear_environ() \n def tearDown(self):\n self.reset_environ()\n \n def check_set_module_directory(self):\n q = catalog.catalog()\n q.set_module_directory('bob')\n r = q.get_module_directory()\n assert (r == 'bob')\n def check_clear_module_directory(self):\n q = catalog.catalog()\n r = q.get_module_directory()\n assert (r == None)\n q.set_module_directory('bob')\n r = q.clear_module_directory()\n assert (r == None)\n def check_get_environ_path(self):\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('path1','path2','path3'))\n q = catalog.catalog()\n path = q.get_environ_path() \n assert(path == ['path1','path2','path3'])\n def check_build_search_order1(self): \n \"\"\" MODULE in search path should be replaced by module_dir.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n q.set_module_directory('second')\n order = q.build_search_order()\n assert(order == ['first','second','third',default_dir()])\n def check_build_search_order2(self): \n \"\"\" MODULE in search path should be removed if module_dir==None.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n order = q.build_search_order()\n assert(order == ['first','third',default_dir()]) \n def check_build_search_order3(self):\n \"\"\" If MODULE is absent, module_dir shouldn't be in search path.\n \"\"\" \n q = catalog.catalog(['first','second'])\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second',default_dir()])\n def check_build_search_order4(self):\n \"\"\" Make sure environment variable is getting used.\n \"\"\" \n q = catalog.catalog(['first','second'])\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second','third','fourth','fifth',default_dir()])\n \n def check_catalog_files1(self):\n \"\"\" Be sure we get at least one file even without specifying the path.\n \"\"\"\n q = catalog.catalog()\n files = q.get_catalog_files()\n assert(len(files) == 1)\n\n def check_catalog_files2(self):\n \"\"\" Ignore bad paths in the path.\n \"\"\"\n q = catalog.catalog()\n os.environ['PYTHONCOMPILED'] = '_some_bad_path_'\n files = q.get_catalog_files()\n assert(len(files) == 1)\n \n def check_get_existing_files1(self):\n \"\"\" Shouldn't get any files when temp doesn't exist and no path set. \n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 0)\n def check_get_existing_files2(self):\n \"\"\" Shouldn't get a single file from the temp dir.\n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n # create a dummy file\n import os \n q.add_function('code', os.getpid)\n del q\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n print 'files:', files\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n \"\"\" There should always be a writable file -- even if it is in temp\n \"\"\"\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_with_bad_path(self):\n \"\"\" There should always be a writable file -- even if search paths contain\n bad values.\n \"\"\"\n if sys.platform == 'win32': sep = ';'\n else: sep = ':' \n os.environ['PYTHONCOMPILED'] = sep.join(('_bad_path_name_'))\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_dir(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n d = q.get_writable_dir()\n file = os.path.join(d,'some_silly_file')\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file)\n def check_unique_module_name(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n file = q.unique_module_name('bob')\n cfile1 = file+'.cpp'\n assert(not os.path.exists(cfile1))\n #make sure it is writable\n try:\n f = open(cfile1,'w')\n f.write('bob')\n finally: \n f.close()\n # try again with same code fragment -- should get unique name\n file = q.unique_module_name('bob')\n cfile2 = file+'.cpp'\n assert(not os.path.exists(cfile2+'.cpp'))\n os.remove(cfile1)\n def check_add_function_persistent1(self):\n \"\"\" Test persisting a function in the default catalog\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog()\n mod_name = q.unique_module_name('bob')\n d,f = os.path.split(mod_name)\n module_name, funcs = simple_module(d,f,'f')\n for i in funcs:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n os.remove(module_name)\n # any way to clean modules???\n restore_temp_catalog()\n for i in funcs:\n assert(i in pfuncs) \n \n def not_sure_about_this_check_add_function_persistent2(self):\n \"\"\" Test ordering of persistent functions\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog() \n \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name1, funcs1 = simple_module(d,f,'f')\n for i in funcs1:\n q.add_function_persistent('code',i)\n \n d = empty_temp_dir()\n q = catalog(d) \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name2, funcs2 = simple_module(d,f,'f')\n for i in funcs2:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n \n os.remove(module_name1)\n os.remove(module_name2)\n cleanup_temp_dir(d)\n restore_temp_catalog()\n # any way to clean modules???\n for i in funcs1:\n assert(i in pfuncs) \n for i in funcs2:\n assert(i in pfuncs)\n # make sure functions occur in correct order for\n # lookup \n all_funcs = zip(funcs1,funcs2)\n print all_funcs\n for a,b in all_funcs:\n assert(pfuncs.index(a) > pfuncs.index(b))\n \n assert(len(pfuncs) == 4)\n\n def check_add_function_ordered(self):\n clear_temp_catalog()\n q = catalog.catalog()\n import string\n \n q.add_function('f',string.upper) \n q.add_function('f',string.lower)\n q.add_function('ff',string.find) \n q.add_function('ff',string.replace)\n q.add_function('fff',string.atof)\n q.add_function('fff',string.atoi)\n del q\n\n # now we're gonna make a new catalog with same code\n # but different functions in a specified module directory\n env_dir = empty_temp_dir()\n r = catalog.catalog(env_dir)\n r.add_function('ff',os.abort)\n r.add_function('ff',os.chdir)\n r.add_function('fff',os.access)\n r.add_function('fff',os.open)\n del r\n # now we're gonna make a new catalog with same code\n # but different functions in a user specified directory\n user_dir = empty_temp_dir()\n s = catalog.catalog(user_dir)\n import re\n s.add_function('fff',re.match)\n s.add_function('fff',re.purge)\n del s\n\n # open new catalog and make sure it retreives the functions\n # from d catalog instead of the temp catalog (made by q)\n os.environ['PYTHONCOMPILED'] = env_dir\n t = catalog.catalog(user_dir)\n funcs1 = t.get_functions('f')\n funcs2 = t.get_functions('ff')\n funcs3 = t.get_functions('fff')\n restore_temp_catalog()\n # make sure everything is read back in the correct order\n assert(funcs1 == [string.lower,string.upper])\n assert(funcs2 == [os.chdir,os.abort,string.replace,string.find])\n assert(funcs3 == [re.purge,re.match,os.open,\n os.access,string.atoi,string.atof])\n cleanup_temp_dir(user_dir)\n cleanup_temp_dir(env_dir)\n \n \ndef test_suite():\n suites = []\n suites.append( unittest.makeSuite(test_default_dir,'check_'))\n suites.append( unittest.makeSuite(test_os_dependent_catalog_name,'check_'))\n suites.append( unittest.makeSuite(test_catalog_path,'check_'))\n suites.append( unittest.makeSuite(test_get_catalog,'check_'))\n suites.append( unittest.makeSuite(test_catalog,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test():\n all_tests = test_suite()\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\n\nif __name__ == '__main__':\n test()\n", "methods": [ { "name": "check_is_writable", "long_name": "check_is_writable( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 51, "parameters": [ "self" ], "start_line": 21, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_current", "long_name": "check_current( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 49, "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": "check_user", "long_name": "check_user( path )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 56, "parameters": [ "path" ], "start_line": 47, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_module", "long_name": "check_module( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 54, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_path", "long_name": "check_path( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_bad_path", "long_name": "check_bad_path( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 67, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_test_dir", "long_name": "get_test_dir( self , erase = 0 )", "filename": "test_catalog.py", "nloc": 19, "complexity": 8, "token_count": 161, "parameters": [ "self", "erase" ], "start_line": 79, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_nonexistent_catalog_is_none", "long_name": "check_nonexistent_catalog_is_none( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 99, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_create_catalog", "long_name": "check_create_catalog( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 103, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_environ", "long_name": "clear_environ( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 110, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "reset_environ", "long_name": "reset_environ( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self" ], "start_line": 116, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "setUp", "long_name": "setUp( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 120, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "tearDown", "long_name": "tearDown( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 122, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_set_module_directory", "long_name": "check_set_module_directory( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_clear_module_directory", "long_name": "check_clear_module_directory( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 130, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_environ_path", "long_name": "check_get_environ_path( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 65, "parameters": [ "self" ], "start_line": 137, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order1", "long_name": "check_build_search_order1( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 144, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order2", "long_name": "check_build_search_order2( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 151, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_build_search_order3", "long_name": "check_build_search_order3( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 157, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order4", "long_name": "check_build_search_order4( self )", "filename": "test_catalog.py", "nloc": 8, "complexity": 2, "token_count": 85, "parameters": [ "self" ], "start_line": 164, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_catalog_files1", "long_name": "check_catalog_files1( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 175, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_catalog_files2", "long_name": "check_catalog_files2( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 182, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_existing_files1", "long_name": "check_get_existing_files1( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 190, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_get_existing_files2", "long_name": "check_get_existing_files2( self )", "filename": "test_catalog.py", "nloc": 11, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 198, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_access_writable_file", "long_name": "check_access_writable_file( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 49, "parameters": [ "self" ], "start_line": 213, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_writable_with_bad_path", "long_name": "check_writable_with_bad_path( self )", "filename": "test_catalog.py", "nloc": 12, "complexity": 3, "token_count": 79, "parameters": [ "self" ], "start_line": 224, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_writable_dir", "long_name": "check_writable_dir( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "self" ], "start_line": 239, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_unique_module_name", "long_name": "check_unique_module_name( self )", "filename": "test_catalog.py", "nloc": 14, "complexity": 2, "token_count": 94, "parameters": [ "self" ], "start_line": 251, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_add_function_persistent1", "long_name": "check_add_function_persistent1( self )", "filename": "test_catalog.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self" ], "start_line": 269, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "not_sure_about_this_check_add_function_persistent2", "long_name": "not_sure_about_this_check_add_function_persistent2( self )", "filename": "test_catalog.py", "nloc": 29, "complexity": 6, "token_count": 210, "parameters": [ "self" ], "start_line": 286, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_add_function_ordered", "long_name": "check_add_function_ordered( self )", "filename": "test_catalog.py", "nloc": 36, "complexity": 1, "token_count": 288, "parameters": [ "self" ], "start_line": 325, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "test_catalog.py", "nloc": 9, "complexity": 1, "token_count": 83, "parameters": [], "start_line": 373, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 384, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_is_writable", "long_name": "check_is_writable( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 51, "parameters": [ "self" ], "start_line": 21, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_current", "long_name": "check_current( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 47, "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": "check_user", "long_name": "check_user( path )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 54, "parameters": [ "path" ], "start_line": 47, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_module", "long_name": "check_module( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 54, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_path", "long_name": "check_path( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_bad_path", "long_name": "check_bad_path( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 67, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_test_dir", "long_name": "get_test_dir( self , erase = 0 )", "filename": "test_catalog.py", "nloc": 16, "complexity": 8, "token_count": 155, "parameters": [ "self", "erase" ], "start_line": 79, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_nonexistent_catalog_is_none", "long_name": "check_nonexistent_catalog_is_none( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 96, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_create_catalog", "long_name": "check_create_catalog( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 100, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_environ", "long_name": "clear_environ( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 107, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "reset_environ", "long_name": "reset_environ( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self" ], "start_line": 113, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "setUp", "long_name": "setUp( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 117, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "tearDown", "long_name": "tearDown( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 119, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_set_module_directory", "long_name": "check_set_module_directory( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 122, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_clear_module_directory", "long_name": "check_clear_module_directory( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 127, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_environ_path", "long_name": "check_get_environ_path( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 65, "parameters": [ "self" ], "start_line": 134, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order1", "long_name": "check_build_search_order1( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 141, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order2", "long_name": "check_build_search_order2( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 148, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_build_search_order3", "long_name": "check_build_search_order3( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 154, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order4", "long_name": "check_build_search_order4( self )", "filename": "test_catalog.py", "nloc": 8, "complexity": 2, "token_count": 85, "parameters": [ "self" ], "start_line": 161, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_catalog_files1", "long_name": "check_catalog_files1( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 172, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_catalog_files2", "long_name": "check_catalog_files2( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 179, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_existing_files1", "long_name": "check_get_existing_files1( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 187, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_get_existing_files2", "long_name": "check_get_existing_files2( self )", "filename": "test_catalog.py", "nloc": 11, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 195, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_access_writable_file", "long_name": "check_access_writable_file( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 49, "parameters": [ "self" ], "start_line": 210, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_writable_with_bad_path", "long_name": "check_writable_with_bad_path( self )", "filename": "test_catalog.py", "nloc": 12, "complexity": 3, "token_count": 79, "parameters": [ "self" ], "start_line": 221, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_writable_dir", "long_name": "check_writable_dir( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "self" ], "start_line": 236, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_unique_module_name", "long_name": "check_unique_module_name( self )", "filename": "test_catalog.py", "nloc": 14, "complexity": 2, "token_count": 94, "parameters": [ "self" ], "start_line": 248, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_add_function_persistent1", "long_name": "check_add_function_persistent1( self )", "filename": "test_catalog.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self" ], "start_line": 266, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "not_sure_about_this_check_add_function_persistent2", "long_name": "not_sure_about_this_check_add_function_persistent2( self )", "filename": "test_catalog.py", "nloc": 29, "complexity": 6, "token_count": 208, "parameters": [ "self" ], "start_line": 283, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_add_function_ordered", "long_name": "check_add_function_ordered( self )", "filename": "test_catalog.py", "nloc": 36, "complexity": 1, "token_count": 288, "parameters": [ "self" ], "start_line": 322, "end_line": 367, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "test_catalog.py", "nloc": 9, "complexity": 1, "token_count": 83, "parameters": [], "start_line": 370, "end_line": 379, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 381, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_bad_path", "long_name": "check_bad_path( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 67, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_user", "long_name": "check_user( path )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 56, "parameters": [ "path" ], "start_line": 47, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_nonexistent_catalog_is_none", "long_name": "check_nonexistent_catalog_is_none( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 99, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "not_sure_about_this_check_add_function_persistent2", "long_name": "not_sure_about_this_check_add_function_persistent2( self )", "filename": "test_catalog.py", "nloc": 29, "complexity": 6, "token_count": 210, "parameters": [ "self" ], "start_line": 286, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "get_test_dir", "long_name": "get_test_dir( self , erase = 0 )", "filename": "test_catalog.py", "nloc": 19, "complexity": 8, "token_count": 161, "parameters": [ "self", "erase" ], "start_line": 79, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_create_catalog", "long_name": "check_create_catalog( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 103, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_path", "long_name": "check_path( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_current", "long_name": "check_current( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 49, "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": "check_module", "long_name": "check_module( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 54, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "nloc": 311, "complexity": 59, "token_count": 2246, "diff_parsed": { "added": [ " path = catalog.catalog_path(in_path)", " path = catalog.catalog_path(in_path)", " assert(f == catalog.os_dependent_catalog_name())", " path = catalog.catalog_path(os.__file__)", " path = catalog.catalog_path(in_path)", " path = catalog.catalog_path(in_path)", " catalog_file = os.path.join(pardir,", " catalog.os_dependent_catalog_name()+'.dat')", " catalog_file = os.path.join(pardir,", " catalog.os_dependent_catalog_name()+'.dir')", " catalog_file = os.path.join(pardir,", " catalog.os_dependent_catalog_name())", " cat = catalog.get_catalog(pardir)", " assert(cat is None)", " cat = catalog.get_catalog(pardir,'c')", " assert(cat is not None)", " q = catalog.catalog(d)" ], "deleted": [ " path = catalog_path(in_path)", " path = catalog_path(in_path)", " assert(f == os_dependent_catalog_name())", " path = catalog_path(os.__file__)", " path = catalog_path(in_path)", " path = catalog_path(in_path)", " catalog_file = os.path.join(pardir,os_dependent_catalog_name()+'.dat')", " catalog_file = os.path.join(pardir,os_dependent_catalog_name()+'.dir')", " catalog_file = os.path.join(pardir,os_dependent_catalog_name())", " catalog = get_catalog(pardir)", " assert(catalog is None)", " catalog = get_catalog(pardir,'c')", " assert(catalog is not None)", " q = catalog(d)" ] } } ] }, { "hash": "fb838538d73bb3cc154ab6ad47c96d1bb9f12f0d", "msg": "fixed a few more issues with removing 'from scipy import *'", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-01-07T05:29:32+00:00", "author_timezone": 0, "committer_date": "2002-01-07T05:29:32+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "20246d094c9e39337597a7d8b38612c92b0d5646" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 11, "insertions": 9, "lines": 20, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "weave/tests/test_catalog.py", "new_path": "weave/tests/test_catalog.py", "filename": "test_catalog.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -6,10 +6,8 @@\n from scipy_distutils.misc_util import add_local_to_path\n \n add_grandparent_to_path(__name__)\n-from catalog import *\n-# not sure why, but was having problems with which catalog was being called.\n import catalog\n-#catalog = catalog.catalog\n+reload(catalog) # this'll pick up any recent code changes\n restore_path()\n \n add_local_to_path(__name__)\n@@ -19,7 +17,7 @@\n \n class test_default_dir(unittest.TestCase):\n def check_is_writable(self):\n- path = default_dir()\n+ path = catalog.default_dir()\n name = os.path.join(path,'dummy_catalog')\n test_file = open(name,'w')\n try:\n@@ -33,17 +31,17 @@ class test_os_dependent_catalog_name(unittest.TestCase):\n \n class test_catalog_path(unittest.TestCase): \n def check_default(self):\n- in_path = default_dir()\n+ in_path = catalog.default_dir()\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n- assert(f == os_dependent_catalog_name())\n+ assert(f == catalog.os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n- assert(f == os_dependent_catalog_name()) \n+ assert(f == catalog.os_dependent_catalog_name()) \n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n@@ -147,20 +145,20 @@ def check_build_search_order1(self):\n q = catalog.catalog(['first','MODULE','third'])\n q.set_module_directory('second')\n order = q.build_search_order()\n- assert(order == ['first','second','third',default_dir()])\n+ assert(order == ['first','second','third',catalog.default_dir()])\n def check_build_search_order2(self): \n \"\"\" MODULE in search path should be removed if module_dir==None.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n order = q.build_search_order()\n- assert(order == ['first','third',default_dir()]) \n+ assert(order == ['first','third',catalog.default_dir()]) \n def check_build_search_order3(self):\n \"\"\" If MODULE is absent, module_dir shouldn't be in search path.\n \"\"\" \n q = catalog.catalog(['first','second'])\n q.set_module_directory('third')\n order = q.build_search_order()\n- assert(order == ['first','second',default_dir()])\n+ assert(order == ['first','second',catalog.default_dir()])\n def check_build_search_order4(self):\n \"\"\" Make sure environment variable is getting used.\n \"\"\" \n@@ -170,7 +168,7 @@ def check_build_search_order4(self):\n os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))\n q.set_module_directory('third')\n order = q.build_search_order()\n- assert(order == ['first','second','third','fourth','fifth',default_dir()])\n+ assert(order == ['first','second','third','fourth','fifth',catalog.default_dir()])\n \n def check_catalog_files1(self):\n \"\"\" Be sure we get at least one file even without specifying the path.\n", "added_lines": 9, "deleted_lines": 11, "source_code": "import unittest\nimport sys, os\n\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport catalog\nreload(catalog) # this'll pick up any recent code changes\nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\n\nclass test_default_dir(unittest.TestCase):\n def check_is_writable(self):\n path = catalog.default_dir()\n name = os.path.join(path,'dummy_catalog')\n test_file = open(name,'w')\n try:\n test_file.write('making sure default location is writable\\n')\n finally:\n test_file.close()\n os.remove(name)\n\nclass test_os_dependent_catalog_name(unittest.TestCase): \n pass\n \nclass test_catalog_path(unittest.TestCase): \n def check_default(self):\n in_path = catalog.default_dir()\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n assert(f == catalog.os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n assert(f == catalog.os_dependent_catalog_name()) \n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n assert(f == catalog.os_dependent_catalog_name())\n def check_module(self):\n # hand it a module and see if it uses the parent directory\n # of the module.\n path = catalog.catalog_path(os.__file__)\n d,f = os.path.split(os.__file__)\n d2,f = os.path.split(path)\n assert (d2 == d)\n def check_path(self):\n # use os.__file__ to get a usable directory.\n in_path,f = os.path.split(os.__file__)\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert (d == in_path)\n def check_bad_path(self):\n # stupid_path_name\n in_path = 'stupid_path_name'\n path = catalog.catalog_path(in_path)\n assert (path is None)\n\nclass test_get_catalog(unittest.TestCase):\n \"\"\" This only tests whether new catalogs are created correctly.\n And whether non-existent return None correctly with read mode.\n Putting catalogs in the right place is all tested with\n catalog_dir tests.\n \"\"\"\n def get_test_dir(self,erase = 0):\n # make sure tempdir catalog doesn't exist\n import tempfile\n temp = tempfile.gettempdir()\n pardir = os.path.join(temp,'catalog_test'+tempfile.gettempprefix())\n if not os.path.exists(pardir):\n os.mkdir(pardir)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name()+'.dat')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name()+'.dir')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name())\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n return pardir\n def check_nonexistent_catalog_is_none(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir)\n assert(cat is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir,'c')\n assert(cat is not None)\n\nclass test_catalog(unittest.TestCase):\n\n def clear_environ(self):\n if os.environ.has_key('PYTHONCOMPILED'):\n self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED']\n del os.environ['PYTHONCOMPILED']\n else: \n self.old_PYTHONCOMPILED = None\n def reset_environ(self):\n if self.old_PYTHONCOMPILED:\n os.environ['PYTHONCOMPILED'] = self.old_PYTHONCOMPILED\n self.old_PYTHONCOMPILED = None\n def setUp(self):\n self.clear_environ() \n def tearDown(self):\n self.reset_environ()\n \n def check_set_module_directory(self):\n q = catalog.catalog()\n q.set_module_directory('bob')\n r = q.get_module_directory()\n assert (r == 'bob')\n def check_clear_module_directory(self):\n q = catalog.catalog()\n r = q.get_module_directory()\n assert (r == None)\n q.set_module_directory('bob')\n r = q.clear_module_directory()\n assert (r == None)\n def check_get_environ_path(self):\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('path1','path2','path3'))\n q = catalog.catalog()\n path = q.get_environ_path() \n assert(path == ['path1','path2','path3'])\n def check_build_search_order1(self): \n \"\"\" MODULE in search path should be replaced by module_dir.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n q.set_module_directory('second')\n order = q.build_search_order()\n assert(order == ['first','second','third',catalog.default_dir()])\n def check_build_search_order2(self): \n \"\"\" MODULE in search path should be removed if module_dir==None.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n order = q.build_search_order()\n assert(order == ['first','third',catalog.default_dir()]) \n def check_build_search_order3(self):\n \"\"\" If MODULE is absent, module_dir shouldn't be in search path.\n \"\"\" \n q = catalog.catalog(['first','second'])\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second',catalog.default_dir()])\n def check_build_search_order4(self):\n \"\"\" Make sure environment variable is getting used.\n \"\"\" \n q = catalog.catalog(['first','second'])\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second','third','fourth','fifth',catalog.default_dir()])\n \n def check_catalog_files1(self):\n \"\"\" Be sure we get at least one file even without specifying the path.\n \"\"\"\n q = catalog.catalog()\n files = q.get_catalog_files()\n assert(len(files) == 1)\n\n def check_catalog_files2(self):\n \"\"\" Ignore bad paths in the path.\n \"\"\"\n q = catalog.catalog()\n os.environ['PYTHONCOMPILED'] = '_some_bad_path_'\n files = q.get_catalog_files()\n assert(len(files) == 1)\n \n def check_get_existing_files1(self):\n \"\"\" Shouldn't get any files when temp doesn't exist and no path set. \n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 0)\n def check_get_existing_files2(self):\n \"\"\" Shouldn't get a single file from the temp dir.\n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n # create a dummy file\n import os \n q.add_function('code', os.getpid)\n del q\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n print 'files:', files\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n \"\"\" There should always be a writable file -- even if it is in temp\n \"\"\"\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_with_bad_path(self):\n \"\"\" There should always be a writable file -- even if search paths contain\n bad values.\n \"\"\"\n if sys.platform == 'win32': sep = ';'\n else: sep = ':' \n os.environ['PYTHONCOMPILED'] = sep.join(('_bad_path_name_'))\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_dir(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n d = q.get_writable_dir()\n file = os.path.join(d,'some_silly_file')\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file)\n def check_unique_module_name(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n file = q.unique_module_name('bob')\n cfile1 = file+'.cpp'\n assert(not os.path.exists(cfile1))\n #make sure it is writable\n try:\n f = open(cfile1,'w')\n f.write('bob')\n finally: \n f.close()\n # try again with same code fragment -- should get unique name\n file = q.unique_module_name('bob')\n cfile2 = file+'.cpp'\n assert(not os.path.exists(cfile2+'.cpp'))\n os.remove(cfile1)\n def check_add_function_persistent1(self):\n \"\"\" Test persisting a function in the default catalog\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog()\n mod_name = q.unique_module_name('bob')\n d,f = os.path.split(mod_name)\n module_name, funcs = simple_module(d,f,'f')\n for i in funcs:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n os.remove(module_name)\n # any way to clean modules???\n restore_temp_catalog()\n for i in funcs:\n assert(i in pfuncs) \n \n def not_sure_about_this_check_add_function_persistent2(self):\n \"\"\" Test ordering of persistent functions\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog() \n \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name1, funcs1 = simple_module(d,f,'f')\n for i in funcs1:\n q.add_function_persistent('code',i)\n \n d = empty_temp_dir()\n q = catalog.catalog(d) \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name2, funcs2 = simple_module(d,f,'f')\n for i in funcs2:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n \n os.remove(module_name1)\n os.remove(module_name2)\n cleanup_temp_dir(d)\n restore_temp_catalog()\n # any way to clean modules???\n for i in funcs1:\n assert(i in pfuncs) \n for i in funcs2:\n assert(i in pfuncs)\n # make sure functions occur in correct order for\n # lookup \n all_funcs = zip(funcs1,funcs2)\n print all_funcs\n for a,b in all_funcs:\n assert(pfuncs.index(a) > pfuncs.index(b))\n \n assert(len(pfuncs) == 4)\n\n def check_add_function_ordered(self):\n clear_temp_catalog()\n q = catalog.catalog()\n import string\n \n q.add_function('f',string.upper) \n q.add_function('f',string.lower)\n q.add_function('ff',string.find) \n q.add_function('ff',string.replace)\n q.add_function('fff',string.atof)\n q.add_function('fff',string.atoi)\n del q\n\n # now we're gonna make a new catalog with same code\n # but different functions in a specified module directory\n env_dir = empty_temp_dir()\n r = catalog.catalog(env_dir)\n r.add_function('ff',os.abort)\n r.add_function('ff',os.chdir)\n r.add_function('fff',os.access)\n r.add_function('fff',os.open)\n del r\n # now we're gonna make a new catalog with same code\n # but different functions in a user specified directory\n user_dir = empty_temp_dir()\n s = catalog.catalog(user_dir)\n import re\n s.add_function('fff',re.match)\n s.add_function('fff',re.purge)\n del s\n\n # open new catalog and make sure it retreives the functions\n # from d catalog instead of the temp catalog (made by q)\n os.environ['PYTHONCOMPILED'] = env_dir\n t = catalog.catalog(user_dir)\n funcs1 = t.get_functions('f')\n funcs2 = t.get_functions('ff')\n funcs3 = t.get_functions('fff')\n restore_temp_catalog()\n # make sure everything is read back in the correct order\n assert(funcs1 == [string.lower,string.upper])\n assert(funcs2 == [os.chdir,os.abort,string.replace,string.find])\n assert(funcs3 == [re.purge,re.match,os.open,\n os.access,string.atoi,string.atof])\n cleanup_temp_dir(user_dir)\n cleanup_temp_dir(env_dir)\n \n \ndef test_suite():\n suites = []\n suites.append( unittest.makeSuite(test_default_dir,'check_'))\n suites.append( unittest.makeSuite(test_os_dependent_catalog_name,'check_'))\n suites.append( unittest.makeSuite(test_catalog_path,'check_'))\n suites.append( unittest.makeSuite(test_get_catalog,'check_'))\n suites.append( unittest.makeSuite(test_catalog,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test():\n all_tests = test_suite()\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\n\nif __name__ == '__main__':\n test()\n", "source_code_before": "import unittest\nimport sys, os\n\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nfrom catalog import *\n# not sure why, but was having problems with which catalog was being called.\nimport catalog\n#catalog = catalog.catalog\nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\n\nclass test_default_dir(unittest.TestCase):\n def check_is_writable(self):\n path = default_dir()\n name = os.path.join(path,'dummy_catalog')\n test_file = open(name,'w')\n try:\n test_file.write('making sure default location is writable\\n')\n finally:\n test_file.close()\n os.remove(name)\n\nclass test_os_dependent_catalog_name(unittest.TestCase): \n pass\n \nclass test_catalog_path(unittest.TestCase): \n def check_default(self):\n in_path = default_dir()\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n assert(f == os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n assert(f == os_dependent_catalog_name()) \n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n assert(f == catalog.os_dependent_catalog_name())\n def check_module(self):\n # hand it a module and see if it uses the parent directory\n # of the module.\n path = catalog.catalog_path(os.__file__)\n d,f = os.path.split(os.__file__)\n d2,f = os.path.split(path)\n assert (d2 == d)\n def check_path(self):\n # use os.__file__ to get a usable directory.\n in_path,f = os.path.split(os.__file__)\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert (d == in_path)\n def check_bad_path(self):\n # stupid_path_name\n in_path = 'stupid_path_name'\n path = catalog.catalog_path(in_path)\n assert (path is None)\n\nclass test_get_catalog(unittest.TestCase):\n \"\"\" This only tests whether new catalogs are created correctly.\n And whether non-existent return None correctly with read mode.\n Putting catalogs in the right place is all tested with\n catalog_dir tests.\n \"\"\"\n def get_test_dir(self,erase = 0):\n # make sure tempdir catalog doesn't exist\n import tempfile\n temp = tempfile.gettempdir()\n pardir = os.path.join(temp,'catalog_test'+tempfile.gettempprefix())\n if not os.path.exists(pardir):\n os.mkdir(pardir)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name()+'.dat')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name()+'.dir')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name())\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n return pardir\n def check_nonexistent_catalog_is_none(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir)\n assert(cat is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir,'c')\n assert(cat is not None)\n\nclass test_catalog(unittest.TestCase):\n\n def clear_environ(self):\n if os.environ.has_key('PYTHONCOMPILED'):\n self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED']\n del os.environ['PYTHONCOMPILED']\n else: \n self.old_PYTHONCOMPILED = None\n def reset_environ(self):\n if self.old_PYTHONCOMPILED:\n os.environ['PYTHONCOMPILED'] = self.old_PYTHONCOMPILED\n self.old_PYTHONCOMPILED = None\n def setUp(self):\n self.clear_environ() \n def tearDown(self):\n self.reset_environ()\n \n def check_set_module_directory(self):\n q = catalog.catalog()\n q.set_module_directory('bob')\n r = q.get_module_directory()\n assert (r == 'bob')\n def check_clear_module_directory(self):\n q = catalog.catalog()\n r = q.get_module_directory()\n assert (r == None)\n q.set_module_directory('bob')\n r = q.clear_module_directory()\n assert (r == None)\n def check_get_environ_path(self):\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('path1','path2','path3'))\n q = catalog.catalog()\n path = q.get_environ_path() \n assert(path == ['path1','path2','path3'])\n def check_build_search_order1(self): \n \"\"\" MODULE in search path should be replaced by module_dir.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n q.set_module_directory('second')\n order = q.build_search_order()\n assert(order == ['first','second','third',default_dir()])\n def check_build_search_order2(self): \n \"\"\" MODULE in search path should be removed if module_dir==None.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n order = q.build_search_order()\n assert(order == ['first','third',default_dir()]) \n def check_build_search_order3(self):\n \"\"\" If MODULE is absent, module_dir shouldn't be in search path.\n \"\"\" \n q = catalog.catalog(['first','second'])\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second',default_dir()])\n def check_build_search_order4(self):\n \"\"\" Make sure environment variable is getting used.\n \"\"\" \n q = catalog.catalog(['first','second'])\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second','third','fourth','fifth',default_dir()])\n \n def check_catalog_files1(self):\n \"\"\" Be sure we get at least one file even without specifying the path.\n \"\"\"\n q = catalog.catalog()\n files = q.get_catalog_files()\n assert(len(files) == 1)\n\n def check_catalog_files2(self):\n \"\"\" Ignore bad paths in the path.\n \"\"\"\n q = catalog.catalog()\n os.environ['PYTHONCOMPILED'] = '_some_bad_path_'\n files = q.get_catalog_files()\n assert(len(files) == 1)\n \n def check_get_existing_files1(self):\n \"\"\" Shouldn't get any files when temp doesn't exist and no path set. \n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 0)\n def check_get_existing_files2(self):\n \"\"\" Shouldn't get a single file from the temp dir.\n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n # create a dummy file\n import os \n q.add_function('code', os.getpid)\n del q\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n print 'files:', files\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n \"\"\" There should always be a writable file -- even if it is in temp\n \"\"\"\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_with_bad_path(self):\n \"\"\" There should always be a writable file -- even if search paths contain\n bad values.\n \"\"\"\n if sys.platform == 'win32': sep = ';'\n else: sep = ':' \n os.environ['PYTHONCOMPILED'] = sep.join(('_bad_path_name_'))\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_dir(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n d = q.get_writable_dir()\n file = os.path.join(d,'some_silly_file')\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file)\n def check_unique_module_name(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n file = q.unique_module_name('bob')\n cfile1 = file+'.cpp'\n assert(not os.path.exists(cfile1))\n #make sure it is writable\n try:\n f = open(cfile1,'w')\n f.write('bob')\n finally: \n f.close()\n # try again with same code fragment -- should get unique name\n file = q.unique_module_name('bob')\n cfile2 = file+'.cpp'\n assert(not os.path.exists(cfile2+'.cpp'))\n os.remove(cfile1)\n def check_add_function_persistent1(self):\n \"\"\" Test persisting a function in the default catalog\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog()\n mod_name = q.unique_module_name('bob')\n d,f = os.path.split(mod_name)\n module_name, funcs = simple_module(d,f,'f')\n for i in funcs:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n os.remove(module_name)\n # any way to clean modules???\n restore_temp_catalog()\n for i in funcs:\n assert(i in pfuncs) \n \n def not_sure_about_this_check_add_function_persistent2(self):\n \"\"\" Test ordering of persistent functions\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog() \n \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name1, funcs1 = simple_module(d,f,'f')\n for i in funcs1:\n q.add_function_persistent('code',i)\n \n d = empty_temp_dir()\n q = catalog.catalog(d) \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name2, funcs2 = simple_module(d,f,'f')\n for i in funcs2:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n \n os.remove(module_name1)\n os.remove(module_name2)\n cleanup_temp_dir(d)\n restore_temp_catalog()\n # any way to clean modules???\n for i in funcs1:\n assert(i in pfuncs) \n for i in funcs2:\n assert(i in pfuncs)\n # make sure functions occur in correct order for\n # lookup \n all_funcs = zip(funcs1,funcs2)\n print all_funcs\n for a,b in all_funcs:\n assert(pfuncs.index(a) > pfuncs.index(b))\n \n assert(len(pfuncs) == 4)\n\n def check_add_function_ordered(self):\n clear_temp_catalog()\n q = catalog.catalog()\n import string\n \n q.add_function('f',string.upper) \n q.add_function('f',string.lower)\n q.add_function('ff',string.find) \n q.add_function('ff',string.replace)\n q.add_function('fff',string.atof)\n q.add_function('fff',string.atoi)\n del q\n\n # now we're gonna make a new catalog with same code\n # but different functions in a specified module directory\n env_dir = empty_temp_dir()\n r = catalog.catalog(env_dir)\n r.add_function('ff',os.abort)\n r.add_function('ff',os.chdir)\n r.add_function('fff',os.access)\n r.add_function('fff',os.open)\n del r\n # now we're gonna make a new catalog with same code\n # but different functions in a user specified directory\n user_dir = empty_temp_dir()\n s = catalog.catalog(user_dir)\n import re\n s.add_function('fff',re.match)\n s.add_function('fff',re.purge)\n del s\n\n # open new catalog and make sure it retreives the functions\n # from d catalog instead of the temp catalog (made by q)\n os.environ['PYTHONCOMPILED'] = env_dir\n t = catalog.catalog(user_dir)\n funcs1 = t.get_functions('f')\n funcs2 = t.get_functions('ff')\n funcs3 = t.get_functions('fff')\n restore_temp_catalog()\n # make sure everything is read back in the correct order\n assert(funcs1 == [string.lower,string.upper])\n assert(funcs2 == [os.chdir,os.abort,string.replace,string.find])\n assert(funcs3 == [re.purge,re.match,os.open,\n os.access,string.atoi,string.atof])\n cleanup_temp_dir(user_dir)\n cleanup_temp_dir(env_dir)\n \n \ndef test_suite():\n suites = []\n suites.append( unittest.makeSuite(test_default_dir,'check_'))\n suites.append( unittest.makeSuite(test_os_dependent_catalog_name,'check_'))\n suites.append( unittest.makeSuite(test_catalog_path,'check_'))\n suites.append( unittest.makeSuite(test_get_catalog,'check_'))\n suites.append( unittest.makeSuite(test_catalog,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test():\n all_tests = test_suite()\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\n\nif __name__ == '__main__':\n test()\n", "methods": [ { "name": "check_is_writable", "long_name": "check_is_writable( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 19, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 33, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_current", "long_name": "check_current( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 51, "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": "check_user", "long_name": "check_user( path )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 56, "parameters": [ "path" ], "start_line": 45, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_module", "long_name": "check_module( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 52, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_path", "long_name": "check_path( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 59, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_bad_path", "long_name": "check_bad_path( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 65, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_test_dir", "long_name": "get_test_dir( self , erase = 0 )", "filename": "test_catalog.py", "nloc": 19, "complexity": 8, "token_count": 161, "parameters": [ "self", "erase" ], "start_line": 77, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_nonexistent_catalog_is_none", "long_name": "check_nonexistent_catalog_is_none( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_create_catalog", "long_name": "check_create_catalog( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 101, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_environ", "long_name": "clear_environ( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 108, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "reset_environ", "long_name": "reset_environ( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self" ], "start_line": 114, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "setUp", "long_name": "setUp( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 118, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "tearDown", "long_name": "tearDown( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 120, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_set_module_directory", "long_name": "check_set_module_directory( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 123, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_clear_module_directory", "long_name": "check_clear_module_directory( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 128, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_environ_path", "long_name": "check_get_environ_path( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 65, "parameters": [ "self" ], "start_line": 135, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order1", "long_name": "check_build_search_order1( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 142, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order2", "long_name": "check_build_search_order2( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 149, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_build_search_order3", "long_name": "check_build_search_order3( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 155, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order4", "long_name": "check_build_search_order4( self )", "filename": "test_catalog.py", "nloc": 8, "complexity": 2, "token_count": 87, "parameters": [ "self" ], "start_line": 162, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_catalog_files1", "long_name": "check_catalog_files1( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 173, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_catalog_files2", "long_name": "check_catalog_files2( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 180, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_existing_files1", "long_name": "check_get_existing_files1( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 188, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_get_existing_files2", "long_name": "check_get_existing_files2( self )", "filename": "test_catalog.py", "nloc": 11, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 196, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_access_writable_file", "long_name": "check_access_writable_file( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 49, "parameters": [ "self" ], "start_line": 211, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_writable_with_bad_path", "long_name": "check_writable_with_bad_path( self )", "filename": "test_catalog.py", "nloc": 12, "complexity": 3, "token_count": 79, "parameters": [ "self" ], "start_line": 222, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_writable_dir", "long_name": "check_writable_dir( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "self" ], "start_line": 237, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_unique_module_name", "long_name": "check_unique_module_name( self )", "filename": "test_catalog.py", "nloc": 14, "complexity": 2, "token_count": 94, "parameters": [ "self" ], "start_line": 249, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_add_function_persistent1", "long_name": "check_add_function_persistent1( self )", "filename": "test_catalog.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self" ], "start_line": 267, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "not_sure_about_this_check_add_function_persistent2", "long_name": "not_sure_about_this_check_add_function_persistent2( self )", "filename": "test_catalog.py", "nloc": 29, "complexity": 6, "token_count": 210, "parameters": [ "self" ], "start_line": 284, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_add_function_ordered", "long_name": "check_add_function_ordered( self )", "filename": "test_catalog.py", "nloc": 36, "complexity": 1, "token_count": 288, "parameters": [ "self" ], "start_line": 323, "end_line": 368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "test_catalog.py", "nloc": 9, "complexity": 1, "token_count": 83, "parameters": [], "start_line": 371, "end_line": 380, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 382, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_is_writable", "long_name": "check_is_writable( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 51, "parameters": [ "self" ], "start_line": 21, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_current", "long_name": "check_current( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 49, "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": "check_user", "long_name": "check_user( path )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 56, "parameters": [ "path" ], "start_line": 47, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_module", "long_name": "check_module( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 54, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_path", "long_name": "check_path( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_bad_path", "long_name": "check_bad_path( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 67, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_test_dir", "long_name": "get_test_dir( self , erase = 0 )", "filename": "test_catalog.py", "nloc": 19, "complexity": 8, "token_count": 161, "parameters": [ "self", "erase" ], "start_line": 79, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_nonexistent_catalog_is_none", "long_name": "check_nonexistent_catalog_is_none( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 99, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_create_catalog", "long_name": "check_create_catalog( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 103, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_environ", "long_name": "clear_environ( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 110, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "reset_environ", "long_name": "reset_environ( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self" ], "start_line": 116, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "setUp", "long_name": "setUp( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 120, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "tearDown", "long_name": "tearDown( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 122, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_set_module_directory", "long_name": "check_set_module_directory( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_clear_module_directory", "long_name": "check_clear_module_directory( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 130, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_environ_path", "long_name": "check_get_environ_path( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 65, "parameters": [ "self" ], "start_line": 137, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order1", "long_name": "check_build_search_order1( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 144, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order2", "long_name": "check_build_search_order2( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 151, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_build_search_order3", "long_name": "check_build_search_order3( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 157, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order4", "long_name": "check_build_search_order4( self )", "filename": "test_catalog.py", "nloc": 8, "complexity": 2, "token_count": 85, "parameters": [ "self" ], "start_line": 164, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_catalog_files1", "long_name": "check_catalog_files1( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 175, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_catalog_files2", "long_name": "check_catalog_files2( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 182, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_existing_files1", "long_name": "check_get_existing_files1( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 190, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_get_existing_files2", "long_name": "check_get_existing_files2( self )", "filename": "test_catalog.py", "nloc": 11, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 198, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_access_writable_file", "long_name": "check_access_writable_file( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 49, "parameters": [ "self" ], "start_line": 213, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_writable_with_bad_path", "long_name": "check_writable_with_bad_path( self )", "filename": "test_catalog.py", "nloc": 12, "complexity": 3, "token_count": 79, "parameters": [ "self" ], "start_line": 224, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_writable_dir", "long_name": "check_writable_dir( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "self" ], "start_line": 239, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_unique_module_name", "long_name": "check_unique_module_name( self )", "filename": "test_catalog.py", "nloc": 14, "complexity": 2, "token_count": 94, "parameters": [ "self" ], "start_line": 251, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_add_function_persistent1", "long_name": "check_add_function_persistent1( self )", "filename": "test_catalog.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self" ], "start_line": 269, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "not_sure_about_this_check_add_function_persistent2", "long_name": "not_sure_about_this_check_add_function_persistent2( self )", "filename": "test_catalog.py", "nloc": 29, "complexity": 6, "token_count": 210, "parameters": [ "self" ], "start_line": 286, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_add_function_ordered", "long_name": "check_add_function_ordered( self )", "filename": "test_catalog.py", "nloc": 36, "complexity": 1, "token_count": 288, "parameters": [ "self" ], "start_line": 325, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "test_catalog.py", "nloc": 9, "complexity": 1, "token_count": 83, "parameters": [], "start_line": 373, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 384, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_build_search_order2", "long_name": "check_build_search_order2( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 149, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_current", "long_name": "check_current( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 51, "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": "check_build_search_order1", "long_name": "check_build_search_order1( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 142, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order3", "long_name": "check_build_search_order3( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 155, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_is_writable", "long_name": "check_is_writable( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 19, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_build_search_order4", "long_name": "check_build_search_order4( self )", "filename": "test_catalog.py", "nloc": 8, "complexity": 2, "token_count": 87, "parameters": [ "self" ], "start_line": 162, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 33, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "nloc": 311, "complexity": 59, "token_count": 2262, "diff_parsed": { "added": [ "reload(catalog) # this'll pick up any recent code changes", " path = catalog.default_dir()", " in_path = catalog.default_dir()", " assert(f == catalog.os_dependent_catalog_name())", " assert(f == catalog.os_dependent_catalog_name())", " assert(order == ['first','second','third',catalog.default_dir()])", " assert(order == ['first','third',catalog.default_dir()])", " assert(order == ['first','second',catalog.default_dir()])", " assert(order == ['first','second','third','fourth','fifth',catalog.default_dir()])" ], "deleted": [ "from catalog import *", "# not sure why, but was having problems with which catalog was being called.", "#catalog = catalog.catalog", " path = default_dir()", " in_path = default_dir()", " assert(f == os_dependent_catalog_name())", " assert(f == os_dependent_catalog_name())", " assert(order == ['first','second','third',default_dir()])", " assert(order == ['first','third',default_dir()])", " assert(order == ['first','second',default_dir()])", " assert(order == ['first','second','third','fourth','fifth',default_dir()])" ] } } ] }, { "hash": "3b5adc1dd411def34fd1515eb6cace3a98c02b57", "msg": "fixed problem with detecting existing catalogs found on Sun, but likely to occur in other places. I was simply filtering for a file names existence in a give folder, but because shelve (with anydbm) can use a variety of file suffixes, it wasn't finding existing files. Also, fixed the cleanup in weave_test_utils.py to delete the appropriate file+suffix on Sun. Likely will need to add some more to the list later.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-01-07T06:08:25+00:00", "author_timezone": 0, "committer_date": "2002-01-07T06:08:25+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "fb838538d73bb3cc154ab6ad47c96d1bb9f12f0d" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 5, "insertions": 21, "lines": 26, "files": 3, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.7142857142857143, "modified_files": [ { "old_path": "weave/catalog.py", "new_path": "weave/catalog.py", "filename": "catalog.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -320,7 +320,19 @@ def get_existing_files(self):\n \"\"\" Returns all existing catalog file list in correct search order.\n \"\"\"\n files = self.get_catalog_files()\n- existing_files = filter(os.path.exists,files)\n+ # open every stinking file to check if it exists.\n+ # This is because anydbm doesn't provide a consistent naming \n+ # convention across platforms for its files \n+ existing_files = []\n+ for file in files:\n+ try:\n+ x = shelve.open(file,'r')\n+ x.close()\n+ existing_files.append(file)\n+ except:\n+ pass\n+ # This is the non-portable (and much faster) old code\n+ #existing_files = filter(os.path.exists,files)\n return existing_files\n \n def get_writable_file(self,existing_only=0):\n@@ -522,6 +534,10 @@ def add_function(self,code,function,module_dir=None):\n if self.cache.has_key(code):\n if function not in self.cache[code]:\n self.cache[code].insert(0,function)\n+ else:\n+ # if it is in the cache, then it is also\n+ # been persisted \n+ return\n else: \n # Load functions and put this one up front\n self.cache[code] = self.get_functions(code) \n", "added_lines": 17, "deleted_lines": 1, "source_code": "\"\"\" Track relationships between compiled extension functions & code fragments\n\n catalog keeps track of which compiled(or even standard) functions are \n related to which code fragments. It also stores these relationships\n to disk so they are remembered between Python sessions. When \n \n a = 1\n compiler.inline('printf(\"printed from C: %d\",a);',['a'] )\n \n is called, inline() first looks to see if it has seen the code \n 'printf(\"printed from C\");' before. If not, it calls \n \n catalog.get_functions('printf(\"printed from C: %d\", a);')\n \n which returns a list of all the function objects that have been compiled\n for the code fragment. Multiple functions can occur because the code\n could be compiled for different types for 'a' (although not likely in\n this case). The catalog first looks in its cache and quickly returns\n a list of the functions if possible. If the cache lookup fails, it then\n looks through possibly multiple catalog files on disk and fills its\n cache with all the functions that match the code fragment. \n \n In case where the code fragment hasn't been compiled, inline() compiles\n the code and then adds it to the catalog:\n \n function = \n catalog.add_function('printf(\"printed from C: %d\", a);',function)\n \n add_function() adds function to the front of the cache. function,\n along with the path information to its module, are also stored in a\n persistent catalog for future use by python sessions. \n\"\"\" \n\nimport os,sys,string\nimport shelve\n\ndef getmodule(object):\n \"\"\" Discover the name of the module where object was defined.\n \n This is an augmented version of inspect.getmodule that can discover \n the parent module for extension functions.\n \"\"\"\n import inspect\n value = inspect.getmodule(object)\n if value is None:\n #walk trough all modules looking for function\n for name,mod in sys.modules.items():\n # try except used because of some comparison failures\n # in wxPoint code. Need to review this\n try:\n if mod and object in mod.__dict__.values():\n value = mod\n # if it is a built-in module, keep looking to see\n # if a non-builtin also has it. Otherwise quit and\n # consider the module found. (ain't perfect, but will \n # have to do for now).\n if string.find('(built-in)',str(mod)) is -1:\n break\n \n except TypeError:\n pass \n return value\n\ndef expr_to_filename(expr):\n \"\"\" Convert an arbitrary expr string to a valid file name.\n \n The name is based on the md5 check sum for the string and\n Something that was a little more human readable would be \n nice, but the computer doesn't seem to care.\n \"\"\"\n import md5\n base = 'sc_'\n return base + md5.new(expr).hexdigest()\n\ndef unique_file(d,expr):\n \"\"\" Generate a unqiue file name based on expr in directory d\n \n This is meant for use with building extension modules, so\n a file name is considered unique if none of the following\n extension '.cpp','.o','.so','module.so','.py', or '.pyd'\n exists in directory d. The fully qualified path to the\n new name is returned. You'll need to append your own\n extension to it before creating files.\n \"\"\"\n files = os.listdir(d)\n #base = 'scipy_compile'\n base = expr_to_filename(expr)\n for i in range(1000000):\n fname = base + `i`\n if not (fname+'.cpp' in files or\n fname+'.o' in files or\n fname+'.so' in files or\n fname+'module.so' in files or\n fname+'.py' in files or\n fname+'.pyd' in files):\n break\n return os.path.join(d,fname)\n \ndef default_dir():\n \"\"\" Return a default location to store compiled files and catalogs.\n \n XX is the Python version number in all paths listed below\n On windows, the default location is the temporary directory\n returned by gettempdir()/pythonXX.\n \n On Unix, ~/.pythonXX_compiled is the default location. If it doesn't\n exist, it is created. The directory is marked rwx------.\n \n If for some reason it isn't possible to build a default directory\n in the user's home, /tmp/_pythonXX_compiled is used. If it \n doesn't exist, it is created. The directory is marked rwx------\n to try and keep people from being able to sneak a bad module\n in on you. \n \"\"\"\n import tempfile \n python_name = \"python%d%d_compiled\" % tuple(sys.version_info[:2]) \n if sys.platform != 'win32':\n try:\n path = os.path.join(os.environ['HOME'],'.' + python_name)\n except KeyError:\n temp_dir = `os.getuid()` + '_' + python_name\n path = os.path.join(tempfile.gettempdir(),temp_dir) \n else:\n path = os.path.join(tempfile.gettempdir(),python_name)\n \n if not os.path.exists(path):\n os.mkdir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not os.access(path,os.W_OK):\n print 'warning: default directory is not write accessible.'\n print 'defualt:', path\n return path\n\ndef default_temp_dir():\n path = os.path.join(default_dir(),'temp')\n if not os.path.exists(path):\n os.mkdir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not os.access(path,os.W_OK):\n print 'warning: default directory is not write accessible.'\n print 'defualt:', path\n return path\n\n \ndef os_dependent_catalog_name():\n \"\"\" Generate catalog name dependent on OS and Python version being used.\n \n This allows multiple platforms to have catalog files in the\n same directory without stepping on each other. For now, it \n bases the name of the value returned by sys.platform and the\n version of python being run. If this isn't enough to descriminate\n on some platforms, we can try to add other info. It has \n occured to me that if we get fancy enough to optimize for different\n architectures, then chip type might be added to the catalog name also.\n \"\"\"\n version = '%d%d' % sys.version_info[:2]\n return sys.platform+version+'compiled_catalog'\n \ndef catalog_path(module_path):\n \"\"\" Return the full path name for the catalog file in the given directory.\n \n module_path can either be a file name or a path name. If it is a \n file name, the catalog file name in its parent directory is returned.\n If it is a directory, the catalog file in that directory is returned.\n\n If module_path doesn't exist, None is returned. Note though, that the\n catalog file does *not* have to exist, only its parent. '~', shell\n variables, and relative ('.' and '..') paths are all acceptable.\n \n catalog file names are os dependent (based on sys.platform), so this \n should support multiple platforms sharing the same disk space \n (NFS mounts). See os_dependent_catalog_name() for more info.\n \"\"\"\n module_path = os.path.expanduser(module_path)\n module_path = os.path.expandvars(module_path)\n module_path = os.path.abspath(module_path)\n if not os.path.exists(module_path):\n catalog_file = None\n elif not os.path.isdir(module_path):\n module_path,dummy = os.path.split(module_path)\n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n else: \n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n return catalog_file\n\ndef get_catalog(module_path,mode='r'):\n \"\"\" Return a function catalog (shelve object) from the path module_path\n\n If module_path is a directory, the function catalog returned is\n from that directory. If module_path is an actual module_name,\n then the function catalog returned is from its parent directory.\n mode uses the standard 'c' = create, 'n' = new, 'r' = read, \n 'w' = write file open modes available for anydbm databases.\n \n See catalog_path() for more information on module_path.\n \"\"\"\n if mode not in ['c','r','w','n']:\n msg = \" mode must be 'c', 'n', 'r', or 'w'. See anydbm for more info\"\n raise ValueError, msg\n catalog_file = catalog_path(module_path)\n #print catalog_file,mode\n try:\n sh = shelve.open(catalog_file,mode)\n except: # not sure how to pin down which error to catch yet\n sh = None\n return sh\n\nclass catalog:\n \"\"\" Stores information about compiled functions both in cache and on disk.\n \n catalog stores (code, list_of_function) pairs so that all the functions\n that have been compiled for code are available for calling (usually in\n inline or blitz).\n \n catalog keeps a dictionary of previously accessed code values cached \n for quick access. It also handles the looking up of functions compiled \n in previously called Python sessions on disk in function catalogs. \n catalog searches the directories in the PYTHONCOMPILED environment \n variable in order loading functions that correspond to the given code \n fragment. A default directory is also searched for catalog functions. \n On unix, the default directory is usually '~/.pythonxx_compiled' where \n xx is the version of Python used. On windows, it is the directory \n returned by temfile.gettempdir(). Functions closer to the front are of \n the variable list are guaranteed to be closer to the front of the \n function list so that they will be called first. See \n get_cataloged_functions() for more info on how the search order is \n traversed.\n \n Catalog also handles storing information about compiled functions to\n a catalog. When writing this information, the first writable catalog\n file in PYTHONCOMPILED path is used. If a writable catalog is not\n found, it is written to the catalog in the default directory. This\n directory should always be writable.\n \"\"\"\n def __init__(self,user_path_list=None):\n \"\"\" Create a catalog for storing/searching for compiled functions. \n \n user_path_list contains directories that should be searched \n first for function catalogs. They will come before the path\n entries in the PYTHONCOMPILED environment varilable.\n \"\"\"\n if type(user_path_list) == type('string'):\n self.user_path_list = [user_path_list]\n elif user_path_list:\n self.user_path_list = user_path_list\n else:\n self.user_path_list = []\n self.cache = {}\n self.module_dir = None\n self.paths_added = 0\n \n def set_module_directory(self,module_dir):\n \"\"\" Set the path that will replace 'MODULE' in catalog searches.\n \n You should call clear_module_directory() when your finished\n working with it.\n \"\"\"\n self.module_dir = module_dir\n def get_module_directory(self):\n \"\"\" Return the path used to replace the 'MODULE' in searches.\n \"\"\"\n return self.module_dir\n def clear_module_directory(self):\n \"\"\" Reset 'MODULE' path to None so that it is ignored in searches. \n \"\"\"\n self.module_dir = None\n \n def get_environ_path(self):\n \"\"\" Return list of paths from 'PYTHONCOMPILED' environment variable.\n \n On Unix the path in PYTHONCOMPILED is a ':' separated list of\n directories. On Windows, a ';' separated list is used. \n \"\"\"\n paths = []\n if os.environ.has_key('PYTHONCOMPILED'):\n path_string = os.environ['PYTHONCOMPILED'] \n if sys.platform == 'win32':\n #probably should also look in registry\n paths = path_string.split(';')\n else: \n paths = path_string.split(':')\n return paths \n\n def build_search_order(self):\n \"\"\" Returns a list of paths that are searched for catalogs. \n \n Values specified in the catalog constructor are searched first,\n then values found in the PYTHONCOMPILED environment variable.\n The directory returned by default_dir() is always returned at\n the end of the list.\n \n There is a 'magic' path name called 'MODULE' that is replaced\n by the directory defined by set_module_directory(). If the\n module directory hasn't been set, 'MODULE' is ignored.\n \"\"\"\n \n paths = self.user_path_list + self.get_environ_path()\n search_order = []\n for path in paths:\n if path == 'MODULE':\n if self.module_dir:\n search_order.append(self.module_dir)\n else:\n search_order.append(path)\n search_order.append(default_dir())\n return search_order\n\n def get_catalog_files(self):\n \"\"\" Returns catalog file list in correct search order.\n \n Some of the catalog files may not currently exists.\n However, all will be valid locations for a catalog\n to be created (if you have write permission).\n \"\"\"\n files = map(catalog_path,self.build_search_order())\n files = filter(lambda x: x is not None,files)\n return files\n\n def get_existing_files(self):\n \"\"\" Returns all existing catalog file list in correct search order.\n \"\"\"\n files = self.get_catalog_files()\n # open every stinking file to check if it exists.\n # This is because anydbm doesn't provide a consistent naming \n # convention across platforms for its files \n existing_files = []\n for file in files:\n try:\n x = shelve.open(file,'r')\n x.close()\n existing_files.append(file)\n except:\n pass\n # This is the non-portable (and much faster) old code\n #existing_files = filter(os.path.exists,files)\n return existing_files\n\n def get_writable_file(self,existing_only=0):\n \"\"\" Return the name of the first writable catalog file.\n \n Its parent directory must also be writable. This is so that\n compiled modules can be written to the same directory.\n \"\"\"\n # note: both file and its parent directory must be writeable\n if existing_only:\n files = self.get_existing_files()\n else:\n files = self.get_catalog_files()\n # filter for (file exists and is writable) OR directory is writable\n def file_test(x):\n from os import access, F_OK, W_OK\n return (access(x,F_OK) and access(x,W_OK) or\n access(os.path.dirname(x),W_OK))\n writable = filter(file_test,files)\n if writable:\n file = writable[0]\n else:\n file = None\n return file\n \n def get_writable_dir(self):\n \"\"\" Return the parent directory of first writable catalog file.\n \n The returned directory has write access.\n \"\"\"\n return os.path.dirname(self.get_writable_file())\n \n def unique_module_name(self,code,module_dir=None):\n \"\"\" Return full path to unique file name that in writable location.\n \n The directory for the file is the first writable directory in \n the catalog search path. The unique file name is derived from\n the code fragment. If, module_dir is specified, it is used\n to replace 'MODULE' in the search path.\n \"\"\"\n if module_dir is not None:\n self.set_module_directory(module_dir)\n try:\n d = self.get_writable_dir()\n finally:\n if module_dir is not None:\n self.clear_module_directory()\n return unique_file(d,code)\n\n def path_key(self,code):\n \"\"\" Return key for path information for functions associated with code.\n \"\"\"\n return '__path__' + code\n \n def configure_path(self,cat,code):\n \"\"\" Add the python path for the given code to the sys.path\n \n unconfigure_path() should be called as soon as possible after\n imports associated with code are finished so that sys.path \n is restored to normal.\n \"\"\"\n try:\n paths = cat[self.path_key(code)]\n self.paths_added = len(paths)\n sys.path = paths + sys.path\n except:\n self.paths_added = 0 \n \n def unconfigure_path(self):\n \"\"\" Restores sys.path to normal after calls to configure_path()\n \n Remove the previously added paths from sys.path\n \"\"\"\n sys.path = sys.path[self.paths_added:]\n self.paths_added = 0\n\n def get_cataloged_functions(self,code):\n \"\"\" Load all functions associated with code from catalog search path.\n \n Sometimes there can be trouble loading a function listed in a\n catalog file because the actual module that holds the function \n has been moved or deleted. When this happens, that catalog file\n is \"repaired\", meaning the entire entry for this function is \n removed from the file. This only affects the catalog file that\n has problems -- not the others in the search path.\n \n The \"repair\" behavior may not be needed, but I'll keep it for now.\n \"\"\"\n mode = 'r'\n cat = None\n function_list = []\n for path in self.build_search_order():\n cat = get_catalog(path,mode)\n if cat is not None and cat.has_key(code):\n # set up the python path so that modules for this\n # function can be loaded.\n self.configure_path(cat,code)\n try: \n function_list += cat[code]\n except: #SystemError and ImportError so far seen \n # problems loading a function from the catalog. Try to\n # repair the cause.\n cat.close()\n self.repair_catalog(path,code)\n self.unconfigure_path() \n return function_list\n\n\n def repair_catalog(self,catalog_path,code):\n \"\"\" Remove entry for code from catalog_path\n \n Occasionally catalog entries could get corrupted. An example\n would be when a module that had functions in the catalog was\n deleted or moved on the disk. The best current repair method is \n just to trash the entire catalog entry for this piece of code. \n This may loose function entries that are valid, but thats life.\n \n catalog_path must be writable for repair. If it isn't, the\n function exists with a warning. \n \"\"\"\n writable_cat = None\n if not os.path.exists(catalog_path):\n return\n try:\n writable_cat = get_catalog(catalog_path,'w')\n except:\n print 'warning: unable to repair catalog entry\\n %s\\n in\\n %s' % \\\n (code,catalog_path)\n return \n if writable_cat.has_key(code):\n print 'repairing catalog by removing key'\n del writable_cat[code]\n \n # it is possible that the path key doesn't exist (if the function registered\n # was a built-in function), so we have to check if the path exists before\n # arbitrarily deleting it.\n path_key = self.path_key(code) \n if writable_cat.has_key(path_key):\n del writable_cat[path_key] \n \n def get_functions_fast(self,code):\n \"\"\" Return list of functions for code from the cache.\n \n Return an empty list if the code entry is not found.\n \"\"\"\n return self.cache.get(code,[])\n \n def get_functions(self,code,module_dir=None):\n \"\"\" Return the list of functions associated with this code fragment.\n \n The cache is first searched for the function. If an entry\n in the cache is not found, then catalog files on disk are \n searched for the entry. This is slooooow, but only happens\n once per code object. All the functions found in catalog files\n on a cache miss are loaded into the cache to speed up future calls.\n The search order is as follows:\n \n 1. user specified path (from catalog initialization)\n 2. directories from the PYTHONCOMPILED environment variable\n 3. The temporary directory on your platform.\n\n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n # Fast!! try cache first.\n if self.cache.has_key(code):\n return self.cache[code]\n \n # 2. Slow!! read previously compiled functions from disk.\n try:\n self.set_module_directory(module_dir)\n function_list = self.get_cataloged_functions(code)\n if code:\n function_list\n # put function_list in cache to save future lookups.\n if function_list:\n self.cache[code] = function_list\n # return function_list, empty or otherwise.\n finally:\n self.clear_module_directory()\n return function_list\n\n def add_function(self,code,function,module_dir=None):\n \"\"\" Adds a function to the catalog.\n \n The function is added to the cache as well as the first\n writable file catalog found in the search path. If no\n code entry exists in the cache, the on disk catalogs\n are loaded into the cache and function is added to the\n beginning of the function list.\n \n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n\n # 1. put it in the cache.\n if self.cache.has_key(code):\n if function not in self.cache[code]:\n self.cache[code].insert(0,function)\n else:\n # if it is in the cache, then it is also\n # been persisted \n return\n else: \n # Load functions and put this one up front\n self.cache[code] = self.get_functions(code) \n self.fast_cache(code,function)\n \n # 2. Store the function entry to disk. \n try:\n self.set_module_directory(module_dir)\n self.add_function_persistent(code,function)\n finally:\n self.clear_module_directory()\n \n def add_function_persistent(self,code,function):\n \"\"\" Store the code->function relationship to disk.\n \n Two pieces of information are needed for loading functions\n from disk -- the function pickle (which conveniently stores\n the module name, etc.) and the path to its module's directory.\n The latter is needed so that the function can be loaded no\n matter what the user's Python path is.\n \"\"\" \n # add function to data in first writable catalog\n mode = 'c' # create if doesn't exist, otherwise, use existing\n cat_file = self.get_writable_dir()\n cat = get_catalog(cat_file,mode)\n if cat is None:\n cat_dir = default_dir()\n cat = get_catalog(cat_file,mode)\n if cat is None:\n cat_dir = default_dir() \n cat_file = catalog_path(cat_dir)\n print 'problems with default catalog -- removing'\n os.remove(cat_file)\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n raise ValueError, 'Failed to access a catalog for storing functions' \n function_list = [function] + cat.get(code,[])\n cat[code] = function_list\n \n # now add needed path information for loading function\n module = getmodule(function)\n try:\n # built in modules don't have the __file__ extension, so this\n # will fail. Just pass in this case since path additions aren't\n # needed for built-in modules.\n mod_path,f=os.path.split(os.path.abspath(module.__file__))\n pkey = self.path_key(code)\n cat[pkey] = [mod_path] + cat.get(pkey,[])\n except:\n pass\n\n def fast_cache(self,code,function):\n \"\"\" Move function to the front of the cache entry for code\n \n If future calls to the function have the same type signature,\n this will speed up access significantly because the first\n function call is correct.\n \n Note: The cache added to the inline_tools module is significantly\n faster than always calling get_functions, so this isn't\n as necessary as it used to be. Still, it's probably worth\n doing. \n \"\"\"\n try:\n if self.cache[code][0] == function:\n return\n except: # KeyError, IndexError \n pass\n try:\n self.cache[code].remove(function)\n except ValueError:\n pass\n # put new function at the beginning of the list to search.\n self.cache[code].insert(0,function)\n \ndef test():\n from scipy_test import module_test\n module_test(__name__,__file__)\n\ndef test_suite():\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__) \n", "source_code_before": "\"\"\" Track relationships between compiled extension functions & code fragments\n\n catalog keeps track of which compiled(or even standard) functions are \n related to which code fragments. It also stores these relationships\n to disk so they are remembered between Python sessions. When \n \n a = 1\n compiler.inline('printf(\"printed from C: %d\",a);',['a'] )\n \n is called, inline() first looks to see if it has seen the code \n 'printf(\"printed from C\");' before. If not, it calls \n \n catalog.get_functions('printf(\"printed from C: %d\", a);')\n \n which returns a list of all the function objects that have been compiled\n for the code fragment. Multiple functions can occur because the code\n could be compiled for different types for 'a' (although not likely in\n this case). The catalog first looks in its cache and quickly returns\n a list of the functions if possible. If the cache lookup fails, it then\n looks through possibly multiple catalog files on disk and fills its\n cache with all the functions that match the code fragment. \n \n In case where the code fragment hasn't been compiled, inline() compiles\n the code and then adds it to the catalog:\n \n function = \n catalog.add_function('printf(\"printed from C: %d\", a);',function)\n \n add_function() adds function to the front of the cache. function,\n along with the path information to its module, are also stored in a\n persistent catalog for future use by python sessions. \n\"\"\" \n\nimport os,sys,string\nimport shelve\n\ndef getmodule(object):\n \"\"\" Discover the name of the module where object was defined.\n \n This is an augmented version of inspect.getmodule that can discover \n the parent module for extension functions.\n \"\"\"\n import inspect\n value = inspect.getmodule(object)\n if value is None:\n #walk trough all modules looking for function\n for name,mod in sys.modules.items():\n # try except used because of some comparison failures\n # in wxPoint code. Need to review this\n try:\n if mod and object in mod.__dict__.values():\n value = mod\n # if it is a built-in module, keep looking to see\n # if a non-builtin also has it. Otherwise quit and\n # consider the module found. (ain't perfect, but will \n # have to do for now).\n if string.find('(built-in)',str(mod)) is -1:\n break\n \n except TypeError:\n pass \n return value\n\ndef expr_to_filename(expr):\n \"\"\" Convert an arbitrary expr string to a valid file name.\n \n The name is based on the md5 check sum for the string and\n Something that was a little more human readable would be \n nice, but the computer doesn't seem to care.\n \"\"\"\n import md5\n base = 'sc_'\n return base + md5.new(expr).hexdigest()\n\ndef unique_file(d,expr):\n \"\"\" Generate a unqiue file name based on expr in directory d\n \n This is meant for use with building extension modules, so\n a file name is considered unique if none of the following\n extension '.cpp','.o','.so','module.so','.py', or '.pyd'\n exists in directory d. The fully qualified path to the\n new name is returned. You'll need to append your own\n extension to it before creating files.\n \"\"\"\n files = os.listdir(d)\n #base = 'scipy_compile'\n base = expr_to_filename(expr)\n for i in range(1000000):\n fname = base + `i`\n if not (fname+'.cpp' in files or\n fname+'.o' in files or\n fname+'.so' in files or\n fname+'module.so' in files or\n fname+'.py' in files or\n fname+'.pyd' in files):\n break\n return os.path.join(d,fname)\n \ndef default_dir():\n \"\"\" Return a default location to store compiled files and catalogs.\n \n XX is the Python version number in all paths listed below\n On windows, the default location is the temporary directory\n returned by gettempdir()/pythonXX.\n \n On Unix, ~/.pythonXX_compiled is the default location. If it doesn't\n exist, it is created. The directory is marked rwx------.\n \n If for some reason it isn't possible to build a default directory\n in the user's home, /tmp/_pythonXX_compiled is used. If it \n doesn't exist, it is created. The directory is marked rwx------\n to try and keep people from being able to sneak a bad module\n in on you. \n \"\"\"\n import tempfile \n python_name = \"python%d%d_compiled\" % tuple(sys.version_info[:2]) \n if sys.platform != 'win32':\n try:\n path = os.path.join(os.environ['HOME'],'.' + python_name)\n except KeyError:\n temp_dir = `os.getuid()` + '_' + python_name\n path = os.path.join(tempfile.gettempdir(),temp_dir) \n else:\n path = os.path.join(tempfile.gettempdir(),python_name)\n \n if not os.path.exists(path):\n os.mkdir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not os.access(path,os.W_OK):\n print 'warning: default directory is not write accessible.'\n print 'defualt:', path\n return path\n\ndef default_temp_dir():\n path = os.path.join(default_dir(),'temp')\n if not os.path.exists(path):\n os.mkdir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not os.access(path,os.W_OK):\n print 'warning: default directory is not write accessible.'\n print 'defualt:', path\n return path\n\n \ndef os_dependent_catalog_name():\n \"\"\" Generate catalog name dependent on OS and Python version being used.\n \n This allows multiple platforms to have catalog files in the\n same directory without stepping on each other. For now, it \n bases the name of the value returned by sys.platform and the\n version of python being run. If this isn't enough to descriminate\n on some platforms, we can try to add other info. It has \n occured to me that if we get fancy enough to optimize for different\n architectures, then chip type might be added to the catalog name also.\n \"\"\"\n version = '%d%d' % sys.version_info[:2]\n return sys.platform+version+'compiled_catalog'\n \ndef catalog_path(module_path):\n \"\"\" Return the full path name for the catalog file in the given directory.\n \n module_path can either be a file name or a path name. If it is a \n file name, the catalog file name in its parent directory is returned.\n If it is a directory, the catalog file in that directory is returned.\n\n If module_path doesn't exist, None is returned. Note though, that the\n catalog file does *not* have to exist, only its parent. '~', shell\n variables, and relative ('.' and '..') paths are all acceptable.\n \n catalog file names are os dependent (based on sys.platform), so this \n should support multiple platforms sharing the same disk space \n (NFS mounts). See os_dependent_catalog_name() for more info.\n \"\"\"\n module_path = os.path.expanduser(module_path)\n module_path = os.path.expandvars(module_path)\n module_path = os.path.abspath(module_path)\n if not os.path.exists(module_path):\n catalog_file = None\n elif not os.path.isdir(module_path):\n module_path,dummy = os.path.split(module_path)\n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n else: \n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n return catalog_file\n\ndef get_catalog(module_path,mode='r'):\n \"\"\" Return a function catalog (shelve object) from the path module_path\n\n If module_path is a directory, the function catalog returned is\n from that directory. If module_path is an actual module_name,\n then the function catalog returned is from its parent directory.\n mode uses the standard 'c' = create, 'n' = new, 'r' = read, \n 'w' = write file open modes available for anydbm databases.\n \n See catalog_path() for more information on module_path.\n \"\"\"\n if mode not in ['c','r','w','n']:\n msg = \" mode must be 'c', 'n', 'r', or 'w'. See anydbm for more info\"\n raise ValueError, msg\n catalog_file = catalog_path(module_path)\n #print catalog_file,mode\n try:\n sh = shelve.open(catalog_file,mode)\n except: # not sure how to pin down which error to catch yet\n sh = None\n return sh\n\nclass catalog:\n \"\"\" Stores information about compiled functions both in cache and on disk.\n \n catalog stores (code, list_of_function) pairs so that all the functions\n that have been compiled for code are available for calling (usually in\n inline or blitz).\n \n catalog keeps a dictionary of previously accessed code values cached \n for quick access. It also handles the looking up of functions compiled \n in previously called Python sessions on disk in function catalogs. \n catalog searches the directories in the PYTHONCOMPILED environment \n variable in order loading functions that correspond to the given code \n fragment. A default directory is also searched for catalog functions. \n On unix, the default directory is usually '~/.pythonxx_compiled' where \n xx is the version of Python used. On windows, it is the directory \n returned by temfile.gettempdir(). Functions closer to the front are of \n the variable list are guaranteed to be closer to the front of the \n function list so that they will be called first. See \n get_cataloged_functions() for more info on how the search order is \n traversed.\n \n Catalog also handles storing information about compiled functions to\n a catalog. When writing this information, the first writable catalog\n file in PYTHONCOMPILED path is used. If a writable catalog is not\n found, it is written to the catalog in the default directory. This\n directory should always be writable.\n \"\"\"\n def __init__(self,user_path_list=None):\n \"\"\" Create a catalog for storing/searching for compiled functions. \n \n user_path_list contains directories that should be searched \n first for function catalogs. They will come before the path\n entries in the PYTHONCOMPILED environment varilable.\n \"\"\"\n if type(user_path_list) == type('string'):\n self.user_path_list = [user_path_list]\n elif user_path_list:\n self.user_path_list = user_path_list\n else:\n self.user_path_list = []\n self.cache = {}\n self.module_dir = None\n self.paths_added = 0\n \n def set_module_directory(self,module_dir):\n \"\"\" Set the path that will replace 'MODULE' in catalog searches.\n \n You should call clear_module_directory() when your finished\n working with it.\n \"\"\"\n self.module_dir = module_dir\n def get_module_directory(self):\n \"\"\" Return the path used to replace the 'MODULE' in searches.\n \"\"\"\n return self.module_dir\n def clear_module_directory(self):\n \"\"\" Reset 'MODULE' path to None so that it is ignored in searches. \n \"\"\"\n self.module_dir = None\n \n def get_environ_path(self):\n \"\"\" Return list of paths from 'PYTHONCOMPILED' environment variable.\n \n On Unix the path in PYTHONCOMPILED is a ':' separated list of\n directories. On Windows, a ';' separated list is used. \n \"\"\"\n paths = []\n if os.environ.has_key('PYTHONCOMPILED'):\n path_string = os.environ['PYTHONCOMPILED'] \n if sys.platform == 'win32':\n #probably should also look in registry\n paths = path_string.split(';')\n else: \n paths = path_string.split(':')\n return paths \n\n def build_search_order(self):\n \"\"\" Returns a list of paths that are searched for catalogs. \n \n Values specified in the catalog constructor are searched first,\n then values found in the PYTHONCOMPILED environment variable.\n The directory returned by default_dir() is always returned at\n the end of the list.\n \n There is a 'magic' path name called 'MODULE' that is replaced\n by the directory defined by set_module_directory(). If the\n module directory hasn't been set, 'MODULE' is ignored.\n \"\"\"\n \n paths = self.user_path_list + self.get_environ_path()\n search_order = []\n for path in paths:\n if path == 'MODULE':\n if self.module_dir:\n search_order.append(self.module_dir)\n else:\n search_order.append(path)\n search_order.append(default_dir())\n return search_order\n\n def get_catalog_files(self):\n \"\"\" Returns catalog file list in correct search order.\n \n Some of the catalog files may not currently exists.\n However, all will be valid locations for a catalog\n to be created (if you have write permission).\n \"\"\"\n files = map(catalog_path,self.build_search_order())\n files = filter(lambda x: x is not None,files)\n return files\n\n def get_existing_files(self):\n \"\"\" Returns all existing catalog file list in correct search order.\n \"\"\"\n files = self.get_catalog_files()\n existing_files = filter(os.path.exists,files)\n return existing_files\n\n def get_writable_file(self,existing_only=0):\n \"\"\" Return the name of the first writable catalog file.\n \n Its parent directory must also be writable. This is so that\n compiled modules can be written to the same directory.\n \"\"\"\n # note: both file and its parent directory must be writeable\n if existing_only:\n files = self.get_existing_files()\n else:\n files = self.get_catalog_files()\n # filter for (file exists and is writable) OR directory is writable\n def file_test(x):\n from os import access, F_OK, W_OK\n return (access(x,F_OK) and access(x,W_OK) or\n access(os.path.dirname(x),W_OK))\n writable = filter(file_test,files)\n if writable:\n file = writable[0]\n else:\n file = None\n return file\n \n def get_writable_dir(self):\n \"\"\" Return the parent directory of first writable catalog file.\n \n The returned directory has write access.\n \"\"\"\n return os.path.dirname(self.get_writable_file())\n \n def unique_module_name(self,code,module_dir=None):\n \"\"\" Return full path to unique file name that in writable location.\n \n The directory for the file is the first writable directory in \n the catalog search path. The unique file name is derived from\n the code fragment. If, module_dir is specified, it is used\n to replace 'MODULE' in the search path.\n \"\"\"\n if module_dir is not None:\n self.set_module_directory(module_dir)\n try:\n d = self.get_writable_dir()\n finally:\n if module_dir is not None:\n self.clear_module_directory()\n return unique_file(d,code)\n\n def path_key(self,code):\n \"\"\" Return key for path information for functions associated with code.\n \"\"\"\n return '__path__' + code\n \n def configure_path(self,cat,code):\n \"\"\" Add the python path for the given code to the sys.path\n \n unconfigure_path() should be called as soon as possible after\n imports associated with code are finished so that sys.path \n is restored to normal.\n \"\"\"\n try:\n paths = cat[self.path_key(code)]\n self.paths_added = len(paths)\n sys.path = paths + sys.path\n except:\n self.paths_added = 0 \n \n def unconfigure_path(self):\n \"\"\" Restores sys.path to normal after calls to configure_path()\n \n Remove the previously added paths from sys.path\n \"\"\"\n sys.path = sys.path[self.paths_added:]\n self.paths_added = 0\n\n def get_cataloged_functions(self,code):\n \"\"\" Load all functions associated with code from catalog search path.\n \n Sometimes there can be trouble loading a function listed in a\n catalog file because the actual module that holds the function \n has been moved or deleted. When this happens, that catalog file\n is \"repaired\", meaning the entire entry for this function is \n removed from the file. This only affects the catalog file that\n has problems -- not the others in the search path.\n \n The \"repair\" behavior may not be needed, but I'll keep it for now.\n \"\"\"\n mode = 'r'\n cat = None\n function_list = []\n for path in self.build_search_order():\n cat = get_catalog(path,mode)\n if cat is not None and cat.has_key(code):\n # set up the python path so that modules for this\n # function can be loaded.\n self.configure_path(cat,code)\n try: \n function_list += cat[code]\n except: #SystemError and ImportError so far seen \n # problems loading a function from the catalog. Try to\n # repair the cause.\n cat.close()\n self.repair_catalog(path,code)\n self.unconfigure_path() \n return function_list\n\n\n def repair_catalog(self,catalog_path,code):\n \"\"\" Remove entry for code from catalog_path\n \n Occasionally catalog entries could get corrupted. An example\n would be when a module that had functions in the catalog was\n deleted or moved on the disk. The best current repair method is \n just to trash the entire catalog entry for this piece of code. \n This may loose function entries that are valid, but thats life.\n \n catalog_path must be writable for repair. If it isn't, the\n function exists with a warning. \n \"\"\"\n writable_cat = None\n if not os.path.exists(catalog_path):\n return\n try:\n writable_cat = get_catalog(catalog_path,'w')\n except:\n print 'warning: unable to repair catalog entry\\n %s\\n in\\n %s' % \\\n (code,catalog_path)\n return \n if writable_cat.has_key(code):\n print 'repairing catalog by removing key'\n del writable_cat[code]\n \n # it is possible that the path key doesn't exist (if the function registered\n # was a built-in function), so we have to check if the path exists before\n # arbitrarily deleting it.\n path_key = self.path_key(code) \n if writable_cat.has_key(path_key):\n del writable_cat[path_key] \n \n def get_functions_fast(self,code):\n \"\"\" Return list of functions for code from the cache.\n \n Return an empty list if the code entry is not found.\n \"\"\"\n return self.cache.get(code,[])\n \n def get_functions(self,code,module_dir=None):\n \"\"\" Return the list of functions associated with this code fragment.\n \n The cache is first searched for the function. If an entry\n in the cache is not found, then catalog files on disk are \n searched for the entry. This is slooooow, but only happens\n once per code object. All the functions found in catalog files\n on a cache miss are loaded into the cache to speed up future calls.\n The search order is as follows:\n \n 1. user specified path (from catalog initialization)\n 2. directories from the PYTHONCOMPILED environment variable\n 3. The temporary directory on your platform.\n\n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n # Fast!! try cache first.\n if self.cache.has_key(code):\n return self.cache[code]\n \n # 2. Slow!! read previously compiled functions from disk.\n try:\n self.set_module_directory(module_dir)\n function_list = self.get_cataloged_functions(code)\n if code:\n function_list\n # put function_list in cache to save future lookups.\n if function_list:\n self.cache[code] = function_list\n # return function_list, empty or otherwise.\n finally:\n self.clear_module_directory()\n return function_list\n\n def add_function(self,code,function,module_dir=None):\n \"\"\" Adds a function to the catalog.\n \n The function is added to the cache as well as the first\n writable file catalog found in the search path. If no\n code entry exists in the cache, the on disk catalogs\n are loaded into the cache and function is added to the\n beginning of the function list.\n \n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n\n # 1. put it in the cache.\n if self.cache.has_key(code):\n if function not in self.cache[code]:\n self.cache[code].insert(0,function)\n else: \n # Load functions and put this one up front\n self.cache[code] = self.get_functions(code) \n self.fast_cache(code,function)\n \n # 2. Store the function entry to disk. \n try:\n self.set_module_directory(module_dir)\n self.add_function_persistent(code,function)\n finally:\n self.clear_module_directory()\n \n def add_function_persistent(self,code,function):\n \"\"\" Store the code->function relationship to disk.\n \n Two pieces of information are needed for loading functions\n from disk -- the function pickle (which conveniently stores\n the module name, etc.) and the path to its module's directory.\n The latter is needed so that the function can be loaded no\n matter what the user's Python path is.\n \"\"\" \n # add function to data in first writable catalog\n mode = 'c' # create if doesn't exist, otherwise, use existing\n cat_file = self.get_writable_dir()\n cat = get_catalog(cat_file,mode)\n if cat is None:\n cat_dir = default_dir()\n cat = get_catalog(cat_file,mode)\n if cat is None:\n cat_dir = default_dir() \n cat_file = catalog_path(cat_dir)\n print 'problems with default catalog -- removing'\n os.remove(cat_file)\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n raise ValueError, 'Failed to access a catalog for storing functions' \n function_list = [function] + cat.get(code,[])\n cat[code] = function_list\n \n # now add needed path information for loading function\n module = getmodule(function)\n try:\n # built in modules don't have the __file__ extension, so this\n # will fail. Just pass in this case since path additions aren't\n # needed for built-in modules.\n mod_path,f=os.path.split(os.path.abspath(module.__file__))\n pkey = self.path_key(code)\n cat[pkey] = [mod_path] + cat.get(pkey,[])\n except:\n pass\n\n def fast_cache(self,code,function):\n \"\"\" Move function to the front of the cache entry for code\n \n If future calls to the function have the same type signature,\n this will speed up access significantly because the first\n function call is correct.\n \n Note: The cache added to the inline_tools module is significantly\n faster than always calling get_functions, so this isn't\n as necessary as it used to be. Still, it's probably worth\n doing. \n \"\"\"\n try:\n if self.cache[code][0] == function:\n return\n except: # KeyError, IndexError \n pass\n try:\n self.cache[code].remove(function)\n except ValueError:\n pass\n # put new function at the beginning of the list to search.\n self.cache[code].insert(0,function)\n \ndef test():\n from scipy_test import module_test\n module_test(__name__,__file__)\n\ndef test_suite():\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__) \n", "methods": [ { "name": "getmodule", "long_name": "getmodule( object )", "filename": "catalog.py", "nloc": 13, "complexity": 7, "token_count": 75, "parameters": [ "object" ], "start_line": 37, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expr_to_filename", "long_name": "expr_to_filename( expr )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "expr" ], "start_line": 64, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "unique_file", "long_name": "unique_file( d , expr )", "filename": "catalog.py", "nloc": 13, "complexity": 8, "token_count": 89, "parameters": [ "d", "expr" ], "start_line": 75, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "default_dir", "long_name": "default_dir( )", "filename": "catalog.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [], "start_line": 99, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "default_temp_dir", "long_name": "default_temp_dir( )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 134, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "os_dependent_catalog_name", "long_name": "os_dependent_catalog_name( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 145, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "catalog_path", "long_name": "catalog_path( module_path )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "module_path" ], "start_line": 159, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "get_catalog", "long_name": "get_catalog( module_path , mode = 'r' )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 56, "parameters": [ "module_path", "mode" ], "start_line": 186, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , user_path_list = None )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 60, "parameters": [ "self", "user_path_list" ], "start_line": 235, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "set_module_directory", "long_name": "set_module_directory( self , module_dir )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "module_dir" ], "start_line": 252, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_module_directory", "long_name": "get_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 259, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_module_directory", "long_name": "clear_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 263, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_environ_path", "long_name": "get_environ_path( self )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 268, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "build_search_order", "long_name": "build_search_order( self )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 62, "parameters": [ "self" ], "start_line": 284, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_catalog_files", "long_name": "get_catalog_files( self )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 308, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_existing_files", "long_name": "get_existing_files( self )", "filename": "catalog.py", "nloc": 11, "complexity": 3, "token_count": 50, "parameters": [ "self" ], "start_line": 319, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_writable_file.file_test", "long_name": "get_writable_file.file_test( x )", "filename": "catalog.py", "nloc": 4, "complexity": 3, "token_count": 43, "parameters": [ "x" ], "start_line": 350, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "get_writable_file", "long_name": "get_writable_file( self , existing_only = 0 )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 55, "parameters": [ "self", "existing_only" ], "start_line": 338, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_writable_dir", "long_name": "get_writable_dir( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 361, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "unique_module_name", "long_name": "unique_module_name( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "self", "code", "module_dir" ], "start_line": 368, "end_line": 383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "path_key", "long_name": "path_key( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "code" ], "start_line": 385, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configure_path", "long_name": "configure_path( self , cat , code )", "filename": "catalog.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "cat", "code" ], "start_line": 390, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "unconfigure_path", "long_name": "unconfigure_path( self )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 404, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_cataloged_functions", "long_name": "get_cataloged_functions( self , code )", "filename": "catalog.py", "nloc": 15, "complexity": 5, "token_count": 86, "parameters": [ "self", "code" ], "start_line": 412, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "repair_catalog", "long_name": "repair_catalog( self , catalog_path , code )", "filename": "catalog.py", "nloc": 16, "complexity": 5, "token_count": 83, "parameters": [ "self", "catalog_path", "code" ], "start_line": 444, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_functions_fast", "long_name": "get_functions_fast( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "code" ], "start_line": 476, "end_line": 481, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_functions", "long_name": "get_functions( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 13, "complexity": 5, "token_count": 69, "parameters": [ "self", "code", "module_dir" ], "start_line": 483, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , code , function , module_dir = None )", "filename": "catalog.py", "nloc": 14, "complexity": 4, "token_count": 97, "parameters": [ "self", "code", "function", "module_dir" ], "start_line": 519, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "add_function_persistent", "long_name": "add_function_persistent( self , code , function )", "filename": "catalog.py", "nloc": 24, "complexity": 5, "token_count": 166, "parameters": [ "self", "code", "function" ], "start_line": 553, "end_line": 590, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "fast_cache", "long_name": "fast_cache( self , code , function )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 59, "parameters": [ "self", "code", "function" ], "start_line": 592, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 616, "end_line": 618, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 620, "end_line": 622, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "getmodule", "long_name": "getmodule( object )", "filename": "catalog.py", "nloc": 13, "complexity": 7, "token_count": 75, "parameters": [ "object" ], "start_line": 37, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expr_to_filename", "long_name": "expr_to_filename( expr )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "expr" ], "start_line": 64, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "unique_file", "long_name": "unique_file( d , expr )", "filename": "catalog.py", "nloc": 13, "complexity": 8, "token_count": 89, "parameters": [ "d", "expr" ], "start_line": 75, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "default_dir", "long_name": "default_dir( )", "filename": "catalog.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [], "start_line": 99, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "default_temp_dir", "long_name": "default_temp_dir( )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 134, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "os_dependent_catalog_name", "long_name": "os_dependent_catalog_name( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 145, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "catalog_path", "long_name": "catalog_path( module_path )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "module_path" ], "start_line": 159, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "get_catalog", "long_name": "get_catalog( module_path , mode = 'r' )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 56, "parameters": [ "module_path", "mode" ], "start_line": 186, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , user_path_list = None )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 60, "parameters": [ "self", "user_path_list" ], "start_line": 235, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "set_module_directory", "long_name": "set_module_directory( self , module_dir )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "module_dir" ], "start_line": 252, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_module_directory", "long_name": "get_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 259, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_module_directory", "long_name": "clear_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 263, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_environ_path", "long_name": "get_environ_path( self )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 268, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "build_search_order", "long_name": "build_search_order( self )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 62, "parameters": [ "self" ], "start_line": 284, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_catalog_files", "long_name": "get_catalog_files( self )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 308, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_existing_files", "long_name": "get_existing_files( self )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 319, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_writable_file.file_test", "long_name": "get_writable_file.file_test( x )", "filename": "catalog.py", "nloc": 4, "complexity": 3, "token_count": 43, "parameters": [ "x" ], "start_line": 338, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "get_writable_file", "long_name": "get_writable_file( self , existing_only = 0 )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 55, "parameters": [ "self", "existing_only" ], "start_line": 326, "end_line": 347, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_writable_dir", "long_name": "get_writable_dir( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 349, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "unique_module_name", "long_name": "unique_module_name( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "self", "code", "module_dir" ], "start_line": 356, "end_line": 371, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "path_key", "long_name": "path_key( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "code" ], "start_line": 373, "end_line": 376, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configure_path", "long_name": "configure_path( self , cat , code )", "filename": "catalog.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "cat", "code" ], "start_line": 378, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "unconfigure_path", "long_name": "unconfigure_path( self )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 392, "end_line": 398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_cataloged_functions", "long_name": "get_cataloged_functions( self , code )", "filename": "catalog.py", "nloc": 15, "complexity": 5, "token_count": 86, "parameters": [ "self", "code" ], "start_line": 400, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "repair_catalog", "long_name": "repair_catalog( self , catalog_path , code )", "filename": "catalog.py", "nloc": 16, "complexity": 5, "token_count": 83, "parameters": [ "self", "catalog_path", "code" ], "start_line": 432, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_functions_fast", "long_name": "get_functions_fast( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "code" ], "start_line": 464, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_functions", "long_name": "get_functions( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 13, "complexity": 5, "token_count": 69, "parameters": [ "self", "code", "module_dir" ], "start_line": 471, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , code , function , module_dir = None )", "filename": "catalog.py", "nloc": 12, "complexity": 4, "token_count": 94, "parameters": [ "self", "code", "function", "module_dir" ], "start_line": 507, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "add_function_persistent", "long_name": "add_function_persistent( self , code , function )", "filename": "catalog.py", "nloc": 24, "complexity": 5, "token_count": 166, "parameters": [ "self", "code", "function" ], "start_line": 537, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "fast_cache", "long_name": "fast_cache( self , code , function )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 59, "parameters": [ "self", "code", "function" ], "start_line": 576, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 600, "end_line": 602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 604, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_existing_files", "long_name": "get_existing_files( self )", "filename": "catalog.py", "nloc": 11, "complexity": 3, "token_count": 50, "parameters": [ "self" ], "start_line": 319, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , code , function , module_dir = None )", "filename": "catalog.py", "nloc": 14, "complexity": 4, "token_count": 97, "parameters": [ "self", "code", "function", "module_dir" ], "start_line": 519, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 } ], "nloc": 333, "complexity": 94, "token_count": 1782, "diff_parsed": { "added": [ " # open every stinking file to check if it exists.", " # This is because anydbm doesn't provide a consistent naming", " # convention across platforms for its files", " existing_files = []", " for file in files:", " try:", " x = shelve.open(file,'r')", " x.close()", " existing_files.append(file)", " except:", " pass", " # This is the non-portable (and much faster) old code", " #existing_files = filter(os.path.exists,files)", " else:", " # if it is in the cache, then it is also", " # been persisted", " return" ], "deleted": [ " existing_files = filter(os.path.exists,files)" ] } }, { "old_path": "weave/tests/test_catalog.py", "new_path": "weave/tests/test_catalog.py", "filename": "test_catalog.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -45,7 +45,7 @@ def check_current(self):\n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n- path = catalog_path(in_path)\n+ path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n assert(f == catalog.os_dependent_catalog_name())\n@@ -205,7 +205,6 @@ def check_get_existing_files2(self):\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n- print 'files:', files\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n@@ -314,7 +313,6 @@ def not_sure_about_this_check_add_function_persistent2(self):\n # make sure functions occur in correct order for\n # lookup \n all_funcs = zip(funcs1,funcs2)\n- print all_funcs\n for a,b in all_funcs:\n assert(pfuncs.index(a) > pfuncs.index(b))\n \n", "added_lines": 1, "deleted_lines": 3, "source_code": "import unittest\nimport sys, os\n\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport catalog\nreload(catalog) # this'll pick up any recent code changes\nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\n\nclass test_default_dir(unittest.TestCase):\n def check_is_writable(self):\n path = catalog.default_dir()\n name = os.path.join(path,'dummy_catalog')\n test_file = open(name,'w')\n try:\n test_file.write('making sure default location is writable\\n')\n finally:\n test_file.close()\n os.remove(name)\n\nclass test_os_dependent_catalog_name(unittest.TestCase): \n pass\n \nclass test_catalog_path(unittest.TestCase): \n def check_default(self):\n in_path = catalog.default_dir()\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n assert(f == catalog.os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n assert(f == catalog.os_dependent_catalog_name()) \n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n assert(f == catalog.os_dependent_catalog_name())\n def check_module(self):\n # hand it a module and see if it uses the parent directory\n # of the module.\n path = catalog.catalog_path(os.__file__)\n d,f = os.path.split(os.__file__)\n d2,f = os.path.split(path)\n assert (d2 == d)\n def check_path(self):\n # use os.__file__ to get a usable directory.\n in_path,f = os.path.split(os.__file__)\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert (d == in_path)\n def check_bad_path(self):\n # stupid_path_name\n in_path = 'stupid_path_name'\n path = catalog.catalog_path(in_path)\n assert (path is None)\n\nclass test_get_catalog(unittest.TestCase):\n \"\"\" This only tests whether new catalogs are created correctly.\n And whether non-existent return None correctly with read mode.\n Putting catalogs in the right place is all tested with\n catalog_dir tests.\n \"\"\"\n def get_test_dir(self,erase = 0):\n # make sure tempdir catalog doesn't exist\n import tempfile\n temp = tempfile.gettempdir()\n pardir = os.path.join(temp,'catalog_test'+tempfile.gettempprefix())\n if not os.path.exists(pardir):\n os.mkdir(pardir)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name()+'.dat')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name()+'.dir')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name())\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n return pardir\n def check_nonexistent_catalog_is_none(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir)\n assert(cat is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir,'c')\n assert(cat is not None)\n\nclass test_catalog(unittest.TestCase):\n\n def clear_environ(self):\n if os.environ.has_key('PYTHONCOMPILED'):\n self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED']\n del os.environ['PYTHONCOMPILED']\n else: \n self.old_PYTHONCOMPILED = None\n def reset_environ(self):\n if self.old_PYTHONCOMPILED:\n os.environ['PYTHONCOMPILED'] = self.old_PYTHONCOMPILED\n self.old_PYTHONCOMPILED = None\n def setUp(self):\n self.clear_environ() \n def tearDown(self):\n self.reset_environ()\n \n def check_set_module_directory(self):\n q = catalog.catalog()\n q.set_module_directory('bob')\n r = q.get_module_directory()\n assert (r == 'bob')\n def check_clear_module_directory(self):\n q = catalog.catalog()\n r = q.get_module_directory()\n assert (r == None)\n q.set_module_directory('bob')\n r = q.clear_module_directory()\n assert (r == None)\n def check_get_environ_path(self):\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('path1','path2','path3'))\n q = catalog.catalog()\n path = q.get_environ_path() \n assert(path == ['path1','path2','path3'])\n def check_build_search_order1(self): \n \"\"\" MODULE in search path should be replaced by module_dir.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n q.set_module_directory('second')\n order = q.build_search_order()\n assert(order == ['first','second','third',catalog.default_dir()])\n def check_build_search_order2(self): \n \"\"\" MODULE in search path should be removed if module_dir==None.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n order = q.build_search_order()\n assert(order == ['first','third',catalog.default_dir()]) \n def check_build_search_order3(self):\n \"\"\" If MODULE is absent, module_dir shouldn't be in search path.\n \"\"\" \n q = catalog.catalog(['first','second'])\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second',catalog.default_dir()])\n def check_build_search_order4(self):\n \"\"\" Make sure environment variable is getting used.\n \"\"\" \n q = catalog.catalog(['first','second'])\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second','third','fourth','fifth',catalog.default_dir()])\n \n def check_catalog_files1(self):\n \"\"\" Be sure we get at least one file even without specifying the path.\n \"\"\"\n q = catalog.catalog()\n files = q.get_catalog_files()\n assert(len(files) == 1)\n\n def check_catalog_files2(self):\n \"\"\" Ignore bad paths in the path.\n \"\"\"\n q = catalog.catalog()\n os.environ['PYTHONCOMPILED'] = '_some_bad_path_'\n files = q.get_catalog_files()\n assert(len(files) == 1)\n \n def check_get_existing_files1(self):\n \"\"\" Shouldn't get any files when temp doesn't exist and no path set. \n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 0)\n def check_get_existing_files2(self):\n \"\"\" Shouldn't get a single file from the temp dir.\n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n # create a dummy file\n import os \n q.add_function('code', os.getpid)\n del q\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n \"\"\" There should always be a writable file -- even if it is in temp\n \"\"\"\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_with_bad_path(self):\n \"\"\" There should always be a writable file -- even if search paths contain\n bad values.\n \"\"\"\n if sys.platform == 'win32': sep = ';'\n else: sep = ':' \n os.environ['PYTHONCOMPILED'] = sep.join(('_bad_path_name_'))\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_dir(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n d = q.get_writable_dir()\n file = os.path.join(d,'some_silly_file')\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file)\n def check_unique_module_name(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n file = q.unique_module_name('bob')\n cfile1 = file+'.cpp'\n assert(not os.path.exists(cfile1))\n #make sure it is writable\n try:\n f = open(cfile1,'w')\n f.write('bob')\n finally: \n f.close()\n # try again with same code fragment -- should get unique name\n file = q.unique_module_name('bob')\n cfile2 = file+'.cpp'\n assert(not os.path.exists(cfile2+'.cpp'))\n os.remove(cfile1)\n def check_add_function_persistent1(self):\n \"\"\" Test persisting a function in the default catalog\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog()\n mod_name = q.unique_module_name('bob')\n d,f = os.path.split(mod_name)\n module_name, funcs = simple_module(d,f,'f')\n for i in funcs:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n os.remove(module_name)\n # any way to clean modules???\n restore_temp_catalog()\n for i in funcs:\n assert(i in pfuncs) \n \n def not_sure_about_this_check_add_function_persistent2(self):\n \"\"\" Test ordering of persistent functions\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog() \n \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name1, funcs1 = simple_module(d,f,'f')\n for i in funcs1:\n q.add_function_persistent('code',i)\n \n d = empty_temp_dir()\n q = catalog.catalog(d) \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name2, funcs2 = simple_module(d,f,'f')\n for i in funcs2:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n \n os.remove(module_name1)\n os.remove(module_name2)\n cleanup_temp_dir(d)\n restore_temp_catalog()\n # any way to clean modules???\n for i in funcs1:\n assert(i in pfuncs) \n for i in funcs2:\n assert(i in pfuncs)\n # make sure functions occur in correct order for\n # lookup \n all_funcs = zip(funcs1,funcs2)\n for a,b in all_funcs:\n assert(pfuncs.index(a) > pfuncs.index(b))\n \n assert(len(pfuncs) == 4)\n\n def check_add_function_ordered(self):\n clear_temp_catalog()\n q = catalog.catalog()\n import string\n \n q.add_function('f',string.upper) \n q.add_function('f',string.lower)\n q.add_function('ff',string.find) \n q.add_function('ff',string.replace)\n q.add_function('fff',string.atof)\n q.add_function('fff',string.atoi)\n del q\n\n # now we're gonna make a new catalog with same code\n # but different functions in a specified module directory\n env_dir = empty_temp_dir()\n r = catalog.catalog(env_dir)\n r.add_function('ff',os.abort)\n r.add_function('ff',os.chdir)\n r.add_function('fff',os.access)\n r.add_function('fff',os.open)\n del r\n # now we're gonna make a new catalog with same code\n # but different functions in a user specified directory\n user_dir = empty_temp_dir()\n s = catalog.catalog(user_dir)\n import re\n s.add_function('fff',re.match)\n s.add_function('fff',re.purge)\n del s\n\n # open new catalog and make sure it retreives the functions\n # from d catalog instead of the temp catalog (made by q)\n os.environ['PYTHONCOMPILED'] = env_dir\n t = catalog.catalog(user_dir)\n funcs1 = t.get_functions('f')\n funcs2 = t.get_functions('ff')\n funcs3 = t.get_functions('fff')\n restore_temp_catalog()\n # make sure everything is read back in the correct order\n assert(funcs1 == [string.lower,string.upper])\n assert(funcs2 == [os.chdir,os.abort,string.replace,string.find])\n assert(funcs3 == [re.purge,re.match,os.open,\n os.access,string.atoi,string.atof])\n cleanup_temp_dir(user_dir)\n cleanup_temp_dir(env_dir)\n \n \ndef test_suite():\n suites = []\n suites.append( unittest.makeSuite(test_default_dir,'check_'))\n suites.append( unittest.makeSuite(test_os_dependent_catalog_name,'check_'))\n suites.append( unittest.makeSuite(test_catalog_path,'check_'))\n suites.append( unittest.makeSuite(test_get_catalog,'check_'))\n suites.append( unittest.makeSuite(test_catalog,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test():\n all_tests = test_suite()\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\n\nif __name__ == '__main__':\n test()\n", "source_code_before": "import unittest\nimport sys, os\n\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport catalog\nreload(catalog) # this'll pick up any recent code changes\nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\n\nclass test_default_dir(unittest.TestCase):\n def check_is_writable(self):\n path = catalog.default_dir()\n name = os.path.join(path,'dummy_catalog')\n test_file = open(name,'w')\n try:\n test_file.write('making sure default location is writable\\n')\n finally:\n test_file.close()\n os.remove(name)\n\nclass test_os_dependent_catalog_name(unittest.TestCase): \n pass\n \nclass test_catalog_path(unittest.TestCase): \n def check_default(self):\n in_path = catalog.default_dir()\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n assert(f == catalog.os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n assert(f == catalog.os_dependent_catalog_name()) \n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n path = catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n assert(f == catalog.os_dependent_catalog_name())\n def check_module(self):\n # hand it a module and see if it uses the parent directory\n # of the module.\n path = catalog.catalog_path(os.__file__)\n d,f = os.path.split(os.__file__)\n d2,f = os.path.split(path)\n assert (d2 == d)\n def check_path(self):\n # use os.__file__ to get a usable directory.\n in_path,f = os.path.split(os.__file__)\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert (d == in_path)\n def check_bad_path(self):\n # stupid_path_name\n in_path = 'stupid_path_name'\n path = catalog.catalog_path(in_path)\n assert (path is None)\n\nclass test_get_catalog(unittest.TestCase):\n \"\"\" This only tests whether new catalogs are created correctly.\n And whether non-existent return None correctly with read mode.\n Putting catalogs in the right place is all tested with\n catalog_dir tests.\n \"\"\"\n def get_test_dir(self,erase = 0):\n # make sure tempdir catalog doesn't exist\n import tempfile\n temp = tempfile.gettempdir()\n pardir = os.path.join(temp,'catalog_test'+tempfile.gettempprefix())\n if not os.path.exists(pardir):\n os.mkdir(pardir)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name()+'.dat')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name()+'.dir')\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n catalog_file = os.path.join(pardir,\n catalog.os_dependent_catalog_name())\n if os.path.exists(catalog_file) and erase:\n os.remove(catalog_file)\n return pardir\n def check_nonexistent_catalog_is_none(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir)\n assert(cat is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir,'c')\n assert(cat is not None)\n\nclass test_catalog(unittest.TestCase):\n\n def clear_environ(self):\n if os.environ.has_key('PYTHONCOMPILED'):\n self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED']\n del os.environ['PYTHONCOMPILED']\n else: \n self.old_PYTHONCOMPILED = None\n def reset_environ(self):\n if self.old_PYTHONCOMPILED:\n os.environ['PYTHONCOMPILED'] = self.old_PYTHONCOMPILED\n self.old_PYTHONCOMPILED = None\n def setUp(self):\n self.clear_environ() \n def tearDown(self):\n self.reset_environ()\n \n def check_set_module_directory(self):\n q = catalog.catalog()\n q.set_module_directory('bob')\n r = q.get_module_directory()\n assert (r == 'bob')\n def check_clear_module_directory(self):\n q = catalog.catalog()\n r = q.get_module_directory()\n assert (r == None)\n q.set_module_directory('bob')\n r = q.clear_module_directory()\n assert (r == None)\n def check_get_environ_path(self):\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('path1','path2','path3'))\n q = catalog.catalog()\n path = q.get_environ_path() \n assert(path == ['path1','path2','path3'])\n def check_build_search_order1(self): \n \"\"\" MODULE in search path should be replaced by module_dir.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n q.set_module_directory('second')\n order = q.build_search_order()\n assert(order == ['first','second','third',catalog.default_dir()])\n def check_build_search_order2(self): \n \"\"\" MODULE in search path should be removed if module_dir==None.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n order = q.build_search_order()\n assert(order == ['first','third',catalog.default_dir()]) \n def check_build_search_order3(self):\n \"\"\" If MODULE is absent, module_dir shouldn't be in search path.\n \"\"\" \n q = catalog.catalog(['first','second'])\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second',catalog.default_dir()])\n def check_build_search_order4(self):\n \"\"\" Make sure environment variable is getting used.\n \"\"\" \n q = catalog.catalog(['first','second'])\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second','third','fourth','fifth',catalog.default_dir()])\n \n def check_catalog_files1(self):\n \"\"\" Be sure we get at least one file even without specifying the path.\n \"\"\"\n q = catalog.catalog()\n files = q.get_catalog_files()\n assert(len(files) == 1)\n\n def check_catalog_files2(self):\n \"\"\" Ignore bad paths in the path.\n \"\"\"\n q = catalog.catalog()\n os.environ['PYTHONCOMPILED'] = '_some_bad_path_'\n files = q.get_catalog_files()\n assert(len(files) == 1)\n \n def check_get_existing_files1(self):\n \"\"\" Shouldn't get any files when temp doesn't exist and no path set. \n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 0)\n def check_get_existing_files2(self):\n \"\"\" Shouldn't get a single file from the temp dir.\n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n # create a dummy file\n import os \n q.add_function('code', os.getpid)\n del q\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n print 'files:', files\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n \"\"\" There should always be a writable file -- even if it is in temp\n \"\"\"\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_with_bad_path(self):\n \"\"\" There should always be a writable file -- even if search paths contain\n bad values.\n \"\"\"\n if sys.platform == 'win32': sep = ';'\n else: sep = ':' \n os.environ['PYTHONCOMPILED'] = sep.join(('_bad_path_name_'))\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_dir(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n d = q.get_writable_dir()\n file = os.path.join(d,'some_silly_file')\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file)\n def check_unique_module_name(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n file = q.unique_module_name('bob')\n cfile1 = file+'.cpp'\n assert(not os.path.exists(cfile1))\n #make sure it is writable\n try:\n f = open(cfile1,'w')\n f.write('bob')\n finally: \n f.close()\n # try again with same code fragment -- should get unique name\n file = q.unique_module_name('bob')\n cfile2 = file+'.cpp'\n assert(not os.path.exists(cfile2+'.cpp'))\n os.remove(cfile1)\n def check_add_function_persistent1(self):\n \"\"\" Test persisting a function in the default catalog\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog()\n mod_name = q.unique_module_name('bob')\n d,f = os.path.split(mod_name)\n module_name, funcs = simple_module(d,f,'f')\n for i in funcs:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n os.remove(module_name)\n # any way to clean modules???\n restore_temp_catalog()\n for i in funcs:\n assert(i in pfuncs) \n \n def not_sure_about_this_check_add_function_persistent2(self):\n \"\"\" Test ordering of persistent functions\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog() \n \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name1, funcs1 = simple_module(d,f,'f')\n for i in funcs1:\n q.add_function_persistent('code',i)\n \n d = empty_temp_dir()\n q = catalog.catalog(d) \n mod_name = q.unique_module_name('bob') \n d,f = os.path.split(mod_name)\n module_name2, funcs2 = simple_module(d,f,'f')\n for i in funcs2:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n \n os.remove(module_name1)\n os.remove(module_name2)\n cleanup_temp_dir(d)\n restore_temp_catalog()\n # any way to clean modules???\n for i in funcs1:\n assert(i in pfuncs) \n for i in funcs2:\n assert(i in pfuncs)\n # make sure functions occur in correct order for\n # lookup \n all_funcs = zip(funcs1,funcs2)\n print all_funcs\n for a,b in all_funcs:\n assert(pfuncs.index(a) > pfuncs.index(b))\n \n assert(len(pfuncs) == 4)\n\n def check_add_function_ordered(self):\n clear_temp_catalog()\n q = catalog.catalog()\n import string\n \n q.add_function('f',string.upper) \n q.add_function('f',string.lower)\n q.add_function('ff',string.find) \n q.add_function('ff',string.replace)\n q.add_function('fff',string.atof)\n q.add_function('fff',string.atoi)\n del q\n\n # now we're gonna make a new catalog with same code\n # but different functions in a specified module directory\n env_dir = empty_temp_dir()\n r = catalog.catalog(env_dir)\n r.add_function('ff',os.abort)\n r.add_function('ff',os.chdir)\n r.add_function('fff',os.access)\n r.add_function('fff',os.open)\n del r\n # now we're gonna make a new catalog with same code\n # but different functions in a user specified directory\n user_dir = empty_temp_dir()\n s = catalog.catalog(user_dir)\n import re\n s.add_function('fff',re.match)\n s.add_function('fff',re.purge)\n del s\n\n # open new catalog and make sure it retreives the functions\n # from d catalog instead of the temp catalog (made by q)\n os.environ['PYTHONCOMPILED'] = env_dir\n t = catalog.catalog(user_dir)\n funcs1 = t.get_functions('f')\n funcs2 = t.get_functions('ff')\n funcs3 = t.get_functions('fff')\n restore_temp_catalog()\n # make sure everything is read back in the correct order\n assert(funcs1 == [string.lower,string.upper])\n assert(funcs2 == [os.chdir,os.abort,string.replace,string.find])\n assert(funcs3 == [re.purge,re.match,os.open,\n os.access,string.atoi,string.atof])\n cleanup_temp_dir(user_dir)\n cleanup_temp_dir(env_dir)\n \n \ndef test_suite():\n suites = []\n suites.append( unittest.makeSuite(test_default_dir,'check_'))\n suites.append( unittest.makeSuite(test_os_dependent_catalog_name,'check_'))\n suites.append( unittest.makeSuite(test_catalog_path,'check_'))\n suites.append( unittest.makeSuite(test_get_catalog,'check_'))\n suites.append( unittest.makeSuite(test_catalog,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test():\n all_tests = test_suite()\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\n\nif __name__ == '__main__':\n test()\n", "methods": [ { "name": "check_is_writable", "long_name": "check_is_writable( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 19, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 33, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_current", "long_name": "check_current( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 51, "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": "check_user", "long_name": "check_user( path )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 58, "parameters": [ "path" ], "start_line": 45, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_module", "long_name": "check_module( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 52, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_path", "long_name": "check_path( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 59, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_bad_path", "long_name": "check_bad_path( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 65, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_test_dir", "long_name": "get_test_dir( self , erase = 0 )", "filename": "test_catalog.py", "nloc": 19, "complexity": 8, "token_count": 161, "parameters": [ "self", "erase" ], "start_line": 77, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_nonexistent_catalog_is_none", "long_name": "check_nonexistent_catalog_is_none( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_create_catalog", "long_name": "check_create_catalog( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 101, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_environ", "long_name": "clear_environ( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 108, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "reset_environ", "long_name": "reset_environ( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self" ], "start_line": 114, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "setUp", "long_name": "setUp( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 118, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "tearDown", "long_name": "tearDown( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 120, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_set_module_directory", "long_name": "check_set_module_directory( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 123, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_clear_module_directory", "long_name": "check_clear_module_directory( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 128, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_environ_path", "long_name": "check_get_environ_path( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 65, "parameters": [ "self" ], "start_line": 135, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order1", "long_name": "check_build_search_order1( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 142, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order2", "long_name": "check_build_search_order2( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 149, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_build_search_order3", "long_name": "check_build_search_order3( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 155, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order4", "long_name": "check_build_search_order4( self )", "filename": "test_catalog.py", "nloc": 8, "complexity": 2, "token_count": 87, "parameters": [ "self" ], "start_line": 162, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_catalog_files1", "long_name": "check_catalog_files1( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 173, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_catalog_files2", "long_name": "check_catalog_files2( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 180, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_existing_files1", "long_name": "check_get_existing_files1( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 188, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_get_existing_files2", "long_name": "check_get_existing_files2( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 196, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_access_writable_file", "long_name": "check_access_writable_file( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 49, "parameters": [ "self" ], "start_line": 210, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_writable_with_bad_path", "long_name": "check_writable_with_bad_path( self )", "filename": "test_catalog.py", "nloc": 12, "complexity": 3, "token_count": 79, "parameters": [ "self" ], "start_line": 221, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_writable_dir", "long_name": "check_writable_dir( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "self" ], "start_line": 236, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_unique_module_name", "long_name": "check_unique_module_name( self )", "filename": "test_catalog.py", "nloc": 14, "complexity": 2, "token_count": 94, "parameters": [ "self" ], "start_line": 248, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_add_function_persistent1", "long_name": "check_add_function_persistent1( self )", "filename": "test_catalog.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self" ], "start_line": 266, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "not_sure_about_this_check_add_function_persistent2", "long_name": "not_sure_about_this_check_add_function_persistent2( self )", "filename": "test_catalog.py", "nloc": 28, "complexity": 6, "token_count": 208, "parameters": [ "self" ], "start_line": 283, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 }, { "name": "check_add_function_ordered", "long_name": "check_add_function_ordered( self )", "filename": "test_catalog.py", "nloc": 36, "complexity": 1, "token_count": 288, "parameters": [ "self" ], "start_line": 321, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "test_catalog.py", "nloc": 9, "complexity": 1, "token_count": 83, "parameters": [], "start_line": 369, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 380, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_is_writable", "long_name": "check_is_writable( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 19, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 33, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_current", "long_name": "check_current( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 51, "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": "check_user", "long_name": "check_user( path )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 56, "parameters": [ "path" ], "start_line": 45, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_module", "long_name": "check_module( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 52, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_path", "long_name": "check_path( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 59, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_bad_path", "long_name": "check_bad_path( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 65, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_test_dir", "long_name": "get_test_dir( self , erase = 0 )", "filename": "test_catalog.py", "nloc": 19, "complexity": 8, "token_count": 161, "parameters": [ "self", "erase" ], "start_line": 77, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_nonexistent_catalog_is_none", "long_name": "check_nonexistent_catalog_is_none( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_create_catalog", "long_name": "check_create_catalog( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 101, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_environ", "long_name": "clear_environ( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 108, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "reset_environ", "long_name": "reset_environ( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self" ], "start_line": 114, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "setUp", "long_name": "setUp( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 118, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "tearDown", "long_name": "tearDown( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 120, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_set_module_directory", "long_name": "check_set_module_directory( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 123, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_clear_module_directory", "long_name": "check_clear_module_directory( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 128, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_environ_path", "long_name": "check_get_environ_path( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 65, "parameters": [ "self" ], "start_line": 135, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order1", "long_name": "check_build_search_order1( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 142, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order2", "long_name": "check_build_search_order2( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 149, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_build_search_order3", "long_name": "check_build_search_order3( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 155, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order4", "long_name": "check_build_search_order4( self )", "filename": "test_catalog.py", "nloc": 8, "complexity": 2, "token_count": 87, "parameters": [ "self" ], "start_line": 162, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_catalog_files1", "long_name": "check_catalog_files1( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 173, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_catalog_files2", "long_name": "check_catalog_files2( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 180, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_existing_files1", "long_name": "check_get_existing_files1( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 188, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_get_existing_files2", "long_name": "check_get_existing_files2( self )", "filename": "test_catalog.py", "nloc": 11, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 196, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_access_writable_file", "long_name": "check_access_writable_file( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 49, "parameters": [ "self" ], "start_line": 211, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_writable_with_bad_path", "long_name": "check_writable_with_bad_path( self )", "filename": "test_catalog.py", "nloc": 12, "complexity": 3, "token_count": 79, "parameters": [ "self" ], "start_line": 222, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_writable_dir", "long_name": "check_writable_dir( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "self" ], "start_line": 237, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_unique_module_name", "long_name": "check_unique_module_name( self )", "filename": "test_catalog.py", "nloc": 14, "complexity": 2, "token_count": 94, "parameters": [ "self" ], "start_line": 249, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_add_function_persistent1", "long_name": "check_add_function_persistent1( self )", "filename": "test_catalog.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self" ], "start_line": 267, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "not_sure_about_this_check_add_function_persistent2", "long_name": "not_sure_about_this_check_add_function_persistent2( self )", "filename": "test_catalog.py", "nloc": 29, "complexity": 6, "token_count": 210, "parameters": [ "self" ], "start_line": 284, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_add_function_ordered", "long_name": "check_add_function_ordered( self )", "filename": "test_catalog.py", "nloc": 36, "complexity": 1, "token_count": 288, "parameters": [ "self" ], "start_line": 323, "end_line": 368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( )", "filename": "test_catalog.py", "nloc": 9, "complexity": 1, "token_count": 83, "parameters": [], "start_line": 371, "end_line": 380, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 382, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_user", "long_name": "check_user( path )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 58, "parameters": [ "path" ], "start_line": 45, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "not_sure_about_this_check_add_function_persistent2", "long_name": "not_sure_about_this_check_add_function_persistent2( self )", "filename": "test_catalog.py", "nloc": 29, "complexity": 6, "token_count": 210, "parameters": [ "self" ], "start_line": 284, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_get_existing_files2", "long_name": "check_get_existing_files2( self )", "filename": "test_catalog.py", "nloc": 11, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 196, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 } ], "nloc": 309, "complexity": 59, "token_count": 2258, "diff_parsed": { "added": [ " path = catalog.catalog_path(in_path)" ], "deleted": [ " path = catalog_path(in_path)", " print 'files:', files", " print all_funcs" ] } }, { "old_path": "weave/tests/weave_test_utils.py", "new_path": "weave/tests/weave_test_utils.py", "filename": "weave_test_utils.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -33,9 +33,11 @@ def print_assert_equal(test_string,actual,desired):\n restore_path()\n \n def temp_catalog_files():\n+ # might need to add some more platform specific catalog file\n+ # suffixes to remove. The .pag was recently added for SunOS\n d = catalog.default_dir()\n f = catalog.os_dependent_catalog_name()\n- suffixes = ['.dat','.dir','']\n+ suffixes = ['.dat','.dir','.pag','']\n cat_files = [os.path.join(d,f+suffix) for suffix in suffixes]\n return cat_files\n \n", "added_lines": 3, "deleted_lines": 1, "source_code": "import os,sys,string\nimport pprint \n\ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test\n \"\"\"\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n###################################################\n# mainly used by catalog tests \n###################################################\nfrom scipy_distutils.misc_util import add_grandparent_to_path,restore_path\n\nadd_grandparent_to_path(__name__)\nimport catalog\nrestore_path()\n\ndef temp_catalog_files():\n # might need to add some more platform specific catalog file\n # suffixes to remove. The .pag was recently added for SunOS\n d = catalog.default_dir()\n f = catalog.os_dependent_catalog_name()\n suffixes = ['.dat','.dir','.pag','']\n cat_files = [os.path.join(d,f+suffix) for suffix in suffixes]\n return cat_files\n\ndef clear_temp_catalog():\n \"\"\" Remove any catalog from the temp dir\n \"\"\"\n cat_files = temp_catalog_files()\n for catalog_file in cat_files:\n if os.path.exists(catalog_file):\n if os.path.exists(catalog_file+'.bak'):\n os.remove(catalog_file+'.bak')\n os.rename(catalog_file,catalog_file+'.bak')\n\ndef restore_temp_catalog():\n \"\"\" Remove any catalog from the temp dir\n \"\"\"\n cat_files = temp_catalog_files()\n for catalog_file in cat_files:\n if os.path.exists(catalog_file+'.bak'):\n if os.path.exists(catalog_file): \n os.remove(catalog_file)\n os.rename(catalog_file+'.bak',catalog_file)\n\ndef empty_temp_dir():\n \"\"\" Create a sub directory in the temp directory for use in tests\n \"\"\"\n import tempfile\n d = catalog.default_dir()\n for i in range(10000):\n new_d = os.path.join(d,tempfile.gettempprefix()[1:-1]+`i`)\n if not os.path.exists(new_d):\n os.mkdir(new_d)\n break\n return new_d\n\ndef cleanup_temp_dir(d):\n \"\"\" Remove a directory created by empty_temp_dir\n should probably catch errors\n \"\"\"\n files = map(lambda x,d=d: os.path.join(d,x),os.listdir(d))\n for i in files:\n if os.path.isdir(i):\n cleanup_temp_dir(i)\n else:\n os.remove(i)\n os.rmdir(d)\n\ndef simple_module(directory,name,function_prefix,count=2):\n module_name = os.path.join(directory,name+'.py')\n func = \"def %(function_prefix)s%(fid)d():\\n pass\\n\"\n code = ''\n for fid in range(count):\n code+= func % locals()\n open(module_name,'w').write(code)\n sys.path.append(directory) \n exec \"import \" + name\n funcs = []\n for i in range(count):\n funcs.append(eval(name+'.'+function_prefix+`i`))\n sys.path = sys.path[:-1] \n return module_name, funcs \n", "source_code_before": "import os,sys,string\nimport pprint \n\ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test\n \"\"\"\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n###################################################\n# mainly used by catalog tests \n###################################################\nfrom scipy_distutils.misc_util import add_grandparent_to_path,restore_path\n\nadd_grandparent_to_path(__name__)\nimport catalog\nrestore_path()\n\ndef temp_catalog_files():\n d = catalog.default_dir()\n f = catalog.os_dependent_catalog_name()\n suffixes = ['.dat','.dir','']\n cat_files = [os.path.join(d,f+suffix) for suffix in suffixes]\n return cat_files\n\ndef clear_temp_catalog():\n \"\"\" Remove any catalog from the temp dir\n \"\"\"\n cat_files = temp_catalog_files()\n for catalog_file in cat_files:\n if os.path.exists(catalog_file):\n if os.path.exists(catalog_file+'.bak'):\n os.remove(catalog_file+'.bak')\n os.rename(catalog_file,catalog_file+'.bak')\n\ndef restore_temp_catalog():\n \"\"\" Remove any catalog from the temp dir\n \"\"\"\n cat_files = temp_catalog_files()\n for catalog_file in cat_files:\n if os.path.exists(catalog_file+'.bak'):\n if os.path.exists(catalog_file): \n os.remove(catalog_file)\n os.rename(catalog_file+'.bak',catalog_file)\n\ndef empty_temp_dir():\n \"\"\" Create a sub directory in the temp directory for use in tests\n \"\"\"\n import tempfile\n d = catalog.default_dir()\n for i in range(10000):\n new_d = os.path.join(d,tempfile.gettempprefix()[1:-1]+`i`)\n if not os.path.exists(new_d):\n os.mkdir(new_d)\n break\n return new_d\n\ndef cleanup_temp_dir(d):\n \"\"\" Remove a directory created by empty_temp_dir\n should probably catch errors\n \"\"\"\n files = map(lambda x,d=d: os.path.join(d,x),os.listdir(d))\n for i in files:\n if os.path.isdir(i):\n cleanup_temp_dir(i)\n else:\n os.remove(i)\n os.rmdir(d)\n\ndef simple_module(directory,name,function_prefix,count=2):\n module_name = os.path.join(directory,name+'.py')\n func = \"def %(function_prefix)s%(fid)d():\\n pass\\n\"\n code = ''\n for fid in range(count):\n code+= func % locals()\n open(module_name,'w').write(code)\n sys.path.append(directory) \n exec \"import \" + name\n funcs = []\n for i in range(count):\n funcs.append(eval(name+'.'+function_prefix+`i`))\n sys.path = sys.path[:-1] \n return module_name, funcs \n", "methods": [ { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "weave_test_utils.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 4, "end_line": 9, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "weave_test_utils.py", "nloc": 12, "complexity": 2, "token_count": 72, "parameters": [ "test_string", "actual", "desired" ], "start_line": 11, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "temp_catalog_files", "long_name": "temp_catalog_files( )", "filename": "weave_test_utils.py", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [], "start_line": 35, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "clear_temp_catalog", "long_name": "clear_temp_catalog( )", "filename": "weave_test_utils.py", "nloc": 7, "complexity": 4, "token_count": 55, "parameters": [], "start_line": 44, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "restore_temp_catalog", "long_name": "restore_temp_catalog( )", "filename": "weave_test_utils.py", "nloc": 7, "complexity": 4, "token_count": 53, "parameters": [], "start_line": 54, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "empty_temp_dir", "long_name": "empty_temp_dir( )", "filename": "weave_test_utils.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [], "start_line": 64, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "cleanup_temp_dir", "long_name": "cleanup_temp_dir( d )", "filename": "weave_test_utils.py", "nloc": 8, "complexity": 3, "token_count": 68, "parameters": [ "d" ], "start_line": 76, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "simple_module", "long_name": "simple_module( directory , name , function_prefix , count = 2 )", "filename": "weave_test_utils.py", "nloc": 14, "complexity": 3, "token_count": 116, "parameters": [ "directory", "name", "function_prefix", "count" ], "start_line": 88, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 } ], "methods_before": [ { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "weave_test_utils.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 4, "end_line": 9, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "weave_test_utils.py", "nloc": 12, "complexity": 2, "token_count": 72, "parameters": [ "test_string", "actual", "desired" ], "start_line": 11, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "temp_catalog_files", "long_name": "temp_catalog_files( )", "filename": "weave_test_utils.py", "nloc": 6, "complexity": 2, "token_count": 49, "parameters": [], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "clear_temp_catalog", "long_name": "clear_temp_catalog( )", "filename": "weave_test_utils.py", "nloc": 7, "complexity": 4, "token_count": 55, "parameters": [], "start_line": 42, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "restore_temp_catalog", "long_name": "restore_temp_catalog( )", "filename": "weave_test_utils.py", "nloc": 7, "complexity": 4, "token_count": 53, "parameters": [], "start_line": 52, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "empty_temp_dir", "long_name": "empty_temp_dir( )", "filename": "weave_test_utils.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [], "start_line": 62, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "cleanup_temp_dir", "long_name": "cleanup_temp_dir( d )", "filename": "weave_test_utils.py", "nloc": 8, "complexity": 3, "token_count": 68, "parameters": [ "d" ], "start_line": 74, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "simple_module", "long_name": "simple_module( directory , name , function_prefix , count = 2 )", "filename": "weave_test_utils.py", "nloc": 14, "complexity": 3, "token_count": 116, "parameters": [ "directory", "name", "function_prefix", "count" ], "start_line": 86, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "temp_catalog_files", "long_name": "temp_catalog_files( )", "filename": "weave_test_utils.py", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [], "start_line": 35, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "nloc": 75, "complexity": 22, "token_count": 561, "diff_parsed": { "added": [ " # might need to add some more platform specific catalog file", " # suffixes to remove. The .pag was recently added for SunOS", " suffixes = ['.dat','.dir','.pag','']" ], "deleted": [ " suffixes = ['.dat','.dir','']" ] } } ] }, { "hash": "bf4bf3b9774c2efcf749dbc1664472e8e46d6e31", "msg": "added line_endings.py. Working toward support of conversion of line ending characters for tar.gz files", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-01-07T07:04:56+00:00", "author_timezone": 0, "committer_date": "2002-01-07T07:04:56+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "3b5adc1dd411def34fd1515eb6cace3a98c02b57" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 1, "insertions": 72, "lines": 73, "files": 3, "dmm_unit_size": 0.5277777777777778, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.8888888888888888, "modified_files": [ { "old_path": "scipy_distutils/command/sdist.py", "new_path": "scipy_distutils/command/sdist.py", "filename": "sdist.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -68,6 +68,41 @@ def make_release_tree (self, base_dir, files):\n #raise ValueError\n # make_release_tree ()\n \n+ def make_distribution (self):\n+ \"\"\" Overridden to force a build of zip files to have Windows line \n+ endings and tar balls to have Unix line endings.\n+ \n+ Create the source distribution(s). First, we create the release\n+ tree with 'make_release_tree()'; then, we create all required\n+ archive files (according to 'self.formats') from the release tree.\n+ Finally, we clean up by blowing away the release tree (unless\n+ 'self.keep_temp' is true). The list of archive files created is\n+ stored so it can be retrieved later by 'get_archive_files()'.\n+ \"\"\"\n+ # Don't warn about missing meta-data here -- should be (and is!)\n+ # done elsewhere.\n+ base_dir = self.distribution.get_fullname()\n+ base_name = os.path.join(self.dist_dir, base_dir)\n+\n+ self.make_release_tree(base_dir, self.filelist.files)\n+ archive_files = [] # remember names of files we create\n+ for fmt in self.formats: \n+ self.convert_line_endings(base_dir,fmt)\n+ file = self.make_archive(base_name, fmt, base_dir=base_dir)\n+ archive_files.append(file)\n+ \n+ self.archive_files = archive_files\n+\n+ if not self.keep_temp:\n+ dir_util.remove_tree(base_dir, self.verbose, self.dry_run)\n+\n+ def convert_line_endings(base_dir,fmt):\n+ \"\"\" Convert all text files in a tree to have correct line endings.\n+ \n+ gztar --> \\n (Unix style)\n+ zip --> \\r\\n (Windows style)\n+ \"\"\"\n+ \n def remove_common_base(files):\n \"\"\" Remove the greatest common base directory from all the\n absolute file paths in the list of files. files in the\n", "added_lines": 35, "deleted_lines": 0, "source_code": "from distutils.command.sdist import *\nfrom distutils.command.sdist import sdist as old_sdist\n\nclass sdist(old_sdist):\n def add_defaults (self):\n old_sdist.add_defaults(self)\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.filelist.extend(build_flib.get_source_files())\n\n if self.distribution.has_data_files():\n self.filelist.extend(self.distribution.get_data_files())\n\n def make_release_tree (self, base_dir, files):\n \"\"\"Create the directory tree that will become the source\n distribution archive. All directories implied by the filenames in\n 'files' are created under 'base_dir', and then we hard link or copy\n (if hard linking is unavailable) those files into place.\n Essentially, this duplicates the developer's source tree, but in a\n directory named after the distribution, containing only the files\n to be distributed.\n \"\"\"\n # Create all the directories under 'base_dir' necessary to\n # put 'files' there; the 'mkpath()' is just so we don't die\n # if the manifest happens to be empty.\n dest_files = remove_common_base(files)\n self.mkpath(base_dir)\n dir_util.create_tree(base_dir, dest_files,\n verbose=self.verbose, dry_run=self.dry_run)\n\n # And walk over the list of files, either making a hard link (if\n # os.link exists) to each one that doesn't already exist in its\n # corresponding location under 'base_dir', or copying each file\n # that's out-of-date in 'base_dir'. (Usually, all files will be\n # out-of-date, because by default we blow away 'base_dir' when\n # we're done making the distribution archives.)\n \n if hasattr(os, 'link'): # can make hard links on this system\n link = 'hard'\n msg = \"making hard links in %s...\" % base_dir\n else: # nope, have to copy\n link = None\n msg = \"copying files to %s...\" % base_dir\n\n if not files:\n self.warn(\"no files to distribute -- empty manifest?\")\n else:\n self.announce(msg)\n \n dest_files = [os.path.join(base_dir,file) for file in dest_files]\n file_pairs = zip(files,dest_files) \n for file,dest in file_pairs:\n if not os.path.isfile(file):\n self.warn(\"'%s' not a regular file -- skipping\" % file)\n else:\n #ej: here is the only change -- made to handle\n # absolute paths to files as well as relative\n #par,file_name = os.path.split(file)\n #dest = os.path.join(base_dir, file_name)\n # end of changes\n \n # old code\n #dest = os.path.join(base_dir, file)\n #end old code\n self.copy_file(file, dest, link=link)\n\n self.distribution.metadata.write_pkg_info(base_dir)\n #raise ValueError\n # make_release_tree ()\n\n def make_distribution (self):\n \"\"\" Overridden to force a build of zip files to have Windows line \n endings and tar balls to have Unix line endings.\n \n Create the source distribution(s). First, we create the release\n tree with 'make_release_tree()'; then, we create all required\n archive files (according to 'self.formats') from the release tree.\n Finally, we clean up by blowing away the release tree (unless\n 'self.keep_temp' is true). The list of archive files created is\n stored so it can be retrieved later by 'get_archive_files()'.\n \"\"\"\n # Don't warn about missing meta-data here -- should be (and is!)\n # done elsewhere.\n base_dir = self.distribution.get_fullname()\n base_name = os.path.join(self.dist_dir, base_dir)\n\n self.make_release_tree(base_dir, self.filelist.files)\n archive_files = [] # remember names of files we create\n for fmt in self.formats: \n self.convert_line_endings(base_dir,fmt)\n file = self.make_archive(base_name, fmt, base_dir=base_dir)\n archive_files.append(file)\n \n self.archive_files = archive_files\n\n if not self.keep_temp:\n dir_util.remove_tree(base_dir, self.verbose, self.dry_run)\n\n def convert_line_endings(base_dir,fmt):\n \"\"\" Convert all text files in a tree to have correct line endings.\n \n gztar --> \\n (Unix style)\n zip --> \\r\\n (Windows style)\n \"\"\"\n \ndef remove_common_base(files):\n \"\"\" Remove the greatest common base directory from all the\n absolute file paths in the list of files. files in the\n list without a parent directory are not affected.\n \"\"\"\n rel_files = filter(lambda x: not os.path.dirname(x),files)\n abs_files = filter(os.path.dirname,files)\n base = find_common_base(abs_files)\n # will leave files with local path unaffected\n # and maintains original file order\n results = [string.replace(file,base,'') for file in files]\n return results\n\ndef find_common_base(files):\n \"\"\" Find the \"greatest common base directory\" of a list of files\n \"\"\"\n if not files:\n return files\n result = ''\n d,f = os.path.split(files[0])\n keep_looking = 1 \n while(keep_looking and d):\n keep_looking = 0\n for file in files:\n if string.find('start'+file,'start'+d) == -1:\n keep_looking = 1\n break\n if keep_looking:\n d,f = os.path.split(d)\n else:\n result = d\n \n if d: \n d = os.path.join(d,'')\n return d ", "source_code_before": "from distutils.command.sdist import *\nfrom distutils.command.sdist import sdist as old_sdist\n\nclass sdist(old_sdist):\n def add_defaults (self):\n old_sdist.add_defaults(self)\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.filelist.extend(build_flib.get_source_files())\n\n if self.distribution.has_data_files():\n self.filelist.extend(self.distribution.get_data_files())\n\n def make_release_tree (self, base_dir, files):\n \"\"\"Create the directory tree that will become the source\n distribution archive. All directories implied by the filenames in\n 'files' are created under 'base_dir', and then we hard link or copy\n (if hard linking is unavailable) those files into place.\n Essentially, this duplicates the developer's source tree, but in a\n directory named after the distribution, containing only the files\n to be distributed.\n \"\"\"\n # Create all the directories under 'base_dir' necessary to\n # put 'files' there; the 'mkpath()' is just so we don't die\n # if the manifest happens to be empty.\n dest_files = remove_common_base(files)\n self.mkpath(base_dir)\n dir_util.create_tree(base_dir, dest_files,\n verbose=self.verbose, dry_run=self.dry_run)\n\n # And walk over the list of files, either making a hard link (if\n # os.link exists) to each one that doesn't already exist in its\n # corresponding location under 'base_dir', or copying each file\n # that's out-of-date in 'base_dir'. (Usually, all files will be\n # out-of-date, because by default we blow away 'base_dir' when\n # we're done making the distribution archives.)\n \n if hasattr(os, 'link'): # can make hard links on this system\n link = 'hard'\n msg = \"making hard links in %s...\" % base_dir\n else: # nope, have to copy\n link = None\n msg = \"copying files to %s...\" % base_dir\n\n if not files:\n self.warn(\"no files to distribute -- empty manifest?\")\n else:\n self.announce(msg)\n \n dest_files = [os.path.join(base_dir,file) for file in dest_files]\n file_pairs = zip(files,dest_files) \n for file,dest in file_pairs:\n if not os.path.isfile(file):\n self.warn(\"'%s' not a regular file -- skipping\" % file)\n else:\n #ej: here is the only change -- made to handle\n # absolute paths to files as well as relative\n #par,file_name = os.path.split(file)\n #dest = os.path.join(base_dir, file_name)\n # end of changes\n \n # old code\n #dest = os.path.join(base_dir, file)\n #end old code\n self.copy_file(file, dest, link=link)\n\n self.distribution.metadata.write_pkg_info(base_dir)\n #raise ValueError\n # make_release_tree ()\n\ndef remove_common_base(files):\n \"\"\" Remove the greatest common base directory from all the\n absolute file paths in the list of files. files in the\n list without a parent directory are not affected.\n \"\"\"\n rel_files = filter(lambda x: not os.path.dirname(x),files)\n abs_files = filter(os.path.dirname,files)\n base = find_common_base(abs_files)\n # will leave files with local path unaffected\n # and maintains original file order\n results = [string.replace(file,base,'') for file in files]\n return results\n\ndef find_common_base(files):\n \"\"\" Find the \"greatest common base directory\" of a list of files\n \"\"\"\n if not files:\n return files\n result = ''\n d,f = os.path.split(files[0])\n keep_looking = 1 \n while(keep_looking and d):\n keep_looking = 0\n for file in files:\n if string.find('start'+file,'start'+d) == -1:\n keep_looking = 1\n break\n if keep_looking:\n d,f = os.path.split(d)\n else:\n result = d\n \n if d: \n d = os.path.join(d,'')\n return d ", "methods": [ { "name": "add_defaults", "long_name": "add_defaults( self )", "filename": "sdist.py", "nloc": 7, "complexity": 3, "token_count": 63, "parameters": [ "self" ], "start_line": 5, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "make_release_tree", "long_name": "make_release_tree( self , base_dir , files )", "filename": "sdist.py", "nloc": 23, "complexity": 6, "token_count": 162, "parameters": [ "self", "base_dir", "files" ], "start_line": 14, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "make_distribution", "long_name": "make_distribution( self )", "filename": "sdist.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "self" ], "start_line": 71, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "convert_line_endings", "long_name": "convert_line_endings( base_dir , fmt )", "filename": "sdist.py", "nloc": 1, "complexity": 1, "token_count": 8, "parameters": [ "base_dir", "fmt" ], "start_line": 99, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "remove_common_base", "long_name": "remove_common_base( files )", "filename": "sdist.py", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "files" ], "start_line": 106, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "find_common_base", "long_name": "find_common_base( files )", "filename": "sdist.py", "nloc": 19, "complexity": 8, "token_count": 106, "parameters": [ "files" ], "start_line": 119, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "methods_before": [ { "name": "add_defaults", "long_name": "add_defaults( self )", "filename": "sdist.py", "nloc": 7, "complexity": 3, "token_count": 63, "parameters": [ "self" ], "start_line": 5, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "make_release_tree", "long_name": "make_release_tree( self , base_dir , files )", "filename": "sdist.py", "nloc": 23, "complexity": 6, "token_count": 162, "parameters": [ "self", "base_dir", "files" ], "start_line": 14, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "remove_common_base", "long_name": "remove_common_base( files )", "filename": "sdist.py", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "files" ], "start_line": 71, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "find_common_base", "long_name": "find_common_base( files )", "filename": "sdist.py", "nloc": 19, "complexity": 8, "token_count": 106, "parameters": [ "files" ], "start_line": 84, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "make_distribution", "long_name": "make_distribution( self )", "filename": "sdist.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "self" ], "start_line": 71, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "convert_line_endings", "long_name": "convert_line_endings( base_dir , fmt )", "filename": "sdist.py", "nloc": 1, "complexity": 1, "token_count": 8, "parameters": [ "base_dir", "fmt" ], "start_line": 99, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "nloc": 71, "complexity": 23, "token_count": 537, "diff_parsed": { "added": [ " def make_distribution (self):", " \"\"\" Overridden to force a build of zip files to have Windows line", " endings and tar balls to have Unix line endings.", "", " Create the source distribution(s). First, we create the release", " tree with 'make_release_tree()'; then, we create all required", " archive files (according to 'self.formats') from the release tree.", " Finally, we clean up by blowing away the release tree (unless", " 'self.keep_temp' is true). The list of archive files created is", " stored so it can be retrieved later by 'get_archive_files()'.", " \"\"\"", " # Don't warn about missing meta-data here -- should be (and is!)", " # done elsewhere.", " base_dir = self.distribution.get_fullname()", " base_name = os.path.join(self.dist_dir, base_dir)", "", " self.make_release_tree(base_dir, self.filelist.files)", " archive_files = [] # remember names of files we create", " for fmt in self.formats:", " self.convert_line_endings(base_dir,fmt)", " file = self.make_archive(base_name, fmt, base_dir=base_dir)", " archive_files.append(file)", "", " self.archive_files = archive_files", "", " if not self.keep_temp:", " dir_util.remove_tree(base_dir, self.verbose, self.dry_run)", "", " def convert_line_endings(base_dir,fmt):", " \"\"\" Convert all text files in a tree to have correct line endings.", "", " gztar --> \\n (Unix style)", " zip --> \\r\\n (Windows style)", " \"\"\"", "" ], "deleted": [] } }, { "old_path": null, "new_path": "scipy_distutils/line_endings.py", "filename": "line_endings.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,36 @@\n+\"\"\" Functions for converting from DOS to UNIX line endings\n+\"\"\"\n+\n+import sys, re, os\n+\n+def dos2unix(file):\n+ \"Replace CRLF with LF in argument files. Print names of changed files.\" \n+ if os.path.isdir(file):\n+ print file, \"Directory!\"\n+ return\n+ \n+ data = open(file, \"rb\").read()\n+ if '\\0' in data:\n+ print file, \"Binary!\"\n+ return\n+ \n+ newdata = re.sub(\"\\r\\n\", \"\\n\", data)\n+ if newdata != data:\n+ print file\n+ f = open(file, \"wb\")\n+ f.write(newdata)\n+ f.close()\n+ else:\n+ print file, 'ok' \n+\n+def dos2unix_one_dir(args,dir_name,file_names):\n+ for file in file_names:\n+ full_path = os.path.join(dir_name,file)\n+ dos2unix(full_path)\n+ \n+def dos2unix_dir(dir_name):\n+ os.path.walk(dir_name,dos2unix_one_dir,[])\n+ \n+if __name__ == \"__main__\":\n+ import sys\n+ dos2unix_dir(sys.argv[1])\n", "added_lines": 36, "deleted_lines": 0, "source_code": "\"\"\" Functions for converting from DOS to UNIX line endings\n\"\"\"\n\nimport sys, re, os\n\ndef dos2unix(file):\n \"Replace CRLF with LF in argument files. Print names of changed files.\" \n if os.path.isdir(file):\n print file, \"Directory!\"\n return\n \n data = open(file, \"rb\").read()\n if '\\0' in data:\n print file, \"Binary!\"\n return\n \n newdata = re.sub(\"\\r\\n\", \"\\n\", data)\n if newdata != data:\n print file\n f = open(file, \"wb\")\n f.write(newdata)\n f.close()\n else:\n print file, 'ok' \n\ndef dos2unix_one_dir(args,dir_name,file_names):\n for file in file_names:\n full_path = os.path.join(dir_name,file)\n dos2unix(full_path)\n \ndef dos2unix_dir(dir_name):\n os.path.walk(dir_name,dos2unix_one_dir,[])\n \nif __name__ == \"__main__\":\n import sys\n dos2unix_dir(sys.argv[1])\n", "source_code_before": null, "methods": [ { "name": "dos2unix", "long_name": "dos2unix( file )", "filename": "line_endings.py", "nloc": 17, "complexity": 4, "token_count": 87, "parameters": [ "file" ], "start_line": 6, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "dos2unix_one_dir", "long_name": "dos2unix_one_dir( args , dir_name , file_names )", "filename": "line_endings.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "args", "dir_name", "file_names" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "dos2unix_dir", "long_name": "dos2unix_dir( dir_name )", "filename": "line_endings.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "dir_name" ], "start_line": 31, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "dos2unix_dir", "long_name": "dos2unix_dir( dir_name )", "filename": "line_endings.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "dir_name" ], "start_line": 31, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "dos2unix", "long_name": "dos2unix( file )", "filename": "line_endings.py", "nloc": 17, "complexity": 4, "token_count": 87, "parameters": [ "file" ], "start_line": 6, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "dos2unix_one_dir", "long_name": "dos2unix_one_dir( args , dir_name , file_names )", "filename": "line_endings.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "args", "dir_name", "file_names" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "nloc": 29, "complexity": 7, "token_count": 161, "diff_parsed": { "added": [ "\"\"\" Functions for converting from DOS to UNIX line endings", "\"\"\"", "", "import sys, re, os", "", "def dos2unix(file):", " \"Replace CRLF with LF in argument files. Print names of changed files.\"", " if os.path.isdir(file):", " print file, \"Directory!\"", " return", "", " data = open(file, \"rb\").read()", " if '\\0' in data:", " print file, \"Binary!\"", " return", "", " newdata = re.sub(\"\\r\\n\", \"\\n\", data)", " if newdata != data:", " print file", " f = open(file, \"wb\")", " f.write(newdata)", " f.close()", " else:", " print file, 'ok'", "", "def dos2unix_one_dir(args,dir_name,file_names):", " for file in file_names:", " full_path = os.path.join(dir_name,file)", " dos2unix(full_path)", "", "def dos2unix_dir(dir_name):", " os.path.walk(dir_name,dos2unix_one_dir,[])", "", "if __name__ == \"__main__\":", " import sys", " dos2unix_dir(sys.argv[1])" ], "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": "@@ -178,7 +178,7 @@ def package_config(primary,dependencies=[]):\n \n list_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n- 'headers']\n+ 'headers']\n dict_keys = ['package_dir'] \n \n def default_config_dict():\n", "added_lines": 1, "deleted_lines": 1, "source_code": "import os,sys,string\n\ndef get_version(release_level='alpha', path='.', major=None):\n \"\"\"\n Return version string calculated from CVS tree or found in\n /__version__.py. Automatically update /__version__.py\n if the version is changed.\n An attempt is made to guarantee that version is increasing in\n time. This function always succeeds. None is returned if no\n version information is available.\n\n Version string is in the form\n\n ..--\n\n and its items have the following meanings:\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n \"\"\"\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_version(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version = '%s.%s.%s-%s-%s' % version_info\n\n if version != old_version:\n print 'updating version: %s -> %s'%(old_version,version)\n version_file = os.path.abspath(os.path.join(path,'__version__.py'))\n f = open(version_file,'w')\n f.write('# This file is automatically updated with get_version\\n'\\\n '# function from scipy_distutils.misc_utils.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_cvs_version(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_version(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n d1,d2 = map(eval,string.split(items[2],'.')[-2:])\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\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 #import scipy_distutils.setup\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\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() file 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():\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n return d\n\ndef merge_config_dicts(config_list):\n result = default_config_dict() \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", "source_code_before": "import os,sys,string\n\ndef get_version(release_level='alpha', path='.', major=None):\n \"\"\"\n Return version string calculated from CVS tree or found in\n /__version__.py. Automatically update /__version__.py\n if the version is changed.\n An attempt is made to guarantee that version is increasing in\n time. This function always succeeds. None is returned if no\n version information is available.\n\n Version string is in the form\n\n ..--\n\n and its items have the following meanings:\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n \"\"\"\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_version(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version = '%s.%s.%s-%s-%s' % version_info\n\n if version != old_version:\n print 'updating version: %s -> %s'%(old_version,version)\n version_file = os.path.abspath(os.path.join(path,'__version__.py'))\n f = open(version_file,'w')\n f.write('# This file is automatically updated with get_version\\n'\\\n '# function from scipy_distutils.misc_utils.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_cvs_version(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_version(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n d1,d2 = map(eval,string.split(items[2],'.')[-2:])\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\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 #import scipy_distutils.setup\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\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() file 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():\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n return d\n\ndef merge_config_dicts(config_list):\n result = default_config_dict() \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", "methods": [ { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , major = None )", "filename": "misc_util.py", "nloc": 51, "complexity": 11, "token_count": 299, "parameters": [ "release_level", "path", "major" ], "start_line": 3, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 }, { "name": "get_cvs_version", "long_name": "get_cvs_version( path )", "filename": "misc_util.py", "nloc": 17, "complexity": 9, "token_count": 170, "parameters": [ "path" ], "start_line": 82, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 107, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 125, "end_line": 127, "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": 129, "end_line": 132, "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": 134, "end_line": 135, "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": 137, "end_line": 151, "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": 153, "end_line": 163, "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": 165, "end_line": 177, "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( )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 34, "parameters": [], "start_line": 184, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 190, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , major = None )", "filename": "misc_util.py", "nloc": 51, "complexity": 11, "token_count": 299, "parameters": [ "release_level", "path", "major" ], "start_line": 3, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 }, { "name": "get_cvs_version", "long_name": "get_cvs_version( path )", "filename": "misc_util.py", "nloc": 17, "complexity": 9, "token_count": 170, "parameters": [ "path" ], "start_line": 82, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 107, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 125, "end_line": 127, "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": 129, "end_line": 132, "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": 134, "end_line": 135, "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": 137, "end_line": 151, "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": 153, "end_line": 163, "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": 165, "end_line": 177, "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( )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 34, "parameters": [], "start_line": 184, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 190, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 122, "complexity": 40, "token_count": 893, "diff_parsed": { "added": [ " 'headers']" ], "deleted": [ " 'headers']" ] } } ] }, { "hash": "f44e92676db3563e2e141c08b56a732a123e590e", "msg": "finished additions needed to have tar.gz automatically have correct line ending types even when built on windows (and the same for zip on Linux I think -- not tested)", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-01-07T07:23:37+00:00", "author_timezone": 0, "committer_date": "2002-01-07T07:23:37+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "bf4bf3b9774c2efcf749dbc1664472e8e46d6e31" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 5, "insertions": 45, "lines": 50, "files": 3, "dmm_unit_size": 0.37037037037037035, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.6666666666666666, "modified_files": [ { "old_path": "scipy_distutils/__version__.py", "new_path": "scipy_distutils/__version__.py", "filename": "__version__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n # This file is automatically updated with get_version\n # function from scipy_distutils.misc_utils.py\n-version = '0.1.19-alpha-47'\n-version_info = (0, 1, 19, 'alpha', 47)\n+version = '0.2.20-alpha-50'\n+version_info = (0, 2, 20, 'alpha', 50)\n", "added_lines": 2, "deleted_lines": 2, "source_code": "# This file is automatically updated with get_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.2.20-alpha-50'\nversion_info = (0, 2, 20, 'alpha', 50)\n", "source_code_before": "# This file is automatically updated with get_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.1.19-alpha-47'\nversion_info = (0, 1, 19, 'alpha', 47)\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 2, "complexity": 0, "token_count": 16, "diff_parsed": { "added": [ "version = '0.2.20-alpha-50'", "version_info = (0, 2, 20, 'alpha', 50)" ], "deleted": [ "version = '0.1.19-alpha-47'", "version_info = (0, 1, 19, 'alpha', 47)" ] } }, { "old_path": "scipy_distutils/command/sdist.py", "new_path": "scipy_distutils/command/sdist.py", "filename": "sdist.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,12 @@\n from distutils.command.sdist import *\n from distutils.command.sdist import sdist as old_sdist\n \n+import sys, os\n+mod = __import__(__name__)\n+sys.path.append(os.path.dirname(mod.__file__))\n+import line_endings\n+sys.path = sys.path[:-1]\n+\n class sdist(old_sdist):\n def add_defaults (self):\n old_sdist.add_defaults(self)\n@@ -96,13 +102,17 @@ def make_distribution (self):\n if not self.keep_temp:\n dir_util.remove_tree(base_dir, self.verbose, self.dry_run)\n \n- def convert_line_endings(base_dir,fmt):\n+ def convert_line_endings(self,base_dir,fmt):\n \"\"\" Convert all text files in a tree to have correct line endings.\n \n gztar --> \\n (Unix style)\n zip --> \\r\\n (Windows style)\n \"\"\"\n- \n+ if fmt == 'gztar':\n+ line_endings.dos2unix_dir(base_dir)\n+ elif fmt == 'zip':\n+ line_endings.unix2dos_dir(base_dir)\n+ \n def remove_common_base(files):\n \"\"\" Remove the greatest common base directory from all the\n absolute file paths in the list of files. files in the\n", "added_lines": 12, "deleted_lines": 2, "source_code": "from distutils.command.sdist import *\nfrom distutils.command.sdist import sdist as old_sdist\n\nimport sys, os\nmod = __import__(__name__)\nsys.path.append(os.path.dirname(mod.__file__))\nimport line_endings\nsys.path = sys.path[:-1]\n\nclass sdist(old_sdist):\n def add_defaults (self):\n old_sdist.add_defaults(self)\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.filelist.extend(build_flib.get_source_files())\n\n if self.distribution.has_data_files():\n self.filelist.extend(self.distribution.get_data_files())\n\n def make_release_tree (self, base_dir, files):\n \"\"\"Create the directory tree that will become the source\n distribution archive. All directories implied by the filenames in\n 'files' are created under 'base_dir', and then we hard link or copy\n (if hard linking is unavailable) those files into place.\n Essentially, this duplicates the developer's source tree, but in a\n directory named after the distribution, containing only the files\n to be distributed.\n \"\"\"\n # Create all the directories under 'base_dir' necessary to\n # put 'files' there; the 'mkpath()' is just so we don't die\n # if the manifest happens to be empty.\n dest_files = remove_common_base(files)\n self.mkpath(base_dir)\n dir_util.create_tree(base_dir, dest_files,\n verbose=self.verbose, dry_run=self.dry_run)\n\n # And walk over the list of files, either making a hard link (if\n # os.link exists) to each one that doesn't already exist in its\n # corresponding location under 'base_dir', or copying each file\n # that's out-of-date in 'base_dir'. (Usually, all files will be\n # out-of-date, because by default we blow away 'base_dir' when\n # we're done making the distribution archives.)\n \n if hasattr(os, 'link'): # can make hard links on this system\n link = 'hard'\n msg = \"making hard links in %s...\" % base_dir\n else: # nope, have to copy\n link = None\n msg = \"copying files to %s...\" % base_dir\n\n if not files:\n self.warn(\"no files to distribute -- empty manifest?\")\n else:\n self.announce(msg)\n \n dest_files = [os.path.join(base_dir,file) for file in dest_files]\n file_pairs = zip(files,dest_files) \n for file,dest in file_pairs:\n if not os.path.isfile(file):\n self.warn(\"'%s' not a regular file -- skipping\" % file)\n else:\n #ej: here is the only change -- made to handle\n # absolute paths to files as well as relative\n #par,file_name = os.path.split(file)\n #dest = os.path.join(base_dir, file_name)\n # end of changes\n \n # old code\n #dest = os.path.join(base_dir, file)\n #end old code\n self.copy_file(file, dest, link=link)\n\n self.distribution.metadata.write_pkg_info(base_dir)\n #raise ValueError\n # make_release_tree ()\n\n def make_distribution (self):\n \"\"\" Overridden to force a build of zip files to have Windows line \n endings and tar balls to have Unix line endings.\n \n Create the source distribution(s). First, we create the release\n tree with 'make_release_tree()'; then, we create all required\n archive files (according to 'self.formats') from the release tree.\n Finally, we clean up by blowing away the release tree (unless\n 'self.keep_temp' is true). The list of archive files created is\n stored so it can be retrieved later by 'get_archive_files()'.\n \"\"\"\n # Don't warn about missing meta-data here -- should be (and is!)\n # done elsewhere.\n base_dir = self.distribution.get_fullname()\n base_name = os.path.join(self.dist_dir, base_dir)\n\n self.make_release_tree(base_dir, self.filelist.files)\n archive_files = [] # remember names of files we create\n for fmt in self.formats: \n self.convert_line_endings(base_dir,fmt)\n file = self.make_archive(base_name, fmt, base_dir=base_dir)\n archive_files.append(file)\n \n self.archive_files = archive_files\n\n if not self.keep_temp:\n dir_util.remove_tree(base_dir, self.verbose, self.dry_run)\n\n def convert_line_endings(self,base_dir,fmt):\n \"\"\" Convert all text files in a tree to have correct line endings.\n \n gztar --> \\n (Unix style)\n zip --> \\r\\n (Windows style)\n \"\"\"\n if fmt == 'gztar':\n line_endings.dos2unix_dir(base_dir)\n elif fmt == 'zip':\n line_endings.unix2dos_dir(base_dir)\n \ndef remove_common_base(files):\n \"\"\" Remove the greatest common base directory from all the\n absolute file paths in the list of files. files in the\n list without a parent directory are not affected.\n \"\"\"\n rel_files = filter(lambda x: not os.path.dirname(x),files)\n abs_files = filter(os.path.dirname,files)\n base = find_common_base(abs_files)\n # will leave files with local path unaffected\n # and maintains original file order\n results = [string.replace(file,base,'') for file in files]\n return results\n\ndef find_common_base(files):\n \"\"\" Find the \"greatest common base directory\" of a list of files\n \"\"\"\n if not files:\n return files\n result = ''\n d,f = os.path.split(files[0])\n keep_looking = 1 \n while(keep_looking and d):\n keep_looking = 0\n for file in files:\n if string.find('start'+file,'start'+d) == -1:\n keep_looking = 1\n break\n if keep_looking:\n d,f = os.path.split(d)\n else:\n result = d\n \n if d: \n d = os.path.join(d,'')\n return d ", "source_code_before": "from distutils.command.sdist import *\nfrom distutils.command.sdist import sdist as old_sdist\n\nclass sdist(old_sdist):\n def add_defaults (self):\n old_sdist.add_defaults(self)\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.filelist.extend(build_flib.get_source_files())\n\n if self.distribution.has_data_files():\n self.filelist.extend(self.distribution.get_data_files())\n\n def make_release_tree (self, base_dir, files):\n \"\"\"Create the directory tree that will become the source\n distribution archive. All directories implied by the filenames in\n 'files' are created under 'base_dir', and then we hard link or copy\n (if hard linking is unavailable) those files into place.\n Essentially, this duplicates the developer's source tree, but in a\n directory named after the distribution, containing only the files\n to be distributed.\n \"\"\"\n # Create all the directories under 'base_dir' necessary to\n # put 'files' there; the 'mkpath()' is just so we don't die\n # if the manifest happens to be empty.\n dest_files = remove_common_base(files)\n self.mkpath(base_dir)\n dir_util.create_tree(base_dir, dest_files,\n verbose=self.verbose, dry_run=self.dry_run)\n\n # And walk over the list of files, either making a hard link (if\n # os.link exists) to each one that doesn't already exist in its\n # corresponding location under 'base_dir', or copying each file\n # that's out-of-date in 'base_dir'. (Usually, all files will be\n # out-of-date, because by default we blow away 'base_dir' when\n # we're done making the distribution archives.)\n \n if hasattr(os, 'link'): # can make hard links on this system\n link = 'hard'\n msg = \"making hard links in %s...\" % base_dir\n else: # nope, have to copy\n link = None\n msg = \"copying files to %s...\" % base_dir\n\n if not files:\n self.warn(\"no files to distribute -- empty manifest?\")\n else:\n self.announce(msg)\n \n dest_files = [os.path.join(base_dir,file) for file in dest_files]\n file_pairs = zip(files,dest_files) \n for file,dest in file_pairs:\n if not os.path.isfile(file):\n self.warn(\"'%s' not a regular file -- skipping\" % file)\n else:\n #ej: here is the only change -- made to handle\n # absolute paths to files as well as relative\n #par,file_name = os.path.split(file)\n #dest = os.path.join(base_dir, file_name)\n # end of changes\n \n # old code\n #dest = os.path.join(base_dir, file)\n #end old code\n self.copy_file(file, dest, link=link)\n\n self.distribution.metadata.write_pkg_info(base_dir)\n #raise ValueError\n # make_release_tree ()\n\n def make_distribution (self):\n \"\"\" Overridden to force a build of zip files to have Windows line \n endings and tar balls to have Unix line endings.\n \n Create the source distribution(s). First, we create the release\n tree with 'make_release_tree()'; then, we create all required\n archive files (according to 'self.formats') from the release tree.\n Finally, we clean up by blowing away the release tree (unless\n 'self.keep_temp' is true). The list of archive files created is\n stored so it can be retrieved later by 'get_archive_files()'.\n \"\"\"\n # Don't warn about missing meta-data here -- should be (and is!)\n # done elsewhere.\n base_dir = self.distribution.get_fullname()\n base_name = os.path.join(self.dist_dir, base_dir)\n\n self.make_release_tree(base_dir, self.filelist.files)\n archive_files = [] # remember names of files we create\n for fmt in self.formats: \n self.convert_line_endings(base_dir,fmt)\n file = self.make_archive(base_name, fmt, base_dir=base_dir)\n archive_files.append(file)\n \n self.archive_files = archive_files\n\n if not self.keep_temp:\n dir_util.remove_tree(base_dir, self.verbose, self.dry_run)\n\n def convert_line_endings(base_dir,fmt):\n \"\"\" Convert all text files in a tree to have correct line endings.\n \n gztar --> \\n (Unix style)\n zip --> \\r\\n (Windows style)\n \"\"\"\n \ndef remove_common_base(files):\n \"\"\" Remove the greatest common base directory from all the\n absolute file paths in the list of files. files in the\n list without a parent directory are not affected.\n \"\"\"\n rel_files = filter(lambda x: not os.path.dirname(x),files)\n abs_files = filter(os.path.dirname,files)\n base = find_common_base(abs_files)\n # will leave files with local path unaffected\n # and maintains original file order\n results = [string.replace(file,base,'') for file in files]\n return results\n\ndef find_common_base(files):\n \"\"\" Find the \"greatest common base directory\" of a list of files\n \"\"\"\n if not files:\n return files\n result = ''\n d,f = os.path.split(files[0])\n keep_looking = 1 \n while(keep_looking and d):\n keep_looking = 0\n for file in files:\n if string.find('start'+file,'start'+d) == -1:\n keep_looking = 1\n break\n if keep_looking:\n d,f = os.path.split(d)\n else:\n result = d\n \n if d: \n d = os.path.join(d,'')\n return d ", "methods": [ { "name": "add_defaults", "long_name": "add_defaults( self )", "filename": "sdist.py", "nloc": 7, "complexity": 3, "token_count": 63, "parameters": [ "self" ], "start_line": 11, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "make_release_tree", "long_name": "make_release_tree( self , base_dir , files )", "filename": "sdist.py", "nloc": 23, "complexity": 6, "token_count": 162, "parameters": [ "self", "base_dir", "files" ], "start_line": 20, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "make_distribution", "long_name": "make_distribution( self )", "filename": "sdist.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "self" ], "start_line": 77, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "convert_line_endings", "long_name": "convert_line_endings( self , base_dir , fmt )", "filename": "sdist.py", "nloc": 5, "complexity": 3, "token_count": 32, "parameters": [ "self", "base_dir", "fmt" ], "start_line": 105, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "remove_common_base", "long_name": "remove_common_base( files )", "filename": "sdist.py", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "files" ], "start_line": 116, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "find_common_base", "long_name": "find_common_base( files )", "filename": "sdist.py", "nloc": 19, "complexity": 8, "token_count": 106, "parameters": [ "files" ], "start_line": 129, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "methods_before": [ { "name": "add_defaults", "long_name": "add_defaults( self )", "filename": "sdist.py", "nloc": 7, "complexity": 3, "token_count": 63, "parameters": [ "self" ], "start_line": 5, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "make_release_tree", "long_name": "make_release_tree( self , base_dir , files )", "filename": "sdist.py", "nloc": 23, "complexity": 6, "token_count": 162, "parameters": [ "self", "base_dir", "files" ], "start_line": 14, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "make_distribution", "long_name": "make_distribution( self )", "filename": "sdist.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "self" ], "start_line": 71, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "convert_line_endings", "long_name": "convert_line_endings( base_dir , fmt )", "filename": "sdist.py", "nloc": 1, "complexity": 1, "token_count": 8, "parameters": [ "base_dir", "fmt" ], "start_line": 99, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "remove_common_base", "long_name": "remove_common_base( files )", "filename": "sdist.py", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "files" ], "start_line": 106, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "find_common_base", "long_name": "find_common_base( files )", "filename": "sdist.py", "nloc": 19, "complexity": 8, "token_count": 106, "parameters": [ "files" ], "start_line": 119, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "convert_line_endings", "long_name": "convert_line_endings( base_dir , fmt )", "filename": "sdist.py", "nloc": 1, "complexity": 1, "token_count": 8, "parameters": [ "base_dir", "fmt" ], "start_line": 99, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "convert_line_endings", "long_name": "convert_line_endings( self , base_dir , fmt )", "filename": "sdist.py", "nloc": 5, "complexity": 3, "token_count": 32, "parameters": [ "self", "base_dir", "fmt" ], "start_line": 105, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "nloc": 80, "complexity": 25, "token_count": 602, "diff_parsed": { "added": [ "import sys, os", "mod = __import__(__name__)", "sys.path.append(os.path.dirname(mod.__file__))", "import line_endings", "sys.path = sys.path[:-1]", "", " def convert_line_endings(self,base_dir,fmt):", " if fmt == 'gztar':", " line_endings.dos2unix_dir(base_dir)", " elif fmt == 'zip':", " line_endings.unix2dos_dir(base_dir)", "" ], "deleted": [ " def convert_line_endings(base_dir,fmt):", "" ] } }, { "old_path": "scipy_distutils/line_endings.py", "new_path": "scipy_distutils/line_endings.py", "filename": "line_endings.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -16,7 +16,7 @@ def dos2unix(file):\n \n newdata = re.sub(\"\\r\\n\", \"\\n\", data)\n if newdata != data:\n- print file\n+ print 'dos2unix:', file\n f = open(file, \"wb\")\n f.write(newdata)\n f.close()\n@@ -30,7 +30,37 @@ def dos2unix_one_dir(args,dir_name,file_names):\n \n def dos2unix_dir(dir_name):\n os.path.walk(dir_name,dos2unix_one_dir,[])\n+\n+#----------------------------------\n+\n+def unix2dos(file):\n+ \"Replace LF with CRLF in argument files. Print names of changed files.\" \n+ if os.path.isdir(file):\n+ print file, \"Directory!\"\n+ return\n+ \n+ data = open(file, \"rb\").read()\n+ if '\\0' in data:\n+ print file, \"Binary!\"\n+ return\n+ \n+ newdata = re.sub(\"\\n\", \"\\r\\n\", data)\n+ if newdata != data:\n+ print 'unix2dos:', file\n+ f = open(file, \"wb\")\n+ f.write(newdata)\n+ f.close()\n+ else:\n+ print file, 'ok' \n+\n+def unix2dos_one_dir(args,dir_name,file_names):\n+ for file in file_names:\n+ full_path = os.path.join(dir_name,file)\n+ unix2dos(full_path)\n \n+def unix2dos_dir(dir_name):\n+ os.path.walk(dir_name,unix2dos_one_dir,[])\n+ \n if __name__ == \"__main__\":\n import sys\n dos2unix_dir(sys.argv[1])\n", "added_lines": 31, "deleted_lines": 1, "source_code": "\"\"\" Functions for converting from DOS to UNIX line endings\n\"\"\"\n\nimport sys, re, os\n\ndef dos2unix(file):\n \"Replace CRLF with LF in argument files. Print names of changed files.\" \n if os.path.isdir(file):\n print file, \"Directory!\"\n return\n \n data = open(file, \"rb\").read()\n if '\\0' in data:\n print file, \"Binary!\"\n return\n \n newdata = re.sub(\"\\r\\n\", \"\\n\", data)\n if newdata != data:\n print 'dos2unix:', file\n f = open(file, \"wb\")\n f.write(newdata)\n f.close()\n else:\n print file, 'ok' \n\ndef dos2unix_one_dir(args,dir_name,file_names):\n for file in file_names:\n full_path = os.path.join(dir_name,file)\n dos2unix(full_path)\n \ndef dos2unix_dir(dir_name):\n os.path.walk(dir_name,dos2unix_one_dir,[])\n\n#----------------------------------\n\ndef unix2dos(file):\n \"Replace LF with CRLF in argument files. Print names of changed files.\" \n if os.path.isdir(file):\n print file, \"Directory!\"\n return\n \n data = open(file, \"rb\").read()\n if '\\0' in data:\n print file, \"Binary!\"\n return\n \n newdata = re.sub(\"\\n\", \"\\r\\n\", data)\n if newdata != data:\n print 'unix2dos:', file\n f = open(file, \"wb\")\n f.write(newdata)\n f.close()\n else:\n print file, 'ok' \n\ndef unix2dos_one_dir(args,dir_name,file_names):\n for file in file_names:\n full_path = os.path.join(dir_name,file)\n unix2dos(full_path)\n \ndef unix2dos_dir(dir_name):\n os.path.walk(dir_name,unix2dos_one_dir,[])\n \nif __name__ == \"__main__\":\n import sys\n dos2unix_dir(sys.argv[1])\n", "source_code_before": "\"\"\" Functions for converting from DOS to UNIX line endings\n\"\"\"\n\nimport sys, re, os\n\ndef dos2unix(file):\n \"Replace CRLF with LF in argument files. Print names of changed files.\" \n if os.path.isdir(file):\n print file, \"Directory!\"\n return\n \n data = open(file, \"rb\").read()\n if '\\0' in data:\n print file, \"Binary!\"\n return\n \n newdata = re.sub(\"\\r\\n\", \"\\n\", data)\n if newdata != data:\n print file\n f = open(file, \"wb\")\n f.write(newdata)\n f.close()\n else:\n print file, 'ok' \n\ndef dos2unix_one_dir(args,dir_name,file_names):\n for file in file_names:\n full_path = os.path.join(dir_name,file)\n dos2unix(full_path)\n \ndef dos2unix_dir(dir_name):\n os.path.walk(dir_name,dos2unix_one_dir,[])\n \nif __name__ == \"__main__\":\n import sys\n dos2unix_dir(sys.argv[1])\n", "methods": [ { "name": "dos2unix", "long_name": "dos2unix( file )", "filename": "line_endings.py", "nloc": 17, "complexity": 4, "token_count": 89, "parameters": [ "file" ], "start_line": 6, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "dos2unix_one_dir", "long_name": "dos2unix_one_dir( args , dir_name , file_names )", "filename": "line_endings.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "args", "dir_name", "file_names" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "dos2unix_dir", "long_name": "dos2unix_dir( dir_name )", "filename": "line_endings.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "dir_name" ], "start_line": 31, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "unix2dos", "long_name": "unix2dos( file )", "filename": "line_endings.py", "nloc": 17, "complexity": 4, "token_count": 89, "parameters": [ "file" ], "start_line": 36, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "unix2dos_one_dir", "long_name": "unix2dos_one_dir( args , dir_name , file_names )", "filename": "line_endings.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "args", "dir_name", "file_names" ], "start_line": 56, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "unix2dos_dir", "long_name": "unix2dos_dir( dir_name )", "filename": "line_endings.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "dir_name" ], "start_line": 61, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 } ], "methods_before": [ { "name": "dos2unix", "long_name": "dos2unix( file )", "filename": "line_endings.py", "nloc": 17, "complexity": 4, "token_count": 87, "parameters": [ "file" ], "start_line": 6, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "dos2unix_one_dir", "long_name": "dos2unix_one_dir( args , dir_name , file_names )", "filename": "line_endings.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "args", "dir_name", "file_names" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "dos2unix_dir", "long_name": "dos2unix_dir( dir_name )", "filename": "line_endings.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "dir_name" ], "start_line": 31, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "dos2unix", "long_name": "dos2unix( file )", "filename": "line_endings.py", "nloc": 17, "complexity": 4, "token_count": 89, "parameters": [ "file" ], "start_line": 6, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "unix2dos_one_dir", "long_name": "unix2dos_one_dir( args , dir_name , file_names )", "filename": "line_endings.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "args", "dir_name", "file_names" ], "start_line": 56, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "unix2dos_dir", "long_name": "unix2dos_dir( dir_name )", "filename": "line_endings.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "dir_name" ], "start_line": 61, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "unix2dos", "long_name": "unix2dos( file )", "filename": "line_endings.py", "nloc": 17, "complexity": 4, "token_count": 89, "parameters": [ "file" ], "start_line": 36, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "nloc": 52, "complexity": 14, "token_count": 303, "diff_parsed": { "added": [ " print 'dos2unix:', file", "", "#----------------------------------", "", "def unix2dos(file):", " \"Replace LF with CRLF in argument files. Print names of changed files.\"", " if os.path.isdir(file):", " print file, \"Directory!\"", " return", "", " data = open(file, \"rb\").read()", " if '\\0' in data:", " print file, \"Binary!\"", " return", "", " newdata = re.sub(\"\\n\", \"\\r\\n\", data)", " if newdata != data:", " print 'unix2dos:', file", " f = open(file, \"wb\")", " f.write(newdata)", " f.close()", " else:", " print file, 'ok'", "", "def unix2dos_one_dir(args,dir_name,file_names):", " for file in file_names:", " full_path = os.path.join(dir_name,file)", " unix2dos(full_path)", "def unix2dos_dir(dir_name):", " os.path.walk(dir_name,unix2dos_one_dir,[])", "" ], "deleted": [ " print file" ] } } ] }, { "hash": "37e5c3733a16ca04c90af46807a703c9214cc478", "msg": "renamed get_version to update_version, introduced version_template argument", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-01-07T07:46:32+00:00", "author_timezone": 0, "committer_date": "2002-01-07T07:46:32+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "f44e92676db3563e2e141c08b56a732a123e590e" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 17, "insertions": 52, "lines": 69, "files": 3, "dmm_unit_size": 0.4090909090909091, "dmm_unit_complexity": 0.4090909090909091, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/__version__.py", "new_path": "scipy_distutils/__version__.py", "filename": "__version__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n # This file is automatically updated with get_version\n # function from scipy_distutils.misc_utils.py\n-version = '0.2.20-alpha-50'\n-version_info = (0, 2, 20, 'alpha', 50)\n+version = '0.2.20-alpha-54'\n+version_info = (0, 2, 20, 'alpha', 54)\n", "added_lines": 2, "deleted_lines": 2, "source_code": "# This file is automatically updated with get_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.2.20-alpha-54'\nversion_info = (0, 2, 20, 'alpha', 54)\n", "source_code_before": "# This file is automatically updated with get_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.2.20-alpha-50'\nversion_info = (0, 2, 20, 'alpha', 50)\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 2, "complexity": 0, "token_count": 16, "diff_parsed": { "added": [ "version = '0.2.20-alpha-54'", "version_info = (0, 2, 20, 'alpha', 54)" ], "deleted": [ "version = '0.2.20-alpha-50'", "version_info = (0, 2, 20, 'alpha', 50)" ] } }, { "old_path": "scipy_distutils/misc_util.py", "new_path": "scipy_distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,19 +1,27 @@\n import os,sys,string\n \n-def get_version(release_level='alpha', path='.', major=None):\n+def update_version(release_level='alpha',\n+ path='.',\n+ version_template = \\\n+ '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n+ major=None,\n+ overwrite_version_py = 1):\n \"\"\"\n- Return version string calculated from CVS tree or found in\n- /__version__.py. Automatically update /__version__.py\n- if the version is changed.\n- An attempt is made to guarantee that version is increasing in\n- time. This function always succeeds. None is returned if no\n- version information is available.\n+ Return version string calculated from CVS/Entries file(s) starting\n+ at . If the version information is different from the one\n+ found in the /__version__.py file, update_version updates\n+ the file automatically. The version information will be always\n+ increasing in time.\n+ If CVS tree does not exist (e.g. as in distribution packages),\n+ return the version string found from /__version__.py.\n+ If no version information is available, return None.\n \n- Version string is in the form\n+ Default version string is in the form\n \n ..--\n \n- and its items have the following meanings:\n+ The items have the following meanings:\n+\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n@@ -21,7 +29,15 @@ def get_version(release_level='alpha', path='.', major=None):\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n+\n \"\"\"\n+ # Open issues:\n+ # *** Recommend or not to add __version__.py file to CVS\n+ # repository? If it is in CVS, then when commiting, the\n+ # version information will change, but __version__.py\n+ # is commited with old version information to CVS. To get\n+ # __version__.py also up to date in CVS repository, \n+ # a second commit of the __version__.py file is required.\n \n release_level_map = {'alpha':0,\n 'beta':1,\n@@ -46,7 +62,7 @@ def get_version(release_level='alpha', path='.', major=None):\n old_version = None\n os.chdir(cwd)\n \n- cvs_revs = get_cvs_version(path)\n+ cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n \n@@ -66,9 +82,17 @@ def get_version(release_level='alpha', path='.', major=None):\n major = 0\n \n version_info = (major,minor,micro,release_level,serial)\n- version = '%s.%s.%s-%s-%s' % version_info\n+ version_dict = {'major':major,'minor':minor,'micro':micro,\n+ 'release_level':release_level,'serial':serial\n+ }\n+ version = version_template % version_dict\n \n if version != old_version:\n+ print 'version increase detected: %s -> %s'%(old_version,version)\n+ if not overwrite_version_py:\n+ print 'keeping %s with old version, returing new version' \\\n+ % (os.path.join(path,'__version__.py'))\n+ return version\n print 'updating version: %s -> %s'%(old_version,version)\n version_file = os.path.abspath(os.path.join(path,'__version__.py'))\n f = open(version_file,'w')\n@@ -79,7 +103,18 @@ def get_version(release_level='alpha', path='.', major=None):\n f.close()\n return version\n \n-def get_cvs_version(path):\n+def get_version(release_level='alpha',\n+ path='.',\n+ version_template = \\\n+ '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n+ major=None,\n+ ):\n+ return update_version(release_level = release_level,path = path,\n+ version_template = version_template,\n+ major = major,overwrite_version_py = 0)\n+\n+\n+def get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n@@ -94,7 +129,7 @@ def get_cvs_version(path):\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n- d1,d2 = get_cvs_version(os.path.join(path,items[1]))\n+ d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n", "added_lines": 48, "deleted_lines": 13, "source_code": "import os,sys,string\n\ndef update_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n overwrite_version_py = 1):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . If the version information is different from the one\n found in the /__version__.py file, update_version updates\n the file automatically. The version information will be always\n increasing in time.\n If CVS tree does not exist (e.g. as in distribution packages),\n return the version string found from /__version__.py.\n If no version information is available, return None.\n\n Default version string is in the form\n\n ..--\n\n The items have the following meanings:\n\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n\n \"\"\"\n # Open issues:\n # *** Recommend or not to add __version__.py file to CVS\n # repository? If it is in CVS, then when commiting, the\n # version information will change, but __version__.py\n # is commited with old version information to CVS. To get\n # __version__.py also up to date in CVS repository, \n # a second commit of the __version__.py file is required.\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version_dict = {'major':major,'minor':minor,'micro':micro,\n 'release_level':release_level,'serial':serial\n }\n version = version_template % version_dict\n\n if version != old_version:\n print 'version increase detected: %s -> %s'%(old_version,version)\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n % (os.path.join(path,'__version__.py'))\n return version\n print 'updating version: %s -> %s'%(old_version,version)\n version_file = os.path.abspath(os.path.join(path,'__version__.py'))\n f = open(version_file,'w')\n f.write('# This file is automatically updated with get_version\\n'\\\n '# function from scipy_distutils.misc_utils.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n ):\n return update_version(release_level = release_level,path = path,\n version_template = version_template,\n major = major,overwrite_version_py = 0)\n\n\ndef get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n d1,d2 = map(eval,string.split(items[2],'.')[-2:])\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\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 #import scipy_distutils.setup\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\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() file 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():\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n return d\n\ndef merge_config_dicts(config_list):\n result = default_config_dict() \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", "source_code_before": "import os,sys,string\n\ndef get_version(release_level='alpha', path='.', major=None):\n \"\"\"\n Return version string calculated from CVS tree or found in\n /__version__.py. Automatically update /__version__.py\n if the version is changed.\n An attempt is made to guarantee that version is increasing in\n time. This function always succeeds. None is returned if no\n version information is available.\n\n Version string is in the form\n\n ..--\n\n and its items have the following meanings:\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n \"\"\"\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_version(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version = '%s.%s.%s-%s-%s' % version_info\n\n if version != old_version:\n print 'updating version: %s -> %s'%(old_version,version)\n version_file = os.path.abspath(os.path.join(path,'__version__.py'))\n f = open(version_file,'w')\n f.write('# This file is automatically updated with get_version\\n'\\\n '# function from scipy_distutils.misc_utils.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_cvs_version(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_version(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n d1,d2 = map(eval,string.split(items[2],'.')[-2:])\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\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 #import scipy_distutils.setup\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\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() file 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():\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n return d\n\ndef merge_config_dicts(config_list):\n result = default_config_dict() \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", "methods": [ { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 64, "complexity": 12, "token_count": 361, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 3, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 102, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 44, "parameters": [ "release_level", "path", "major" ], "start_line": 106, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 17, "complexity": 9, "token_count": 170, "parameters": [ "path" ], "start_line": 117, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 142, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 160, "end_line": 162, "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": 164, "end_line": 167, "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": 169, "end_line": 170, "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": 172, "end_line": 186, "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": 188, "end_line": 198, "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": 200, "end_line": 212, "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( )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 34, "parameters": [], "start_line": 219, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 225, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , major = None )", "filename": "misc_util.py", "nloc": 51, "complexity": 11, "token_count": 299, "parameters": [ "release_level", "path", "major" ], "start_line": 3, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 }, { "name": "get_cvs_version", "long_name": "get_cvs_version( path )", "filename": "misc_util.py", "nloc": 17, "complexity": 9, "token_count": 170, "parameters": [ "path" ], "start_line": 82, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 107, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 125, "end_line": 127, "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": 129, "end_line": 132, "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": 134, "end_line": 135, "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": 137, "end_line": 151, "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": 153, "end_line": 163, "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": 165, "end_line": 177, "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( )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 34, "parameters": [], "start_line": 184, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 190, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 17, "complexity": 9, "token_count": 170, "parameters": [ "path" ], "start_line": 117, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "get_cvs_version", "long_name": "get_cvs_version( path )", "filename": "misc_util.py", "nloc": 17, "complexity": 9, "token_count": 170, "parameters": [ "path" ], "start_line": 82, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 44, "parameters": [ "release_level", "path", "major" ], "start_line": 106, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 64, "complexity": 12, "token_count": 361, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 3, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 102, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , major = None )", "filename": "misc_util.py", "nloc": 51, "complexity": 11, "token_count": 299, "parameters": [ "release_level", "path", "major" ], "start_line": 3, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 } ], "nloc": 144, "complexity": 42, "token_count": 1000, "diff_parsed": { "added": [ "def update_version(release_level='alpha',", " path='.',", " version_template = \\", " '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',", " major=None,", " overwrite_version_py = 1):", " Return version string calculated from CVS/Entries file(s) starting", " at . If the version information is different from the one", " found in the /__version__.py file, update_version updates", " the file automatically. The version information will be always", " increasing in time.", " If CVS tree does not exist (e.g. as in distribution packages),", " return the version string found from /__version__.py.", " If no version information is available, return None.", " Default version string is in the form", " The items have the following meanings:", "", "", " # Open issues:", " # *** Recommend or not to add __version__.py file to CVS", " # repository? If it is in CVS, then when commiting, the", " # version information will change, but __version__.py", " # is commited with old version information to CVS. To get", " # __version__.py also up to date in CVS repository,", " # a second commit of the __version__.py file is required.", " cvs_revs = get_cvs_revision(path)", " version_dict = {'major':major,'minor':minor,'micro':micro,", " 'release_level':release_level,'serial':serial", " }", " version = version_template % version_dict", " print 'version increase detected: %s -> %s'%(old_version,version)", " if not overwrite_version_py:", " print 'keeping %s with old version, returing new version' \\", " % (os.path.join(path,'__version__.py'))", " return version", "def get_version(release_level='alpha',", " path='.',", " version_template = \\", " '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',", " major=None,", " ):", " return update_version(release_level = release_level,path = path,", " version_template = version_template,", " major = major,overwrite_version_py = 0)", "", "", "def get_cvs_revision(path):", " d1,d2 = get_cvs_revision(os.path.join(path,items[1]))" ], "deleted": [ "def get_version(release_level='alpha', path='.', major=None):", " Return version string calculated from CVS tree or found in", " /__version__.py. Automatically update /__version__.py", " if the version is changed.", " An attempt is made to guarantee that version is increasing in", " time. This function always succeeds. None is returned if no", " version information is available.", " Version string is in the form", " and its items have the following meanings:", " cvs_revs = get_cvs_version(path)", " version = '%s.%s.%s-%s-%s' % version_info", "def get_cvs_version(path):", " d1,d2 = get_cvs_version(os.path.join(path,items[1]))" ] } }, { "old_path": "scipy_distutils/setup.py", "new_path": "scipy_distutils/setup.py", "filename": "setup.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -2,7 +2,7 @@\n import os\n \n from distutils.core import setup\n-from misc_util import get_path, get_version\n+from misc_util import get_path, update_version\n \n def install_package():\n \"\"\" Install the scipy_distutils. The dance with the current directory is done\n@@ -14,7 +14,7 @@ def install_package():\n os.chdir(path)\n try:\n \n- version = get_version('alpha')\n+ version = update_version('alpha')\n print 'scipy_distutils',version\n \n setup (name = \"scipy_distutils\",\n", "added_lines": 2, "deleted_lines": 2, "source_code": "#!/usr/bin/env python\nimport os\n\nfrom distutils.core import setup\nfrom misc_util import get_path, update_version\n\ndef install_package():\n \"\"\" Install the scipy_distutils. The dance with the current directory is done\n to fool distutils into thinking it is run from the scipy_distutils directory\n even if it was invoked from another script located in a different location.\n \"\"\"\n path = get_path(__name__)\n old_path = os.getcwd()\n os.chdir(path)\n try:\n\n version = update_version('alpha')\n print 'scipy_distutils',version\n\n setup (name = \"scipy_distutils\",\n version = version,\n description = \"Changes to distutils needed for SciPy -- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-devel@scipy.org\",\n licence = \"BSD Style\",\n url = 'http://www.scipy.org',\n packages = ['scipy_distutils','scipy_distutils.command'],\n package_dir = {'scipy_distutils':path}\n )\n finally:\n os.chdir(old_path)\n \nif __name__ == '__main__':\n install_package()\n", "source_code_before": "#!/usr/bin/env python\nimport os\n\nfrom distutils.core import setup\nfrom misc_util import get_path, get_version\n\ndef install_package():\n \"\"\" Install the scipy_distutils. The dance with the current directory is done\n to fool distutils into thinking it is run from the scipy_distutils directory\n even if it was invoked from another script located in a different location.\n \"\"\"\n path = get_path(__name__)\n old_path = os.getcwd()\n os.chdir(path)\n try:\n\n version = get_version('alpha')\n print 'scipy_distutils',version\n\n setup (name = \"scipy_distutils\",\n version = version,\n description = \"Changes to distutils needed for SciPy -- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-devel@scipy.org\",\n licence = \"BSD Style\",\n url = 'http://www.scipy.org',\n packages = ['scipy_distutils','scipy_distutils.command'],\n package_dir = {'scipy_distutils':path}\n )\n finally:\n os.chdir(old_path)\n \nif __name__ == '__main__':\n install_package()\n", "methods": [ { "name": "install_package", "long_name": "install_package( )", "filename": "setup.py", "nloc": 19, "complexity": 2, "token_count": 90, "parameters": [], "start_line": 7, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 } ], "methods_before": [ { "name": "install_package", "long_name": "install_package( )", "filename": "setup.py", "nloc": 19, "complexity": 2, "token_count": 90, "parameters": [], "start_line": 7, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "install_package", "long_name": "install_package( )", "filename": "setup.py", "nloc": 19, "complexity": 2, "token_count": 90, "parameters": [], "start_line": 7, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 } ], "nloc": 24, "complexity": 2, "token_count": 113, "diff_parsed": { "added": [ "from misc_util import get_path, update_version", " version = update_version('alpha')" ], "deleted": [ "from misc_util import get_path, get_version", " version = get_version('alpha')" ] } } ] }, { "hash": "b9ba1e7dd0340e029d9c9f64f29ff9006aae5b05", "msg": "renamed get_version to update_version, introduced version_template argument", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-01-07T07:47:02+00:00", "author_timezone": 0, "committer_date": "2002-01-07T07:47:02+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "37e5c3733a16ca04c90af46807a703c9214cc478" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 5, "insertions": 6, "lines": 11, "files": 2, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/__version__.py", "new_path": "scipy_distutils/__version__.py", "filename": "__version__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n # This file is automatically updated with get_version\n # function from scipy_distutils.misc_utils.py\n-version = '0.2.20-alpha-54'\n-version_info = (0, 2, 20, 'alpha', 54)\n+version = '0.2.20-alpha-55'\n+version_info = (0, 2, 20, 'alpha', 55)\n", "added_lines": 2, "deleted_lines": 2, "source_code": "# This file is automatically updated with get_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.2.20-alpha-55'\nversion_info = (0, 2, 20, 'alpha', 55)\n", "source_code_before": "# This file is automatically updated with get_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.2.20-alpha-54'\nversion_info = (0, 2, 20, 'alpha', 54)\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 2, "complexity": 0, "token_count": 16, "diff_parsed": { "added": [ "version = '0.2.20-alpha-55'", "version_info = (0, 2, 20, 'alpha', 55)" ], "deleted": [ "version = '0.2.20-alpha-54'", "version_info = (0, 2, 20, 'alpha', 54)" ] } }, { "old_path": "scipy_distutils/misc_util.py", "new_path": "scipy_distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -89,12 +89,13 @@ def update_version(release_level='alpha',\n \n if version != old_version:\n print 'version increase detected: %s -> %s'%(old_version,version)\n+ version_file = os.path.join(path,'__version__.py')\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n- % (os.path.join(path,'__version__.py'))\n+ % (version_file)\n return version\n- print 'updating version: %s -> %s'%(old_version,version)\n- version_file = os.path.abspath(os.path.join(path,'__version__.py'))\n+ print 'updating version in %s' % version_file\n+ version_file = os.path.abspath(version_file)\n f = open(version_file,'w')\n f.write('# This file is automatically updated with get_version\\n'\\\n '# function from scipy_distutils.misc_utils.py\\n'\\\n", "added_lines": 4, "deleted_lines": 3, "source_code": "import os,sys,string\n\ndef update_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n overwrite_version_py = 1):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . If the version information is different from the one\n found in the /__version__.py file, update_version updates\n the file automatically. The version information will be always\n increasing in time.\n If CVS tree does not exist (e.g. as in distribution packages),\n return the version string found from /__version__.py.\n If no version information is available, return None.\n\n Default version string is in the form\n\n ..--\n\n The items have the following meanings:\n\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n\n \"\"\"\n # Open issues:\n # *** Recommend or not to add __version__.py file to CVS\n # repository? If it is in CVS, then when commiting, the\n # version information will change, but __version__.py\n # is commited with old version information to CVS. To get\n # __version__.py also up to date in CVS repository, \n # a second commit of the __version__.py file is required.\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version_dict = {'major':major,'minor':minor,'micro':micro,\n 'release_level':release_level,'serial':serial\n }\n version = version_template % version_dict\n\n if version != old_version:\n print 'version increase detected: %s -> %s'%(old_version,version)\n version_file = os.path.join(path,'__version__.py')\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n % (version_file)\n return version\n print 'updating version in %s' % version_file\n version_file = os.path.abspath(version_file)\n f = open(version_file,'w')\n f.write('# This file is automatically updated with get_version\\n'\\\n '# function from scipy_distutils.misc_utils.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n ):\n return update_version(release_level = release_level,path = path,\n version_template = version_template,\n major = major,overwrite_version_py = 0)\n\n\ndef get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n d1,d2 = map(eval,string.split(items[2],'.')[-2:])\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\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 #import scipy_distutils.setup\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\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() file 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():\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n return d\n\ndef merge_config_dicts(config_list):\n result = default_config_dict() \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", "source_code_before": "import os,sys,string\n\ndef update_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n overwrite_version_py = 1):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . If the version information is different from the one\n found in the /__version__.py file, update_version updates\n the file automatically. The version information will be always\n increasing in time.\n If CVS tree does not exist (e.g. as in distribution packages),\n return the version string found from /__version__.py.\n If no version information is available, return None.\n\n Default version string is in the form\n\n ..--\n\n The items have the following meanings:\n\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n\n \"\"\"\n # Open issues:\n # *** Recommend or not to add __version__.py file to CVS\n # repository? If it is in CVS, then when commiting, the\n # version information will change, but __version__.py\n # is commited with old version information to CVS. To get\n # __version__.py also up to date in CVS repository, \n # a second commit of the __version__.py file is required.\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version_dict = {'major':major,'minor':minor,'micro':micro,\n 'release_level':release_level,'serial':serial\n }\n version = version_template % version_dict\n\n if version != old_version:\n print 'version increase detected: %s -> %s'%(old_version,version)\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n % (os.path.join(path,'__version__.py'))\n return version\n print 'updating version: %s -> %s'%(old_version,version)\n version_file = os.path.abspath(os.path.join(path,'__version__.py'))\n f = open(version_file,'w')\n f.write('# This file is automatically updated with get_version\\n'\\\n '# function from scipy_distutils.misc_utils.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n ):\n return update_version(release_level = release_level,path = path,\n version_template = version_template,\n major = major,overwrite_version_py = 0)\n\n\ndef get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n d1,d2 = map(eval,string.split(items[2],'.')[-2:])\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\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 #import scipy_distutils.setup\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\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() file 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():\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n return d\n\ndef merge_config_dicts(config_list):\n result = default_config_dict() \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", "methods": [ { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 65, "complexity": 12, "token_count": 351, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 3, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 103, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 44, "parameters": [ "release_level", "path", "major" ], "start_line": 107, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 17, "complexity": 9, "token_count": 170, "parameters": [ "path" ], "start_line": 118, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 143, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 161, "end_line": 163, "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": 165, "end_line": 168, "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": 170, "end_line": 171, "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": 173, "end_line": 187, "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": 189, "end_line": 199, "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": 201, "end_line": 213, "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( )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 34, "parameters": [], "start_line": 220, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 226, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 64, "complexity": 12, "token_count": 361, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 3, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 102, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 44, "parameters": [ "release_level", "path", "major" ], "start_line": 106, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 17, "complexity": 9, "token_count": 170, "parameters": [ "path" ], "start_line": 117, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 142, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 160, "end_line": 162, "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": 164, "end_line": 167, "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": 169, "end_line": 170, "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": 172, "end_line": 186, "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": 188, "end_line": 198, "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": 200, "end_line": 212, "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( )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 34, "parameters": [], "start_line": 219, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 225, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 65, "complexity": 12, "token_count": 351, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 3, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 103, "top_nesting_level": 0 } ], "nloc": 145, "complexity": 42, "token_count": 990, "diff_parsed": { "added": [ " version_file = os.path.join(path,'__version__.py')", " % (version_file)", " print 'updating version in %s' % version_file", " version_file = os.path.abspath(version_file)" ], "deleted": [ " % (os.path.join(path,'__version__.py'))", " print 'updating version: %s -> %s'%(old_version,version)", " version_file = os.path.abspath(os.path.join(path,'__version__.py'))" ] } } ] }, { "hash": "53022e625eafaedd81b7743bca40af6e0fa8767a", "msg": "added atlas \"discovery\" module to scipy_distutils", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-01-07T21:05:53+00:00", "author_timezone": 0, "committer_date": "2002-01-07T21:05:53+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "b9ba1e7dd0340e029d9c9f64f29ff9006aae5b05" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 0, "insertions": 38, "lines": 38, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": null, "new_path": "scipy_distutils/atlas_info.py", "filename": "atlas_info.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,38 @@\n+import sys, os\n+\n+def get_atlas_info():\n+ if sys.platform == 'win32':\n+ atlas_library_dirs=['C:\\\\atlas\\\\WinNT_PIIISSE1']\n+ blas_libraries = ['f77blas', 'cblas', 'atlas', 'g2c']\n+ lapack_libraries = ['lapack'] + blas_libraries \n+ else:\n+ atlas_library_dirs = unix_atlas_directory(plat)\n+ blas_libraries = ['cblas','f77blas','atlas']\n+ lapack_libraries = ['lapack'] + blas_libraries\n+ return blas_libraries, lapack_libraries, atlas_library_dirs\n+\n+def unix_atlas_directory(platform):\n+ \"\"\" Search a list of common locations looking for the atlas directory.\n+ \n+ Return None if the directory isn't found, otherwise return the\n+ directory name. This isn't very sophisticated right now. I can\n+ imagine doing an ftp to our server on platforms that we know about.\n+ \n+ Atlas is a highly optimized version of lapack and blas that is fast\n+ on almost all platforms.\n+ \"\"\"\n+ result = [] #None\n+ # do a little looking for the linalg directory for atlas libraries\n+ path = get_path(__name__)\n+ local_atlas0 = os.path.join(path,platform,'atlas')\n+ local_atlas1 = os.path.join(path,platform[:-1],'atlas')\n+ \n+ # first look for a system defined atlas directory\n+ dir_search = ['/usr/local/lib/atlas','/usr/lib/atlas',\n+ local_atlas0, local_atlas1]\n+ for directory in dir_search:\n+ if os.path.exists(directory):\n+ result = [directory]\n+\n+ # we should really do an ftp search or something like that at this point.\n+ return result \n", "added_lines": 38, "deleted_lines": 0, "source_code": "import sys, os\n\ndef get_atlas_info():\n if sys.platform == 'win32':\n atlas_library_dirs=['C:\\\\atlas\\\\WinNT_PIIISSE1']\n blas_libraries = ['f77blas', 'cblas', 'atlas', 'g2c']\n lapack_libraries = ['lapack'] + blas_libraries \n else:\n atlas_library_dirs = unix_atlas_directory(plat)\n blas_libraries = ['cblas','f77blas','atlas']\n lapack_libraries = ['lapack'] + blas_libraries\n return blas_libraries, lapack_libraries, atlas_library_dirs\n\ndef unix_atlas_directory(platform):\n \"\"\" Search a list of common locations looking for the atlas directory.\n \n Return None if the directory isn't found, otherwise return the\n directory name. This isn't very sophisticated right now. I can\n imagine doing an ftp to our server on platforms that we know about.\n \n Atlas is a highly optimized version of lapack and blas that is fast\n on almost all platforms.\n \"\"\"\n result = [] #None\n # do a little looking for the linalg directory for atlas libraries\n path = get_path(__name__)\n local_atlas0 = os.path.join(path,platform,'atlas')\n local_atlas1 = os.path.join(path,platform[:-1],'atlas')\n \n # first look for a system defined atlas directory\n dir_search = ['/usr/local/lib/atlas','/usr/lib/atlas',\n local_atlas0, local_atlas1]\n for directory in dir_search:\n if os.path.exists(directory):\n result = [directory]\n\n # we should really do an ftp search or something like that at this point.\n return result \n", "source_code_before": null, "methods": [ { "name": "get_atlas_info", "long_name": "get_atlas_info( )", "filename": "atlas_info.py", "nloc": 10, "complexity": 2, "token_count": 64, "parameters": [], "start_line": 3, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "unix_atlas_directory", "long_name": "unix_atlas_directory( platform )", "filename": "atlas_info.py", "nloc": 11, "complexity": 3, "token_count": 82, "parameters": [ "platform" ], "start_line": 14, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "unix_atlas_directory", "long_name": "unix_atlas_directory( platform )", "filename": "atlas_info.py", "nloc": 11, "complexity": 3, "token_count": 82, "parameters": [ "platform" ], "start_line": 14, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "get_atlas_info", "long_name": "get_atlas_info( )", "filename": "atlas_info.py", "nloc": 10, "complexity": 2, "token_count": 64, "parameters": [], "start_line": 3, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 } ], "nloc": 22, "complexity": 5, "token_count": 152, "diff_parsed": { "added": [ "import sys, os", "", "def get_atlas_info():", " if sys.platform == 'win32':", " atlas_library_dirs=['C:\\\\atlas\\\\WinNT_PIIISSE1']", " blas_libraries = ['f77blas', 'cblas', 'atlas', 'g2c']", " lapack_libraries = ['lapack'] + blas_libraries", " else:", " atlas_library_dirs = unix_atlas_directory(plat)", " blas_libraries = ['cblas','f77blas','atlas']", " lapack_libraries = ['lapack'] + blas_libraries", " return blas_libraries, lapack_libraries, atlas_library_dirs", "", "def unix_atlas_directory(platform):", " \"\"\" Search a list of common locations looking for the atlas directory.", "", " Return None if the directory isn't found, otherwise return the", " directory name. This isn't very sophisticated right now. I can", " imagine doing an ftp to our server on platforms that we know about.", "", " Atlas is a highly optimized version of lapack and blas that is fast", " on almost all platforms.", " \"\"\"", " result = [] #None", " # do a little looking for the linalg directory for atlas libraries", " path = get_path(__name__)", " local_atlas0 = os.path.join(path,platform,'atlas')", " local_atlas1 = os.path.join(path,platform[:-1],'atlas')", "", " # first look for a system defined atlas directory", " dir_search = ['/usr/local/lib/atlas','/usr/lib/atlas',", " local_atlas0, local_atlas1]", " for directory in dir_search:", " if os.path.exists(directory):", " result = [directory]", "", " # we should really do an ftp search or something like that at this point.", " return result" ], "deleted": [] } } ] }, { "hash": "10aaa27252b35120213cc7ef054167fe16bcff6f", "msg": "Added f2py support back into scipy_distutils. This required a few more changes to the setup files.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-01-09T06:22:28+00:00", "author_timezone": 0, "committer_date": "2002-01-09T06:22:28+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "53022e625eafaedd81b7743bca40af6e0fa8767a" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 6, "insertions": 369, "lines": 375, "files": 4, "dmm_unit_size": 0.12217194570135746, "dmm_unit_complexity": 0.12217194570135746, "dmm_unit_interfacing": 0.5882352941176471, "modified_files": [ { "old_path": "scipy_distutils/__version__.py", "new_path": "scipy_distutils/__version__.py", "filename": "__version__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n # This file is automatically updated with get_version\n # function from scipy_distutils.misc_utils.py\n-version = '0.2.20-alpha-55'\n-version_info = (0, 2, 20, 'alpha', 55)\n+version = '0.5.21-alpha-56'\n+version_info = (0, 5, 21, 'alpha', 56)\n", "added_lines": 2, "deleted_lines": 2, "source_code": "# This file is automatically updated with get_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.5.21-alpha-56'\nversion_info = (0, 5, 21, 'alpha', 56)\n", "source_code_before": "# This file is automatically updated with get_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.2.20-alpha-55'\nversion_info = (0, 2, 20, 'alpha', 55)\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 2, "complexity": 0, "token_count": 16, "diff_parsed": { "added": [ "version = '0.5.21-alpha-56'", "version_info = (0, 5, 21, 'alpha', 56)" ], "deleted": [ "version = '0.2.20-alpha-55'", "version_info = (0, 2, 20, 'alpha', 55)" ] } }, { "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": "@@ -1,5 +1,15 @@\n \"\"\" Modified version of build_ext that handles fortran source files and f2py \n \n+ The f2py_sources() method is pretty much a copy of the swig_sources()\n+ method in the standard build_ext class , but modified to use f2py. It\n+ also.\n+ \n+ slightly_modified_standard_build_extension() is a verbatim copy of\n+ the standard build_extension() method with a single line changed so that\n+ preprocess_sources() is called instead of just swig_sources(). This new\n+ function is a nice place to stick any source code preprocessing functions\n+ needed.\n+ \n build_extension() handles building any needed static fortran libraries\n first and then calls our slightly_modified_..._extenstion() to do the\n rest of the processing in the (mostly) standard way. \n@@ -13,9 +23,20 @@\n from distutils.command.build_ext import build_ext as old_build_ext\n \n class build_ext (old_build_ext):\n+ user_options = old_build_ext.user_options + \\\n+ [('f2py-options=', None,\n+ \"command line arguments to f2py\")]\n \n- def run (self):\n+ def initialize_options(self):\n+ old_build_ext.initialize_options(self)\n+ self.f2py_options = None\n \n+ def finalize_options (self): \n+ old_build_ext.finalize_options(self)\n+ if self.f2py_options is None:\n+ self.f2py_options = []\n+ \n+ def run (self):\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.libraries.extend(build_flib.get_library_names() or [])\n@@ -28,7 +49,21 @@ def run (self):\n self.library_dirs.append(build_flib.build_flib)\n \n old_build_ext.run(self)\n- \n+\n+ def preprocess_sources(self,sources,ext):\n+ sources = self.swig_sources(sources)\n+ if self.has_f2py_sources(sources): \n+ sources = self.f2py_sources(sources,ext)\n+ return sources\n+ \n+ def extra_include_dirs(self,sources):\n+ if self.has_f2py_sources(sources): \n+ import f2py2e\n+ d = os.path.dirname(f2py2e.__file__)\n+ return [os.path.join(d,'src')]\n+ else:\n+ return [] \n+ \n def build_extension(self, ext):\n # support for building static fortran libraries\n if self.distribution.has_f_libraries():\n@@ -46,7 +81,180 @@ def build_extension(self, ext):\n if linker_so is not None:\n self.compiler.linker_so = linker_so\n # end of fortran source support\n- return old_build_ext.build_extension(self,ext)\n+ # f2py support handled slightly_modified..._extenstion.\n+ return self.slightly_modified_standard_build_extension(ext)\n+ \n+ def slightly_modified_standard_build_extension(self, ext):\n+ \"\"\"\n+ This is pretty much a verbatim copy of the build_extension()\n+ function in distutils with a single change to make it possible\n+ to pre-process f2py as well as swig source files before \n+ compilation.\n+ \"\"\"\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+ # ignore build-lib -- put the compiled extension into\n+ # the source tree along with pure Python modules\n+\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+\n+ if not (self.force or newer_group(sources, ext_filename, 'newer')):\n+ self.announce(\"skipping '%s' extension (up-to-date)\" %\n+ ext.name)\n+ return\n+ else:\n+ self.announce(\"building '%s' extension\" % ext.name)\n+\n+ # I copied this hole stinken function just to change from\n+ # self.swig_sources to self.preprocess_sources...\n+ # ! must come before the next line!!\n+ include_dirs = self.extra_include_dirs(sources) + \\\n+ (ext.include_dirs or [])\n+ sources = self.preprocess_sources(sources, ext)\n+ \n+ # Next, compile the source code to object files.\n+\n+ # XXX not honouring 'define_macros' or 'undef_macros' -- the\n+ # CCompiler API needs to change to accommodate this, and I\n+ # want to do one thing at a time!\n+\n+ # Two possible sources for extra compiler arguments:\n+ # - 'extra_compile_args' in Extension object\n+ # - CFLAGS environment variable (not particularly\n+ # elegant, but people seem to expect it and I\n+ # guess it's useful)\n+ # The environment variable should take precedence, and\n+ # any sensible compiler will give precedence to later\n+ # command line args. Hence we combine them in order:\n+ extra_args = ext.extra_compile_args or []\n+\n+ macros = ext.define_macros[:]\n+ for undef in ext.undef_macros:\n+ macros.append((undef,))\n+\n+ # XXX and if we support CFLAGS, why not CC (compiler\n+ # executable), CPPFLAGS (pre-processor options), and LDFLAGS\n+ # (linker options) too?\n+ # XXX should we use shlex to properly parse CFLAGS?\n+\n+ if os.environ.has_key('CFLAGS'):\n+ extra_args.extend(string.split(os.environ['CFLAGS']))\n+\n+ objects = self.compiler.compile(sources,\n+ output_dir=self.build_temp,\n+ macros=macros,\n+ include_dirs=include_dirs,\n+ debug=self.debug,\n+ extra_postargs=extra_args)\n+\n+ # Now link the object files together into a \"shared object\" --\n+ # of course, first we have to figure out all the other things\n+ # that go into the mix.\n+ if ext.extra_objects:\n+ objects.extend(ext.extra_objects)\n+ extra_args = ext.extra_link_args or []\n+\n+\n+ self.compiler.link_shared_object(\n+ 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)\n+\n+ def has_f2py_sources (self, sources):\n+ print sources\n+ for source in sources:\n+ (base, ext) = os.path.splitext(source)\n+ if ext == \".pyf\": # f2py interface file\n+ return 1\n+ print 'no!' \n+ return 0\n+ \n+ def f2py_sources (self, sources, ext):\n+\n+ \"\"\"Walk the list of source files in 'sources', looking for f2py\n+ interface (.pyf) files. Run f2py on all that are found, and\n+ return a modified 'sources' list with f2py source files replaced\n+ by the generated C (or C++) files.\n+ \"\"\"\n+\n+ import f2py2e\n+\n+ new_sources = []\n+ new_include_dirs = []\n+ f2py_sources = []\n+ f2py_targets = {}\n+\n+ # XXX this drops generated C/C++ files into the source tree, which\n+ # is fine for developers who want to distribute the generated\n+ # source -- but there should be an option to put f2py output in\n+ # the temp dir.\n+\n+ target_ext = 'module.c'\n+ target_dir = self.build_temp\n+ print 'target_dir', target_dir\n+ \n+ for source in sources:\n+ (base, source_ext) = os.path.splitext(source)\n+ (source_dir, base) = os.path.split(base)\n+ if source_ext == \".pyf\": # f2py interface file\n+ target_file = os.path.join(target_dir,base+target_ext)\n+ new_sources.append(target_file)\n+ f2py_sources.append(source)\n+ f2py_targets[source] = new_sources[-1]\n+ else:\n+ new_sources.append(source)\n+\n+ if not f2py_sources:\n+ return new_sources\n+\n+ # a bit of a hack, but I think it'll work. Just include one of\n+ # the fortranobject.c files that was copied into most \n+ d = os.path.dirname(f2py2e.__file__)\n+ new_sources.append(os.path.join(d,'src','fortranobject.c'))\n+ self.include_dirs.append(os.path.join(d,'src'))\n+\n+ f2py_opts = []\n+ f2py_options = ext.f2py_options + self.f2py_options\n+ for i in f2py_options:\n+ f2py_opts.append('--'+i)\n+ f2py_opts = ['--build-dir',target_dir] + f2py_opts\n+ \n+ # make sure the target dir exists\n+ from distutils.dir_util import mkpath\n+ mkpath(target_dir)\n+\n+ for source in f2py_sources:\n+ target = f2py_targets[source]\n+ if newer(source,target):\n+ self.announce(\"f2py-ing %s to %s\" % (source, target))\n+ self.announce(\"f2py-args: %s\" % f2py_options)\n+ f2py2e.run_main(f2py_opts + [source])\n+ \n+ return new_sources\n+ # f2py_sources ()\n \n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n@@ -58,3 +266,92 @@ def get_source_files (self):\n filenames.extend(get_headers(get_directories(ext.sources)))\n \n return filenames\n+\n+ def check_extensions_list (self, extensions):\n+ \"\"\"\n+ Very slightly modified to add f2py_options as a flag... argh.\n+ \n+ Ensure that the list of extensions (presumably provided as a\n+ command option 'extensions') is valid, i.e. it is a list of\n+ Extension objects. We also support the old-style list of 2-tuples,\n+ where the tuples are (ext_name, build_info), which are converted to\n+ Extension instances here.\n+\n+ Raise DistutilsSetupError if the structure is invalid anywhere;\n+ just returns otherwise.\n+ \"\"\"\n+ if type(extensions) is not ListType:\n+ raise DistutilsSetupError, \\\n+ \"'ext_modules' option must be a list of Extension instances\"\n+ \n+ for i in range(len(extensions)):\n+ ext = extensions[i]\n+ if isinstance(ext, Extension):\n+ continue # OK! (assume type-checking done\n+ # by Extension constructor)\n+\n+ (ext_name, build_info) = ext\n+ self.warn((\"old-style (ext_name, build_info) tuple found in \"\n+ \"ext_modules for extension '%s'\" \n+ \"-- please convert to Extension instance\" % ext_name))\n+ if type(ext) is not TupleType and len(ext) != 2:\n+ raise DistutilsSetupError, \\\n+ (\"each element of 'ext_modules' option must be an \"\n+ \"Extension instance or 2-tuple\")\n+\n+ if not (type(ext_name) is StringType and\n+ extension_name_re.match(ext_name)):\n+ raise DistutilsSetupError, \\\n+ (\"first element of each tuple in 'ext_modules' \"\n+ \"must be the extension name (a string)\")\n+\n+ if type(build_info) is not DictionaryType:\n+ raise DistutilsSetupError, \\\n+ (\"second element of each tuple in 'ext_modules' \"\n+ \"must be a dictionary (build info)\")\n+\n+ # OK, the (ext_name, build_info) dict is type-safe: convert it\n+ # to an Extension instance.\n+ ext = Extension(ext_name, build_info['sources'])\n+\n+ # Easy stuff: one-to-one mapping from dict elements to\n+ # instance attributes.\n+ for key in ('include_dirs',\n+ 'library_dirs',\n+ 'libraries',\n+ 'extra_objects',\n+ 'extra_compile_args',\n+ 'extra_link_args',\n+ 'f2py_options'):\n+ val = build_info.get(key)\n+ if val is not None:\n+ setattr(ext, key, val)\n+\n+ # Medium-easy stuff: same syntax/semantics, different names.\n+ ext.runtime_library_dirs = build_info.get('rpath')\n+ if build_info.has_key('def_file'):\n+ self.warn(\"'def_file' element of build info dict \"\n+ \"no longer supported\")\n+\n+ # Non-trivial stuff: 'macros' split into 'define_macros'\n+ # and 'undef_macros'.\n+ macros = build_info.get('macros')\n+ if macros:\n+ ext.define_macros = []\n+ ext.undef_macros = []\n+ for macro in macros:\n+ if not (type(macro) is TupleType and\n+ 1 <= len(macro) <= 2):\n+ raise DistutilsSetupError, \\\n+ (\"'macros' element of build info dict \"\n+ \"must be 1- or 2-tuple\")\n+ if len(macro) == 1:\n+ ext.undef_macros.append(macro[0])\n+ elif len(macro) == 2:\n+ ext.define_macros.append(macro)\n+\n+ extensions[i] = ext\n+\n+ # for extensions\n+\n+ # check_extensions_list ()\n", "added_lines": 300, "deleted_lines": 3, "source_code": "\"\"\" Modified version of build_ext that handles fortran source files and f2py \n\n The f2py_sources() method is pretty much a copy of the swig_sources()\n method in the standard build_ext class , but modified to use f2py. It\n also.\n \n slightly_modified_standard_build_extension() is a verbatim copy of\n the standard build_extension() method with a single line changed so that\n preprocess_sources() is called instead of just swig_sources(). This new\n function is a nice place to stick any source code preprocessing functions\n needed.\n \n build_extension() handles building any needed static fortran libraries\n first and then calls our slightly_modified_..._extenstion() to do the\n rest of the processing in the (mostly) standard way. \n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import *\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nclass build_ext (old_build_ext):\n user_options = old_build_ext.user_options + \\\n [('f2py-options=', None,\n \"command line arguments to f2py\")]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.f2py_options = None\n\n def finalize_options (self): \n old_build_ext.finalize_options(self)\n if self.f2py_options is None:\n self.f2py_options = []\n \n def run (self):\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.libraries.extend(build_flib.get_library_names() or [])\n self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #runtime_dirs = build_flib.get_runtime_library_dirs()\n #self.runtime_library_dirs.extend(runtime_dirs or [])\n \n #?? what is this ??\n self.library_dirs.append(build_flib.build_flib)\n \n old_build_ext.run(self)\n\n def preprocess_sources(self,sources,ext):\n sources = self.swig_sources(sources)\n if self.has_f2py_sources(sources): \n sources = self.f2py_sources(sources,ext)\n return sources\n \n def extra_include_dirs(self,sources):\n if self.has_f2py_sources(sources): \n import f2py2e\n d = os.path.dirname(f2py2e.__file__)\n return [os.path.join(d,'src')]\n else:\n return [] \n \n def build_extension(self, ext):\n # support for building static fortran libraries\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []: \n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n # be sure to include fortran runtime library directory names\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n linker_so = build_flib.fcompiler.get_linker_so()\n if linker_so is not None:\n self.compiler.linker_so = linker_so\n # end of fortran source support\n # f2py support handled slightly_modified..._extenstion.\n return self.slightly_modified_standard_build_extension(ext)\n \n def slightly_modified_standard_build_extension(self, ext):\n \"\"\"\n This is pretty much a verbatim copy of the build_extension()\n function in distutils with a single change to make it possible\n to pre-process f2py as well as swig source files before \n compilation.\n \"\"\"\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 # ignore build-lib -- put the compiled extension into\n # the source tree along with pure Python modules\n\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\n if not (self.force or newer_group(sources, ext_filename, 'newer')):\n self.announce(\"skipping '%s' extension (up-to-date)\" %\n ext.name)\n return\n else:\n self.announce(\"building '%s' extension\" % ext.name)\n\n # I copied this hole stinken function just to change from\n # self.swig_sources to self.preprocess_sources...\n # ! must come before the next line!!\n include_dirs = self.extra_include_dirs(sources) + \\\n (ext.include_dirs or [])\n sources = self.preprocess_sources(sources, ext)\n \n # Next, compile the source code to object files.\n\n # XXX not honouring 'define_macros' or 'undef_macros' -- the\n # CCompiler API needs to change to accommodate this, and I\n # want to do one thing at a time!\n\n # Two possible sources for extra compiler arguments:\n # - 'extra_compile_args' in Extension object\n # - CFLAGS environment variable (not particularly\n # elegant, but people seem to expect it and I\n # guess it's useful)\n # The environment variable should take precedence, and\n # any sensible compiler will give precedence to later\n # command line args. Hence we combine them in order:\n extra_args = ext.extra_compile_args or []\n\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n # XXX and if we support CFLAGS, why not CC (compiler\n # executable), CPPFLAGS (pre-processor options), and LDFLAGS\n # (linker options) too?\n # XXX should we use shlex to properly parse CFLAGS?\n\n if os.environ.has_key('CFLAGS'):\n extra_args.extend(string.split(os.environ['CFLAGS']))\n\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_args)\n\n # Now link the object files together into a \"shared object\" --\n # of course, first we have to figure out all the other things\n # that go into the mix.\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n\n self.compiler.link_shared_object(\n 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)\n\n def has_f2py_sources (self, sources):\n print sources\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == \".pyf\": # f2py interface file\n return 1\n print 'no!' \n return 0\n \n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) files.\n \"\"\"\n\n import f2py2e\n\n new_sources = []\n new_include_dirs = []\n f2py_sources = []\n f2py_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n target_dir = self.build_temp\n print 'target_dir', target_dir\n \n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n target_file = os.path.join(target_dir,base+target_ext)\n new_sources.append(target_file)\n f2py_sources.append(source)\n f2py_targets[source] = new_sources[-1]\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n self.include_dirs.append(os.path.join(d,'src'))\n\n f2py_opts = []\n f2py_options = ext.f2py_options + self.f2py_options\n for i in f2py_options:\n f2py_opts.append('--'+i)\n f2py_opts = ['--build-dir',target_dir] + f2py_opts\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target):\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_opts + [source])\n \n return new_sources\n # f2py_sources ()\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n def check_extensions_list (self, extensions):\n \"\"\"\n Very slightly modified to add f2py_options as a flag... argh.\n \n Ensure that the list of extensions (presumably provided as a\n command option 'extensions') is valid, i.e. it is a list of\n Extension objects. We also support the old-style list of 2-tuples,\n where the tuples are (ext_name, build_info), which are converted to\n Extension instances here.\n\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\n \"\"\"\n if type(extensions) is not ListType:\n raise DistutilsSetupError, \\\n \"'ext_modules' option must be a list of Extension instances\"\n \n for i in range(len(extensions)):\n ext = extensions[i]\n if isinstance(ext, Extension):\n continue # OK! (assume type-checking done\n # by Extension constructor)\n\n (ext_name, build_info) = ext\n self.warn((\"old-style (ext_name, build_info) tuple found in \"\n \"ext_modules for extension '%s'\" \n \"-- please convert to Extension instance\" % ext_name))\n if type(ext) is not TupleType and len(ext) != 2:\n raise DistutilsSetupError, \\\n (\"each element of 'ext_modules' option must be an \"\n \"Extension instance or 2-tuple\")\n\n if not (type(ext_name) is StringType and\n extension_name_re.match(ext_name)):\n raise DistutilsSetupError, \\\n (\"first element of each tuple in 'ext_modules' \"\n \"must be the extension name (a string)\")\n\n if type(build_info) is not DictionaryType:\n raise DistutilsSetupError, \\\n (\"second element of each tuple in 'ext_modules' \"\n \"must be a dictionary (build info)\")\n\n # OK, the (ext_name, build_info) dict is type-safe: convert it\n # to an Extension instance.\n ext = Extension(ext_name, build_info['sources'])\n\n # Easy stuff: one-to-one mapping from dict elements to\n # instance attributes.\n for key in ('include_dirs',\n 'library_dirs',\n 'libraries',\n 'extra_objects',\n 'extra_compile_args',\n 'extra_link_args',\n 'f2py_options'):\n val = build_info.get(key)\n if val is not None:\n setattr(ext, key, val)\n\n # Medium-easy stuff: same syntax/semantics, different names.\n ext.runtime_library_dirs = build_info.get('rpath')\n if build_info.has_key('def_file'):\n self.warn(\"'def_file' element of build info dict \"\n \"no longer supported\")\n\n # Non-trivial stuff: 'macros' split into 'define_macros'\n # and 'undef_macros'.\n macros = build_info.get('macros')\n if macros:\n ext.define_macros = []\n ext.undef_macros = []\n for macro in macros:\n if not (type(macro) is TupleType and\n 1 <= len(macro) <= 2):\n raise DistutilsSetupError, \\\n (\"'macros' element of build info dict \"\n \"must be 1- or 2-tuple\")\n if len(macro) == 1:\n ext.undef_macros.append(macro[0])\n elif len(macro) == 2:\n ext.define_macros.append(macro)\n\n extensions[i] = ext\n\n # for extensions\n\n # check_extensions_list ()\n", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files and f2py \n\n build_extension() handles building any needed static fortran libraries\n first and then calls our slightly_modified_..._extenstion() to do the\n rest of the processing in the (mostly) standard way. \n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import *\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nclass build_ext (old_build_ext):\n\n def run (self):\n\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.libraries.extend(build_flib.get_library_names() or [])\n self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #runtime_dirs = build_flib.get_runtime_library_dirs()\n #self.runtime_library_dirs.extend(runtime_dirs or [])\n \n #?? what is this ??\n self.library_dirs.append(build_flib.build_flib)\n \n old_build_ext.run(self)\n \n def build_extension(self, ext):\n # support for building static fortran libraries\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []: \n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n # be sure to include fortran runtime library directory names\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n linker_so = build_flib.fcompiler.get_linker_so()\n if linker_so is not None:\n self.compiler.linker_so = linker_so\n # end of fortran source support\n return old_build_ext.build_extension(self,ext)\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 34, "end_line": 37, "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": 7, "complexity": 4, "token_count": 68, "parameters": [ "self" ], "start_line": 39, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "preprocess_sources", "long_name": "preprocess_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "sources", "ext" ], "start_line": 53, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "extra_include_dirs", "long_name": "extra_include_dirs( self , sources )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "sources" ], "start_line": 59, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 15, "complexity": 6, "token_count": 105, "parameters": [ "self", "ext" ], "start_line": 67, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "slightly_modified_standard_build_extension", "long_name": "slightly_modified_standard_build_extension( self , ext )", "filename": "build_ext.py", "nloc": 53, "complexity": 12, "token_count": 390, "parameters": [ "self", "ext" ], "start_line": 87, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 98, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self , sources )", "filename": "build_ext.py", "nloc": 8, "complexity": 3, "token_count": 39, "parameters": [ "self", "sources" ], "start_line": 186, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 38, "complexity": 7, "token_count": 270, "parameters": [ "self", "sources", "ext" ], "start_line": 195, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 259, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_extensions_list", "long_name": "check_extensions_list( self , extensions )", "filename": "build_ext.py", "nloc": 55, "complexity": 18, "token_count": 308, "parameters": [ "self", "extensions" ], "start_line": 270, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 1 } ], "methods_before": [ { "name": "run", "long_name": "run( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 4, "token_count": 68, "parameters": [ "self" ], "start_line": 17, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 15, "complexity": 6, "token_count": 107, "parameters": [ "self", "ext" ], "start_line": 32, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 51, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 15, "complexity": 6, "token_count": 105, "parameters": [ "self", "ext" ], "start_line": 67, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "check_extensions_list", "long_name": "check_extensions_list( self , extensions )", "filename": "build_ext.py", "nloc": 55, "complexity": 18, "token_count": 308, "parameters": [ "self", "extensions" ], "start_line": 270, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 1 }, { "name": "preprocess_sources", "long_name": "preprocess_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "sources", "ext" ], "start_line": 53, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 34, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self , sources )", "filename": "build_ext.py", "nloc": 8, "complexity": 3, "token_count": 39, "parameters": [ "self", "sources" ], "start_line": 186, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 38, "complexity": 7, "token_count": 270, "parameters": [ "self", "sources", "ext" ], "start_line": 195, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 1 }, { "name": "slightly_modified_standard_build_extension", "long_name": "slightly_modified_standard_build_extension( self , ext )", "filename": "build_ext.py", "nloc": 53, "complexity": 12, "token_count": 390, "parameters": [ "self", "ext" ], "start_line": 87, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 98, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 4, "token_count": 68, "parameters": [ "self" ], "start_line": 39, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "extra_include_dirs", "long_name": "extra_include_dirs( self , sources )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "sources" ], "start_line": 59, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "nloc": 227, "complexity": 59, "token_count": 1420, "diff_parsed": { "added": [ " The f2py_sources() method is pretty much a copy of the swig_sources()", " method in the standard build_ext class , but modified to use f2py. It", " also.", "", " slightly_modified_standard_build_extension() is a verbatim copy of", " the standard build_extension() method with a single line changed so that", " preprocess_sources() is called instead of just swig_sources(). This new", " function is a nice place to stick any source code preprocessing functions", " needed.", "", " user_options = old_build_ext.user_options + \\", " [('f2py-options=', None,", " \"command line arguments to f2py\")]", " def initialize_options(self):", " old_build_ext.initialize_options(self)", " self.f2py_options = None", " def finalize_options (self):", " old_build_ext.finalize_options(self)", " if self.f2py_options is None:", " self.f2py_options = []", "", " def run (self):", "", " def preprocess_sources(self,sources,ext):", " sources = self.swig_sources(sources)", " if self.has_f2py_sources(sources):", " sources = self.f2py_sources(sources,ext)", " return sources", "", " def extra_include_dirs(self,sources):", " if self.has_f2py_sources(sources):", " import f2py2e", " d = os.path.dirname(f2py2e.__file__)", " return [os.path.join(d,'src')]", " else:", " return []", "", " # f2py support handled slightly_modified..._extenstion.", " return self.slightly_modified_standard_build_extension(ext)", "", " def slightly_modified_standard_build_extension(self, ext):", " \"\"\"", " This is pretty much a verbatim copy of the build_extension()", " function in distutils with a single change to make it possible", " to pre-process f2py as well as swig source files before", " compilation.", " \"\"\"", " sources = ext.sources", " if sources is None or type(sources) not in (ListType, TupleType):", " raise DistutilsSetupError, \\", " (\"in 'ext_modules' option (extension '%s'), \" +", " \"'sources' must be present and must be \" +", " \"a list of source filenames\") % ext.name", " sources = list(sources)", "", " fullname = self.get_ext_fullname(ext.name)", " if self.inplace:", " # ignore build-lib -- put the compiled extension into", " # the source tree along with pure Python modules", "", " modpath = string.split(fullname, '.')", " package = string.join(modpath[0:-1], '.')", " base = modpath[-1]", "", " build_py = self.get_finalized_command('build_py')", " package_dir = build_py.get_package_dir(package)", " ext_filename = os.path.join(package_dir,", " self.get_ext_filename(base))", " else:", " ext_filename = os.path.join(self.build_lib,", " self.get_ext_filename(fullname))", "", " if not (self.force or newer_group(sources, ext_filename, 'newer')):", " self.announce(\"skipping '%s' extension (up-to-date)\" %", " ext.name)", " return", " else:", " self.announce(\"building '%s' extension\" % ext.name)", "", " # I copied this hole stinken function just to change from", " # self.swig_sources to self.preprocess_sources...", " # ! must come before the next line!!", " include_dirs = self.extra_include_dirs(sources) + \\", " (ext.include_dirs or [])", " sources = self.preprocess_sources(sources, ext)", "", " # Next, compile the source code to object files.", "", " # XXX not honouring 'define_macros' or 'undef_macros' -- the", " # CCompiler API needs to change to accommodate this, and I", " # want to do one thing at a time!", "", " # Two possible sources for extra compiler arguments:", " # - 'extra_compile_args' in Extension object", " # - CFLAGS environment variable (not particularly", " # elegant, but people seem to expect it and I", " # guess it's useful)", " # The environment variable should take precedence, and", " # any sensible compiler will give precedence to later", " # command line args. Hence we combine them in order:", " extra_args = ext.extra_compile_args or []", "", " macros = ext.define_macros[:]", " for undef in ext.undef_macros:", " macros.append((undef,))", "", " # XXX and if we support CFLAGS, why not CC (compiler", " # executable), CPPFLAGS (pre-processor options), and LDFLAGS", " # (linker options) too?", " # XXX should we use shlex to properly parse CFLAGS?", "", " if os.environ.has_key('CFLAGS'):", " extra_args.extend(string.split(os.environ['CFLAGS']))", "", " objects = self.compiler.compile(sources,", " output_dir=self.build_temp,", " macros=macros,", " include_dirs=include_dirs,", " debug=self.debug,", " extra_postargs=extra_args)", "", " # Now link the object files together into a \"shared object\" --", " # of course, first we have to figure out all the other things", " # that go into the mix.", " if ext.extra_objects:", " objects.extend(ext.extra_objects)", " extra_args = ext.extra_link_args or []", "", "", " self.compiler.link_shared_object(", " objects, ext_filename,", " libraries=self.get_libraries(ext),", " library_dirs=ext.library_dirs,", " runtime_library_dirs=ext.runtime_library_dirs,", " extra_postargs=extra_args,", " export_symbols=self.get_export_symbols(ext),", " debug=self.debug,", " build_temp=self.build_temp)", "", " def has_f2py_sources (self, sources):", " print sources", " for source in sources:", " (base, ext) = os.path.splitext(source)", " if ext == \".pyf\": # f2py interface file", " return 1", " print 'no!'", " return 0", "", " def f2py_sources (self, sources, ext):", "", " \"\"\"Walk the list of source files in 'sources', looking for f2py", " interface (.pyf) files. Run f2py on all that are found, and", " return a modified 'sources' list with f2py source files replaced", " by the generated C (or C++) files.", " \"\"\"", "", " import f2py2e", "", " new_sources = []", " new_include_dirs = []", " f2py_sources = []", " f2py_targets = {}", "", " # XXX this drops generated C/C++ files into the source tree, which", " # is fine for developers who want to distribute the generated", " # source -- but there should be an option to put f2py output in", " # the temp dir.", "", " target_ext = 'module.c'", " target_dir = self.build_temp", " print 'target_dir', target_dir", "", " for source in sources:", " (base, source_ext) = os.path.splitext(source)", " (source_dir, base) = os.path.split(base)", " if source_ext == \".pyf\": # f2py interface file", " target_file = os.path.join(target_dir,base+target_ext)", " new_sources.append(target_file)", " f2py_sources.append(source)", " f2py_targets[source] = new_sources[-1]", " else:", " new_sources.append(source)", "", " if not f2py_sources:", " return new_sources", "", " # a bit of a hack, but I think it'll work. Just include one of", " # the fortranobject.c files that was copied into most", " d = os.path.dirname(f2py2e.__file__)", " new_sources.append(os.path.join(d,'src','fortranobject.c'))", " self.include_dirs.append(os.path.join(d,'src'))", "", " f2py_opts = []", " f2py_options = ext.f2py_options + self.f2py_options", " for i in f2py_options:", " f2py_opts.append('--'+i)", " f2py_opts = ['--build-dir',target_dir] + f2py_opts", "", " # make sure the target dir exists", " from distutils.dir_util import mkpath", " mkpath(target_dir)", "", " for source in f2py_sources:", " target = f2py_targets[source]", " if newer(source,target):", " self.announce(\"f2py-ing %s to %s\" % (source, target))", " self.announce(\"f2py-args: %s\" % f2py_options)", " f2py2e.run_main(f2py_opts + [source])", "", " return new_sources", " # f2py_sources ()", "", " def check_extensions_list (self, extensions):", " \"\"\"", " Very slightly modified to add f2py_options as a flag... argh.", "", " Ensure that the list of extensions (presumably provided as a", " command option 'extensions') is valid, i.e. it is a list of", " Extension objects. We also support the old-style list of 2-tuples,", " where the tuples are (ext_name, build_info), which are converted to", " Extension instances here.", "", " Raise DistutilsSetupError if the structure is invalid anywhere;", " just returns otherwise.", " \"\"\"", " if type(extensions) is not ListType:", " raise DistutilsSetupError, \\", " \"'ext_modules' option must be a list of Extension instances\"", "", " for i in range(len(extensions)):", " ext = extensions[i]", " if isinstance(ext, Extension):", " continue # OK! (assume type-checking done", " # by Extension constructor)", "", " (ext_name, build_info) = ext", " self.warn((\"old-style (ext_name, build_info) tuple found in \"", " \"ext_modules for extension '%s'\"", " \"-- please convert to Extension instance\" % ext_name))", " if type(ext) is not TupleType and len(ext) != 2:", " raise DistutilsSetupError, \\", " (\"each element of 'ext_modules' option must be an \"", " \"Extension instance or 2-tuple\")", "", " if not (type(ext_name) is StringType and", " extension_name_re.match(ext_name)):", " raise DistutilsSetupError, \\", " (\"first element of each tuple in 'ext_modules' \"", " \"must be the extension name (a string)\")", "", " if type(build_info) is not DictionaryType:", " raise DistutilsSetupError, \\", " (\"second element of each tuple in 'ext_modules' \"", " \"must be a dictionary (build info)\")", "", " # OK, the (ext_name, build_info) dict is type-safe: convert it", " # to an Extension instance.", " ext = Extension(ext_name, build_info['sources'])", "", " # Easy stuff: one-to-one mapping from dict elements to", " # instance attributes.", " for key in ('include_dirs',", " 'library_dirs',", " 'libraries',", " 'extra_objects',", " 'extra_compile_args',", " 'extra_link_args',", " 'f2py_options'):", " val = build_info.get(key)", " if val is not None:", " setattr(ext, key, val)", "", " # Medium-easy stuff: same syntax/semantics, different names.", " ext.runtime_library_dirs = build_info.get('rpath')", " if build_info.has_key('def_file'):", " self.warn(\"'def_file' element of build info dict \"", " \"no longer supported\")", "", " # Non-trivial stuff: 'macros' split into 'define_macros'", " # and 'undef_macros'.", " macros = build_info.get('macros')", " if macros:", " ext.define_macros = []", " ext.undef_macros = []", " for macro in macros:", " if not (type(macro) is TupleType and", " 1 <= len(macro) <= 2):", " raise DistutilsSetupError, \\", " (\"'macros' element of build info dict \"", " \"must be 1- or 2-tuple\")", " if len(macro) == 1:", " ext.undef_macros.append(macro[0])", " elif len(macro) == 2:", " ext.define_macros.append(macro)", "", " extensions[i] = ext", "", " # for extensions", "", " # check_extensions_list ()" ], "deleted": [ " def run (self):", "", " return old_build_ext.build_extension(self,ext)" ] } }, { "old_path": "scipy_distutils/core.py", "new_path": "scipy_distutils/core.py", "filename": "core.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -2,7 +2,7 @@\n from distutils.core import setup as old_setup\n \n from distutils.cmd import Command\n-from distutils.extension import Extension\n+from scipy_distutils.extension import Extension\n \n # Our dist is different than the standard one.\n from scipy_distutils.dist import Distribution\n", "added_lines": 1, "deleted_lines": 1, "source_code": "from distutils.core import *\nfrom distutils.core import setup as old_setup\n\nfrom distutils.cmd import Command\nfrom scipy_distutils.extension import Extension\n\n# Our dist is different than the standard one.\nfrom scipy_distutils.dist import Distribution\n\nfrom scipy_distutils.command import build\nfrom scipy_distutils.command import build_py\nfrom scipy_distutils.command import build_ext\nfrom scipy_distutils.command import build_clib\nfrom scipy_distutils.command import build_flib\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\ndef setup(**attr):\n distclass = Distribution\n cmdclass = {'build': build.build,\n 'build_flib': build_flib.build_flib,\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 \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 return old_setup(**new_attr)\n", "source_code_before": "from distutils.core import *\nfrom distutils.core import setup as old_setup\n\nfrom distutils.cmd import Command\nfrom distutils.extension import Extension\n\n# Our dist is different than the standard one.\nfrom scipy_distutils.dist import Distribution\n\nfrom scipy_distutils.command import build\nfrom scipy_distutils.command import build_py\nfrom scipy_distutils.command import build_ext\nfrom scipy_distutils.command import build_clib\nfrom scipy_distutils.command import build_flib\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\ndef setup(**attr):\n distclass = Distribution\n cmdclass = {'build': build.build,\n 'build_flib': build_flib.build_flib,\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 \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 return old_setup(**new_attr)\n", "methods": [ { "name": "setup", "long_name": "setup( ** attr )", "filename": "core.py", "nloc": 19, "complexity": 3, "token_count": 117, "parameters": [ "attr" ], "start_line": 20, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "methods_before": [ { "name": "setup", "long_name": "setup( ** attr )", "filename": "core.py", "nloc": 19, "complexity": 3, "token_count": 117, "parameters": [ "attr" ], "start_line": 20, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 33, "complexity": 3, "token_count": 204, "diff_parsed": { "added": [ "from scipy_distutils.extension import Extension" ], "deleted": [ "from distutils.extension import Extension" ] } }, { "old_path": "scipy_distutils/misc_util.py", "new_path": "scipy_distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -231,3 +231,69 @@ def merge_config_dicts(config_list):\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n+\n+def pyf_extensions(parent_package = '',\n+ sources = [],\n+ include_dirs = [],\n+ define_macros = [],\n+ undef_macros = [],\n+ library_dirs = [],\n+ libraries = [],\n+ runtime_library_dirs = [],\n+ extra_objects = [],\n+ extra_compile_args = [],\n+ extra_link_args = [],\n+ export_symbols = [],\n+ f2py_options = [],\n+ f2py_wrap_functions = 1,\n+ f2py_debug_capi = 0,\n+ f2py_build_dir = '.',\n+ ):\n+ \"\"\" Return a list of Extension instances defined by .pyf files listed\n+ in sources list.\n+ \n+ f2py_opts is a list of options passed to the f2py runner.\n+ Option --no-setup is forced. Other possible options are\n+ --build-dir \n+ --[no-]wrap-functions\n+ \n+ Note: This requires that f2py2e is installed on your machine\n+ \"\"\"\n+ from scipy_distutils.core import Extension\n+ import f2py2e \n+ \n+ if parent_package:\n+ parent_package = parent_package + '.' \n+ \n+ f2py_opts = f2py_options or []\n+ if not f2py_wrap_functions:\n+ f2py_opts.append('--no-wrap-functions')\n+ if f2py_debug_capi:\n+ f2py_opts.append('--debug-capi')\n+ if '--setup' not in f2py_opts:\n+ f2py_opts.append('--no-setup')\n+ f2py_opts.extend(['--build-dir',f2py_build_dir])\n+\n+ pyf_files, sources = f2py2e.f2py2e.filter_files('(?i)','[.]pyf',sources)\n+\n+ pyf = f2py2e.run_main(pyf_files+f2py_opts)\n+\n+ include_dirs = include_dirs + pyf.get_include_dirs()\n+ ext_modules = []\n+\n+ for name in pyf.get_names():\n+ ext = Extension(parent_package+name,\n+ pyf.get_sources(name) + sources,\n+ include_dirs = include_dirs,\n+ library_dirs = library_dirs,\n+ libraries = libraries,\n+ define_macros = define_macros,\n+ undef_macros = undef_macros,\n+ extra_objects = extra_objects,\n+ extra_compile_args = extra_compile_args,\n+ extra_link_args = extra_link_args,\n+ export_symbols = export_symbols,\n+ )\n+ ext_modules.append(ext)\n+\n+ return ext_modules\n", "added_lines": 66, "deleted_lines": 0, "source_code": "import os,sys,string\n\ndef update_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n overwrite_version_py = 1):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . If the version information is different from the one\n found in the /__version__.py file, update_version updates\n the file automatically. The version information will be always\n increasing in time.\n If CVS tree does not exist (e.g. as in distribution packages),\n return the version string found from /__version__.py.\n If no version information is available, return None.\n\n Default version string is in the form\n\n ..--\n\n The items have the following meanings:\n\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n\n \"\"\"\n # Open issues:\n # *** Recommend or not to add __version__.py file to CVS\n # repository? If it is in CVS, then when commiting, the\n # version information will change, but __version__.py\n # is commited with old version information to CVS. To get\n # __version__.py also up to date in CVS repository, \n # a second commit of the __version__.py file is required.\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version_dict = {'major':major,'minor':minor,'micro':micro,\n 'release_level':release_level,'serial':serial\n }\n version = version_template % version_dict\n\n if version != old_version:\n print 'version increase detected: %s -> %s'%(old_version,version)\n version_file = os.path.join(path,'__version__.py')\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n % (version_file)\n return version\n print 'updating version in %s' % version_file\n version_file = os.path.abspath(version_file)\n f = open(version_file,'w')\n f.write('# This file is automatically updated with get_version\\n'\\\n '# function from scipy_distutils.misc_utils.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n ):\n return update_version(release_level = release_level,path = path,\n version_template = version_template,\n major = major,overwrite_version_py = 0)\n\n\ndef get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n d1,d2 = map(eval,string.split(items[2],'.')[-2:])\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\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 #import scipy_distutils.setup\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\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() file 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():\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n return d\n\ndef merge_config_dicts(config_list):\n result = default_config_dict() \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 pyf_extensions(parent_package = '',\n sources = [],\n include_dirs = [],\n define_macros = [],\n undef_macros = [],\n library_dirs = [],\n libraries = [],\n runtime_library_dirs = [],\n extra_objects = [],\n extra_compile_args = [],\n extra_link_args = [],\n export_symbols = [],\n f2py_options = [],\n f2py_wrap_functions = 1,\n f2py_debug_capi = 0,\n f2py_build_dir = '.',\n ):\n \"\"\" Return a list of Extension instances defined by .pyf files listed\n in sources list.\n \n f2py_opts is a list of options passed to the f2py runner.\n Option --no-setup is forced. Other possible options are\n --build-dir \n --[no-]wrap-functions\n \n Note: This requires that f2py2e is installed on your machine\n \"\"\"\n from scipy_distutils.core import Extension\n import f2py2e \n \n if parent_package:\n parent_package = parent_package + '.' \n \n f2py_opts = f2py_options or []\n if not f2py_wrap_functions:\n f2py_opts.append('--no-wrap-functions')\n if f2py_debug_capi:\n f2py_opts.append('--debug-capi')\n if '--setup' not in f2py_opts:\n f2py_opts.append('--no-setup')\n f2py_opts.extend(['--build-dir',f2py_build_dir])\n\n pyf_files, sources = f2py2e.f2py2e.filter_files('(?i)','[.]pyf',sources)\n\n pyf = f2py2e.run_main(pyf_files+f2py_opts)\n\n include_dirs = include_dirs + pyf.get_include_dirs()\n ext_modules = []\n\n for name in pyf.get_names():\n ext = Extension(parent_package+name,\n pyf.get_sources(name) + sources,\n include_dirs = include_dirs,\n library_dirs = library_dirs,\n libraries = libraries,\n define_macros = define_macros,\n undef_macros = undef_macros,\n extra_objects = extra_objects,\n extra_compile_args = extra_compile_args,\n extra_link_args = extra_link_args,\n export_symbols = export_symbols,\n )\n ext_modules.append(ext)\n\n return ext_modules\n", "source_code_before": "import os,sys,string\n\ndef update_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n overwrite_version_py = 1):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . If the version information is different from the one\n found in the /__version__.py file, update_version updates\n the file automatically. The version information will be always\n increasing in time.\n If CVS tree does not exist (e.g. as in distribution packages),\n return the version string found from /__version__.py.\n If no version information is available, return None.\n\n Default version string is in the form\n\n ..--\n\n The items have the following meanings:\n\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n\n \"\"\"\n # Open issues:\n # *** Recommend or not to add __version__.py file to CVS\n # repository? If it is in CVS, then when commiting, the\n # version information will change, but __version__.py\n # is commited with old version information to CVS. To get\n # __version__.py also up to date in CVS repository, \n # a second commit of the __version__.py file is required.\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version_dict = {'major':major,'minor':minor,'micro':micro,\n 'release_level':release_level,'serial':serial\n }\n version = version_template % version_dict\n\n if version != old_version:\n print 'version increase detected: %s -> %s'%(old_version,version)\n version_file = os.path.join(path,'__version__.py')\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n % (version_file)\n return version\n print 'updating version in %s' % version_file\n version_file = os.path.abspath(version_file)\n f = open(version_file,'w')\n f.write('# This file is automatically updated with get_version\\n'\\\n '# function from scipy_distutils.misc_utils.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n ):\n return update_version(release_level = release_level,path = path,\n version_template = version_template,\n major = major,overwrite_version_py = 0)\n\n\ndef get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n d1,d2 = map(eval,string.split(items[2],'.')[-2:])\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\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 #import scipy_distutils.setup\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\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() file 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():\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n return d\n\ndef merge_config_dicts(config_list):\n result = default_config_dict() \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", "methods": [ { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 65, "complexity": 12, "token_count": 351, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 3, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 103, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 44, "parameters": [ "release_level", "path", "major" ], "start_line": 107, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 17, "complexity": 9, "token_count": 170, "parameters": [ "path" ], "start_line": 118, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 143, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 161, "end_line": 163, "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": 165, "end_line": 168, "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": 170, "end_line": 171, "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": 173, "end_line": 187, "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": 189, "end_line": 199, "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": 201, "end_line": 213, "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( )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 34, "parameters": [], "start_line": 220, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 226, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "pyf_extensions", "long_name": "pyf_extensions( parent_package = '' , sources = [ ] , include_dirs = [ ] , define_macros = [ ] , undef_macros = [ ] , library_dirs = [ ] , libraries = [ ] , runtime_library_dirs = [ ] , extra_objects = [ ] , extra_compile_args = [ ] , extra_link_args = [ ] , export_symbols = [ ] , f2py_options = [ ] , f2py_wrap_functions = 1 , f2py_debug_capi = 0 , f2py_build_dir = '.' , )", "filename": "misc_util.py", "nloc": 48, "complexity": 7, "token_count": 254, "parameters": [ "parent_package", "sources", "include_dirs", "define_macros", "undef_macros", "library_dirs", "libraries", "runtime_library_dirs", "extra_objects", "extra_compile_args", "extra_link_args", "export_symbols", "f2py_options", "f2py_wrap_functions", "f2py_debug_capi", "f2py_build_dir" ], "start_line": 235, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 0 } ], "methods_before": [ { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 65, "complexity": 12, "token_count": 351, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 3, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 103, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 44, "parameters": [ "release_level", "path", "major" ], "start_line": 107, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 17, "complexity": 9, "token_count": 170, "parameters": [ "path" ], "start_line": 118, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 143, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 161, "end_line": 163, "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": 165, "end_line": 168, "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": 170, "end_line": 171, "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": 173, "end_line": 187, "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": 189, "end_line": 199, "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": 201, "end_line": 213, "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( )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 34, "parameters": [], "start_line": 220, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 226, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "pyf_extensions", "long_name": "pyf_extensions( parent_package = '' , sources = [ ] , include_dirs = [ ] , define_macros = [ ] , undef_macros = [ ] , library_dirs = [ ] , libraries = [ ] , runtime_library_dirs = [ ] , extra_objects = [ ] , extra_compile_args = [ ] , extra_link_args = [ ] , export_symbols = [ ] , f2py_options = [ ] , f2py_wrap_functions = 1 , f2py_debug_capi = 0 , f2py_build_dir = '.' , )", "filename": "misc_util.py", "nloc": 48, "complexity": 7, "token_count": 254, "parameters": [ "parent_package", "sources", "include_dirs", "define_macros", "undef_macros", "library_dirs", "libraries", "runtime_library_dirs", "extra_objects", "extra_compile_args", "extra_link_args", "export_symbols", "f2py_options", "f2py_wrap_functions", "f2py_debug_capi", "f2py_build_dir" ], "start_line": 235, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 0 } ], "nloc": 193, "complexity": 49, "token_count": 1245, "diff_parsed": { "added": [ "", "def pyf_extensions(parent_package = '',", " sources = [],", " include_dirs = [],", " define_macros = [],", " undef_macros = [],", " library_dirs = [],", " libraries = [],", " runtime_library_dirs = [],", " extra_objects = [],", " extra_compile_args = [],", " extra_link_args = [],", " export_symbols = [],", " f2py_options = [],", " f2py_wrap_functions = 1,", " f2py_debug_capi = 0,", " f2py_build_dir = '.',", " ):", " \"\"\" Return a list of Extension instances defined by .pyf files listed", " in sources list.", "", " f2py_opts is a list of options passed to the f2py runner.", " Option --no-setup is forced. Other possible options are", " --build-dir ", " --[no-]wrap-functions", "", " Note: This requires that f2py2e is installed on your machine", " \"\"\"", " from scipy_distutils.core import Extension", " import f2py2e", "", " if parent_package:", " parent_package = parent_package + '.'", "", " f2py_opts = f2py_options or []", " if not f2py_wrap_functions:", " f2py_opts.append('--no-wrap-functions')", " if f2py_debug_capi:", " f2py_opts.append('--debug-capi')", " if '--setup' not in f2py_opts:", " f2py_opts.append('--no-setup')", " f2py_opts.extend(['--build-dir',f2py_build_dir])", "", " pyf_files, sources = f2py2e.f2py2e.filter_files('(?i)','[.]pyf',sources)", "", " pyf = f2py2e.run_main(pyf_files+f2py_opts)", "", " include_dirs = include_dirs + pyf.get_include_dirs()", " ext_modules = []", "", " for name in pyf.get_names():", " ext = Extension(parent_package+name,", " pyf.get_sources(name) + sources,", " include_dirs = include_dirs,", " library_dirs = library_dirs,", " libraries = libraries,", " define_macros = define_macros,", " undef_macros = undef_macros,", " extra_objects = extra_objects,", " extra_compile_args = extra_compile_args,", " extra_link_args = extra_link_args,", " export_symbols = export_symbols,", " )", " ext_modules.append(ext)", "", " return ext_modules" ], "deleted": [] } } ] }, { "hash": "f2871d19ba37424270ccb2d0d5b937776de5542b", "msg": "extension needed for adding f2py_options keyword to Extension", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-01-09T06:45:56+00:00", "author_timezone": 0, "committer_date": "2002-01-09T06:45:56+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "10aaa27252b35120213cc7ef054167fe16bcff6f" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 0, "insertions": 42, "lines": 42, "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/extension.py", "filename": "extension.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,42 @@\n+\"\"\"distutils.extension\n+\n+Provides the Extension class, used to describe C/C++ extension\n+modules in setup scripts.\n+\n+Overridden to support f2py.\n+\"\"\"\n+\n+# created 2000/05/30, Greg Ward\n+\n+__revision__ = \"$Id$\"\n+\n+from distutils.extension import Extension as old_Extension\n+\n+class Extension(old_Extension):\n+ def __init__ (self, name, sources,\n+ include_dirs=None,\n+ define_macros=None,\n+ undef_macros=None,\n+ library_dirs=None,\n+ libraries=None,\n+ runtime_library_dirs=None,\n+ extra_objects=None,\n+ extra_compile_args=None,\n+ extra_link_args=None,\n+ export_symbols=None,\n+ f2py_options=None\n+ ):\n+ old_Extension.__init__(self,name, sources,\n+ include_dirs,\n+ define_macros,\n+ undef_macros,\n+ library_dirs,\n+ libraries,\n+ runtime_library_dirs,\n+ extra_objects,\n+ extra_compile_args,\n+ extra_link_args,\n+ export_symbols)\n+ self.f2py_options = f2py_options or []\n+ \n+# class Extension\n", "added_lines": 42, "deleted_lines": 0, "source_code": "\"\"\"distutils.extension\n\nProvides the Extension class, used to describe C/C++ extension\nmodules in setup scripts.\n\nOverridden to support f2py.\n\"\"\"\n\n# created 2000/05/30, Greg Ward\n\n__revision__ = \"$Id$\"\n\nfrom distutils.extension import Extension as old_Extension\n\nclass Extension(old_Extension):\n def __init__ (self, name, sources,\n include_dirs=None,\n define_macros=None,\n undef_macros=None,\n library_dirs=None,\n libraries=None,\n runtime_library_dirs=None,\n extra_objects=None,\n extra_compile_args=None,\n extra_link_args=None,\n export_symbols=None,\n f2py_options=None\n ):\n old_Extension.__init__(self,name, sources,\n include_dirs,\n define_macros,\n undef_macros,\n library_dirs,\n libraries,\n runtime_library_dirs,\n extra_objects,\n extra_compile_args,\n extra_link_args,\n export_symbols)\n self.f2py_options = f2py_options or []\n \n# class Extension\n", "source_code_before": null, "methods": [ { "name": "__init__", "long_name": "__init__( self , name , sources , include_dirs = None , define_macros = None , undef_macros = None , library_dirs = None , libraries = None , runtime_library_dirs = None , extra_objects = None , extra_compile_args = None , extra_link_args = None , export_symbols = None , f2py_options = None )", "filename": "extension.py", "nloc": 25, "complexity": 2, "token_count": 91, "parameters": [ "self", "name", "sources", "include_dirs", "define_macros", "undef_macros", "library_dirs", "libraries", "runtime_library_dirs", "extra_objects", "extra_compile_args", "extra_link_args", "export_symbols", "f2py_options" ], "start_line": 16, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 } ], "methods_before": [], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , name , sources , include_dirs = None , define_macros = None , undef_macros = None , library_dirs = None , libraries = None , runtime_library_dirs = None , extra_objects = None , extra_compile_args = None , extra_link_args = None , export_symbols = None , f2py_options = None )", "filename": "extension.py", "nloc": 25, "complexity": 2, "token_count": 91, "parameters": [ "self", "name", "sources", "include_dirs", "define_macros", "undef_macros", "library_dirs", "libraries", "runtime_library_dirs", "extra_objects", "extra_compile_args", "extra_link_args", "export_symbols", "f2py_options" ], "start_line": 16, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 } ], "nloc": 35, "complexity": 2, "token_count": 110, "diff_parsed": { "added": [ "\"\"\"distutils.extension", "", "Provides the Extension class, used to describe C/C++ extension", "modules in setup scripts.", "", "Overridden to support f2py.", "\"\"\"", "", "# created 2000/05/30, Greg Ward", "", "__revision__ = \"$Id$\"", "", "from distutils.extension import Extension as old_Extension", "", "class Extension(old_Extension):", " def __init__ (self, name, sources,", " include_dirs=None,", " define_macros=None,", " undef_macros=None,", " library_dirs=None,", " libraries=None,", " runtime_library_dirs=None,", " extra_objects=None,", " extra_compile_args=None,", " extra_link_args=None,", " export_symbols=None,", " f2py_options=None", " ):", " old_Extension.__init__(self,name, sources,", " include_dirs,", " define_macros,", " undef_macros,", " library_dirs,", " libraries,", " runtime_library_dirs,", " extra_objects,", " extra_compile_args,", " extra_link_args,", " export_symbols)", " self.f2py_options = f2py_options or []", "", "# class Extension" ], "deleted": [] } } ] }, { "hash": "3ded519e4c37afe434b596d687534933d94884a3", "msg": "added variable library_path to scipy_distutils.atlas_info to specify where atlas libraries live.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-01-09T06:57:04+00:00", "author_timezone": 0, "committer_date": "2002-01-09T06:57:04+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "f2871d19ba37424270ccb2d0d5b937776de5542b" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 7, "insertions": 16, "lines": 23, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/atlas_info.py", "new_path": "scipy_distutils/atlas_info.py", "filename": "atlas_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,12 +1,21 @@\n import sys, os\n \n+library_path = ''\n+\n def get_atlas_info():\n+ print 'atlas_lib:', library_path\n if sys.platform == 'win32':\n- atlas_library_dirs=['C:\\\\atlas\\\\WinNT_PIIISSE1']\n+ if not library_path:\n+ atlas_library_dirs=['C:\\\\atlas\\\\WinNT_PIIISSE1']\n+ else:\n+ atlas_library_dirs = library_path\n blas_libraries = ['f77blas', 'cblas', 'atlas', 'g2c']\n lapack_libraries = ['lapack'] + blas_libraries \n else:\n- atlas_library_dirs = unix_atlas_directory(plat)\n+ if not library_path:\n+ atlas_library_dirs = unix_atlas_directory(sys.platform)\n+ else:\n+ atlas_library_dirs = library_path\n blas_libraries = ['cblas','f77blas','atlas']\n lapack_libraries = ['lapack'] + blas_libraries\n return blas_libraries, lapack_libraries, atlas_library_dirs\n@@ -23,13 +32,13 @@ def unix_atlas_directory(platform):\n \"\"\"\n result = [] #None\n # do a little looking for the linalg directory for atlas libraries\n- path = get_path(__name__)\n- local_atlas0 = os.path.join(path,platform,'atlas')\n- local_atlas1 = os.path.join(path,platform[:-1],'atlas')\n+ #path = get_path(__name__)\n+ #local_atlas0 = os.path.join(path,platform,'atlas')\n+ #local_atlas1 = os.path.join(path,platform[:-1],'atlas')\n \n # first look for a system defined atlas directory\n- dir_search = ['/usr/local/lib/atlas','/usr/lib/atlas',\n- local_atlas0, local_atlas1]\n+ dir_search = ['/usr/local/lib/atlas','/usr/lib/atlas']#,\n+ # local_atlas0, local_atlas1]\n for directory in dir_search:\n if os.path.exists(directory):\n result = [directory]\n", "added_lines": 16, "deleted_lines": 7, "source_code": "import sys, os\n\nlibrary_path = ''\n\ndef get_atlas_info():\n print 'atlas_lib:', library_path\n if sys.platform == 'win32':\n if not library_path:\n atlas_library_dirs=['C:\\\\atlas\\\\WinNT_PIIISSE1']\n else:\n atlas_library_dirs = library_path\n blas_libraries = ['f77blas', 'cblas', 'atlas', 'g2c']\n lapack_libraries = ['lapack'] + blas_libraries \n else:\n if not library_path:\n atlas_library_dirs = unix_atlas_directory(sys.platform)\n else:\n atlas_library_dirs = library_path\n blas_libraries = ['cblas','f77blas','atlas']\n lapack_libraries = ['lapack'] + blas_libraries\n return blas_libraries, lapack_libraries, atlas_library_dirs\n\ndef unix_atlas_directory(platform):\n \"\"\" Search a list of common locations looking for the atlas directory.\n \n Return None if the directory isn't found, otherwise return the\n directory name. This isn't very sophisticated right now. I can\n imagine doing an ftp to our server on platforms that we know about.\n \n Atlas is a highly optimized version of lapack and blas that is fast\n on almost all platforms.\n \"\"\"\n result = [] #None\n # do a little looking for the linalg directory for atlas libraries\n #path = get_path(__name__)\n #local_atlas0 = os.path.join(path,platform,'atlas')\n #local_atlas1 = os.path.join(path,platform[:-1],'atlas')\n \n # first look for a system defined atlas directory\n dir_search = ['/usr/local/lib/atlas','/usr/lib/atlas']#,\n # local_atlas0, local_atlas1]\n for directory in dir_search:\n if os.path.exists(directory):\n result = [directory]\n\n # we should really do an ftp search or something like that at this point.\n return result \n", "source_code_before": "import sys, os\n\ndef get_atlas_info():\n if sys.platform == 'win32':\n atlas_library_dirs=['C:\\\\atlas\\\\WinNT_PIIISSE1']\n blas_libraries = ['f77blas', 'cblas', 'atlas', 'g2c']\n lapack_libraries = ['lapack'] + blas_libraries \n else:\n atlas_library_dirs = unix_atlas_directory(plat)\n blas_libraries = ['cblas','f77blas','atlas']\n lapack_libraries = ['lapack'] + blas_libraries\n return blas_libraries, lapack_libraries, atlas_library_dirs\n\ndef unix_atlas_directory(platform):\n \"\"\" Search a list of common locations looking for the atlas directory.\n \n Return None if the directory isn't found, otherwise return the\n directory name. This isn't very sophisticated right now. I can\n imagine doing an ftp to our server on platforms that we know about.\n \n Atlas is a highly optimized version of lapack and blas that is fast\n on almost all platforms.\n \"\"\"\n result = [] #None\n # do a little looking for the linalg directory for atlas libraries\n path = get_path(__name__)\n local_atlas0 = os.path.join(path,platform,'atlas')\n local_atlas1 = os.path.join(path,platform[:-1],'atlas')\n \n # first look for a system defined atlas directory\n dir_search = ['/usr/local/lib/atlas','/usr/lib/atlas',\n local_atlas0, local_atlas1]\n for directory in dir_search:\n if os.path.exists(directory):\n result = [directory]\n\n # we should really do an ftp search or something like that at this point.\n return result \n", "methods": [ { "name": "get_atlas_info", "long_name": "get_atlas_info( )", "filename": "atlas_info.py", "nloc": 17, "complexity": 4, "token_count": 88, "parameters": [], "start_line": 5, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "unix_atlas_directory", "long_name": "unix_atlas_directory( platform )", "filename": "atlas_info.py", "nloc": 7, "complexity": 3, "token_count": 39, "parameters": [ "platform" ], "start_line": 23, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_atlas_info", "long_name": "get_atlas_info( )", "filename": "atlas_info.py", "nloc": 10, "complexity": 2, "token_count": 64, "parameters": [], "start_line": 3, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "unix_atlas_directory", "long_name": "unix_atlas_directory( platform )", "filename": "atlas_info.py", "nloc": 11, "complexity": 3, "token_count": 82, "parameters": [ "platform" ], "start_line": 14, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "unix_atlas_directory", "long_name": "unix_atlas_directory( platform )", "filename": "atlas_info.py", "nloc": 7, "complexity": 3, "token_count": 39, "parameters": [ "platform" ], "start_line": 23, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "get_atlas_info", "long_name": "get_atlas_info( )", "filename": "atlas_info.py", "nloc": 17, "complexity": 4, "token_count": 88, "parameters": [], "start_line": 5, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 } ], "nloc": 26, "complexity": 7, "token_count": 136, "diff_parsed": { "added": [ "library_path = ''", "", " print 'atlas_lib:', library_path", " if not library_path:", " atlas_library_dirs=['C:\\\\atlas\\\\WinNT_PIIISSE1']", " else:", " atlas_library_dirs = library_path", " if not library_path:", " atlas_library_dirs = unix_atlas_directory(sys.platform)", " else:", " atlas_library_dirs = library_path", " #path = get_path(__name__)", " #local_atlas0 = os.path.join(path,platform,'atlas')", " #local_atlas1 = os.path.join(path,platform[:-1],'atlas')", " dir_search = ['/usr/local/lib/atlas','/usr/lib/atlas']#,", " # local_atlas0, local_atlas1]" ], "deleted": [ " atlas_library_dirs=['C:\\\\atlas\\\\WinNT_PIIISSE1']", " atlas_library_dirs = unix_atlas_directory(plat)", " path = get_path(__name__)", " local_atlas0 = os.path.join(path,platform,'atlas')", " local_atlas1 = os.path.join(path,platform[:-1],'atlas')", " dir_search = ['/usr/local/lib/atlas','/usr/lib/atlas',", " local_atlas0, local_atlas1]" ] } } ] }, { "hash": "4882d70b502d95bed7ec3d82f85e0858d9c5336c", "msg": "changed library_path to be a list instead of single directory specification.\nremoved a print statement from atlas_info", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-01-09T07:21:15+00:00", "author_timezone": 0, "committer_date": "2002-01-09T07:21:15+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "3ded519e4c37afe434b596d687534933d94884a3" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 2, "insertions": 0, "lines": 2, "files": 2, "dmm_unit_size": 1.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/atlas_info.py", "new_path": "scipy_distutils/atlas_info.py", "filename": "atlas_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,7 +3,6 @@\n library_path = ''\n \n def get_atlas_info():\n- print 'atlas_lib:', library_path\n if sys.platform == 'win32':\n if not library_path:\n atlas_library_dirs=['C:\\\\atlas\\\\WinNT_PIIISSE1']\n", "added_lines": 0, "deleted_lines": 1, "source_code": "import sys, os\n\nlibrary_path = ''\n\ndef get_atlas_info():\n if sys.platform == 'win32':\n if not library_path:\n atlas_library_dirs=['C:\\\\atlas\\\\WinNT_PIIISSE1']\n else:\n atlas_library_dirs = library_path\n blas_libraries = ['f77blas', 'cblas', 'atlas', 'g2c']\n lapack_libraries = ['lapack'] + blas_libraries \n else:\n if not library_path:\n atlas_library_dirs = unix_atlas_directory(sys.platform)\n else:\n atlas_library_dirs = library_path\n blas_libraries = ['cblas','f77blas','atlas']\n lapack_libraries = ['lapack'] + blas_libraries\n return blas_libraries, lapack_libraries, atlas_library_dirs\n\ndef unix_atlas_directory(platform):\n \"\"\" Search a list of common locations looking for the atlas directory.\n \n Return None if the directory isn't found, otherwise return the\n directory name. This isn't very sophisticated right now. I can\n imagine doing an ftp to our server on platforms that we know about.\n \n Atlas is a highly optimized version of lapack and blas that is fast\n on almost all platforms.\n \"\"\"\n result = [] #None\n # do a little looking for the linalg directory for atlas libraries\n #path = get_path(__name__)\n #local_atlas0 = os.path.join(path,platform,'atlas')\n #local_atlas1 = os.path.join(path,platform[:-1],'atlas')\n \n # first look for a system defined atlas directory\n dir_search = ['/usr/local/lib/atlas','/usr/lib/atlas']#,\n # local_atlas0, local_atlas1]\n for directory in dir_search:\n if os.path.exists(directory):\n result = [directory]\n\n # we should really do an ftp search or something like that at this point.\n return result \n", "source_code_before": "import sys, os\n\nlibrary_path = ''\n\ndef get_atlas_info():\n print 'atlas_lib:', library_path\n if sys.platform == 'win32':\n if not library_path:\n atlas_library_dirs=['C:\\\\atlas\\\\WinNT_PIIISSE1']\n else:\n atlas_library_dirs = library_path\n blas_libraries = ['f77blas', 'cblas', 'atlas', 'g2c']\n lapack_libraries = ['lapack'] + blas_libraries \n else:\n if not library_path:\n atlas_library_dirs = unix_atlas_directory(sys.platform)\n else:\n atlas_library_dirs = library_path\n blas_libraries = ['cblas','f77blas','atlas']\n lapack_libraries = ['lapack'] + blas_libraries\n return blas_libraries, lapack_libraries, atlas_library_dirs\n\ndef unix_atlas_directory(platform):\n \"\"\" Search a list of common locations looking for the atlas directory.\n \n Return None if the directory isn't found, otherwise return the\n directory name. This isn't very sophisticated right now. I can\n imagine doing an ftp to our server on platforms that we know about.\n \n Atlas is a highly optimized version of lapack and blas that is fast\n on almost all platforms.\n \"\"\"\n result = [] #None\n # do a little looking for the linalg directory for atlas libraries\n #path = get_path(__name__)\n #local_atlas0 = os.path.join(path,platform,'atlas')\n #local_atlas1 = os.path.join(path,platform[:-1],'atlas')\n \n # first look for a system defined atlas directory\n dir_search = ['/usr/local/lib/atlas','/usr/lib/atlas']#,\n # local_atlas0, local_atlas1]\n for directory in dir_search:\n if os.path.exists(directory):\n result = [directory]\n\n # we should really do an ftp search or something like that at this point.\n return result \n", "methods": [ { "name": "get_atlas_info", "long_name": "get_atlas_info( )", "filename": "atlas_info.py", "nloc": 16, "complexity": 4, "token_count": 84, "parameters": [], "start_line": 5, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "unix_atlas_directory", "long_name": "unix_atlas_directory( platform )", "filename": "atlas_info.py", "nloc": 7, "complexity": 3, "token_count": 39, "parameters": [ "platform" ], "start_line": 22, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_atlas_info", "long_name": "get_atlas_info( )", "filename": "atlas_info.py", "nloc": 17, "complexity": 4, "token_count": 88, "parameters": [], "start_line": 5, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "unix_atlas_directory", "long_name": "unix_atlas_directory( platform )", "filename": "atlas_info.py", "nloc": 7, "complexity": 3, "token_count": 39, "parameters": [ "platform" ], "start_line": 23, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_atlas_info", "long_name": "get_atlas_info( )", "filename": "atlas_info.py", "nloc": 17, "complexity": 4, "token_count": 88, "parameters": [], "start_line": 5, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 } ], "nloc": 25, "complexity": 7, "token_count": 132, "diff_parsed": { "added": [], "deleted": [ " print 'atlas_lib:', library_path" ] } }, { "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": "@@ -172,7 +172,6 @@ def slightly_modified_standard_build_extension(self, ext):\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n \n-\n self.compiler.link_shared_object(\n objects, ext_filename, \n libraries=self.get_libraries(ext),\n", "added_lines": 0, "deleted_lines": 1, "source_code": "\"\"\" Modified version of build_ext that handles fortran source files and f2py \n\n The f2py_sources() method is pretty much a copy of the swig_sources()\n method in the standard build_ext class , but modified to use f2py. It\n also.\n \n slightly_modified_standard_build_extension() is a verbatim copy of\n the standard build_extension() method with a single line changed so that\n preprocess_sources() is called instead of just swig_sources(). This new\n function is a nice place to stick any source code preprocessing functions\n needed.\n \n build_extension() handles building any needed static fortran libraries\n first and then calls our slightly_modified_..._extenstion() to do the\n rest of the processing in the (mostly) standard way. \n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import *\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nclass build_ext (old_build_ext):\n user_options = old_build_ext.user_options + \\\n [('f2py-options=', None,\n \"command line arguments to f2py\")]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.f2py_options = None\n\n def finalize_options (self): \n old_build_ext.finalize_options(self)\n if self.f2py_options is None:\n self.f2py_options = []\n \n def run (self):\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.libraries.extend(build_flib.get_library_names() or [])\n self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #runtime_dirs = build_flib.get_runtime_library_dirs()\n #self.runtime_library_dirs.extend(runtime_dirs or [])\n \n #?? what is this ??\n self.library_dirs.append(build_flib.build_flib)\n \n old_build_ext.run(self)\n\n def preprocess_sources(self,sources,ext):\n sources = self.swig_sources(sources)\n if self.has_f2py_sources(sources): \n sources = self.f2py_sources(sources,ext)\n return sources\n \n def extra_include_dirs(self,sources):\n if self.has_f2py_sources(sources): \n import f2py2e\n d = os.path.dirname(f2py2e.__file__)\n return [os.path.join(d,'src')]\n else:\n return [] \n \n def build_extension(self, ext):\n # support for building static fortran libraries\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []: \n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n # be sure to include fortran runtime library directory names\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n linker_so = build_flib.fcompiler.get_linker_so()\n if linker_so is not None:\n self.compiler.linker_so = linker_so\n # end of fortran source support\n # f2py support handled slightly_modified..._extenstion.\n return self.slightly_modified_standard_build_extension(ext)\n \n def slightly_modified_standard_build_extension(self, ext):\n \"\"\"\n This is pretty much a verbatim copy of the build_extension()\n function in distutils with a single change to make it possible\n to pre-process f2py as well as swig source files before \n compilation.\n \"\"\"\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 # ignore build-lib -- put the compiled extension into\n # the source tree along with pure Python modules\n\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\n if not (self.force or newer_group(sources, ext_filename, 'newer')):\n self.announce(\"skipping '%s' extension (up-to-date)\" %\n ext.name)\n return\n else:\n self.announce(\"building '%s' extension\" % ext.name)\n\n # I copied this hole stinken function just to change from\n # self.swig_sources to self.preprocess_sources...\n # ! must come before the next line!!\n include_dirs = self.extra_include_dirs(sources) + \\\n (ext.include_dirs or [])\n sources = self.preprocess_sources(sources, ext)\n \n # Next, compile the source code to object files.\n\n # XXX not honouring 'define_macros' or 'undef_macros' -- the\n # CCompiler API needs to change to accommodate this, and I\n # want to do one thing at a time!\n\n # Two possible sources for extra compiler arguments:\n # - 'extra_compile_args' in Extension object\n # - CFLAGS environment variable (not particularly\n # elegant, but people seem to expect it and I\n # guess it's useful)\n # The environment variable should take precedence, and\n # any sensible compiler will give precedence to later\n # command line args. Hence we combine them in order:\n extra_args = ext.extra_compile_args or []\n\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n # XXX and if we support CFLAGS, why not CC (compiler\n # executable), CPPFLAGS (pre-processor options), and LDFLAGS\n # (linker options) too?\n # XXX should we use shlex to properly parse CFLAGS?\n\n if os.environ.has_key('CFLAGS'):\n extra_args.extend(string.split(os.environ['CFLAGS']))\n\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_args)\n\n # Now link the object files together into a \"shared object\" --\n # of course, first we have to figure out all the other things\n # that go into the mix.\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n self.compiler.link_shared_object(\n 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)\n\n def has_f2py_sources (self, sources):\n print sources\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == \".pyf\": # f2py interface file\n return 1\n print 'no!' \n return 0\n \n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) files.\n \"\"\"\n\n import f2py2e\n\n new_sources = []\n new_include_dirs = []\n f2py_sources = []\n f2py_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n target_dir = self.build_temp\n print 'target_dir', target_dir\n \n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n target_file = os.path.join(target_dir,base+target_ext)\n new_sources.append(target_file)\n f2py_sources.append(source)\n f2py_targets[source] = new_sources[-1]\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n self.include_dirs.append(os.path.join(d,'src'))\n\n f2py_opts = []\n f2py_options = ext.f2py_options + self.f2py_options\n for i in f2py_options:\n f2py_opts.append('--'+i)\n f2py_opts = ['--build-dir',target_dir] + f2py_opts\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target):\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_opts + [source])\n \n return new_sources\n # f2py_sources ()\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n def check_extensions_list (self, extensions):\n \"\"\"\n Very slightly modified to add f2py_options as a flag... argh.\n \n Ensure that the list of extensions (presumably provided as a\n command option 'extensions') is valid, i.e. it is a list of\n Extension objects. We also support the old-style list of 2-tuples,\n where the tuples are (ext_name, build_info), which are converted to\n Extension instances here.\n\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\n \"\"\"\n if type(extensions) is not ListType:\n raise DistutilsSetupError, \\\n \"'ext_modules' option must be a list of Extension instances\"\n \n for i in range(len(extensions)):\n ext = extensions[i]\n if isinstance(ext, Extension):\n continue # OK! (assume type-checking done\n # by Extension constructor)\n\n (ext_name, build_info) = ext\n self.warn((\"old-style (ext_name, build_info) tuple found in \"\n \"ext_modules for extension '%s'\" \n \"-- please convert to Extension instance\" % ext_name))\n if type(ext) is not TupleType and len(ext) != 2:\n raise DistutilsSetupError, \\\n (\"each element of 'ext_modules' option must be an \"\n \"Extension instance or 2-tuple\")\n\n if not (type(ext_name) is StringType and\n extension_name_re.match(ext_name)):\n raise DistutilsSetupError, \\\n (\"first element of each tuple in 'ext_modules' \"\n \"must be the extension name (a string)\")\n\n if type(build_info) is not DictionaryType:\n raise DistutilsSetupError, \\\n (\"second element of each tuple in 'ext_modules' \"\n \"must be a dictionary (build info)\")\n\n # OK, the (ext_name, build_info) dict is type-safe: convert it\n # to an Extension instance.\n ext = Extension(ext_name, build_info['sources'])\n\n # Easy stuff: one-to-one mapping from dict elements to\n # instance attributes.\n for key in ('include_dirs',\n 'library_dirs',\n 'libraries',\n 'extra_objects',\n 'extra_compile_args',\n 'extra_link_args',\n 'f2py_options'):\n val = build_info.get(key)\n if val is not None:\n setattr(ext, key, val)\n\n # Medium-easy stuff: same syntax/semantics, different names.\n ext.runtime_library_dirs = build_info.get('rpath')\n if build_info.has_key('def_file'):\n self.warn(\"'def_file' element of build info dict \"\n \"no longer supported\")\n\n # Non-trivial stuff: 'macros' split into 'define_macros'\n # and 'undef_macros'.\n macros = build_info.get('macros')\n if macros:\n ext.define_macros = []\n ext.undef_macros = []\n for macro in macros:\n if not (type(macro) is TupleType and\n 1 <= len(macro) <= 2):\n raise DistutilsSetupError, \\\n (\"'macros' element of build info dict \"\n \"must be 1- or 2-tuple\")\n if len(macro) == 1:\n ext.undef_macros.append(macro[0])\n elif len(macro) == 2:\n ext.define_macros.append(macro)\n\n extensions[i] = ext\n\n # for extensions\n\n # check_extensions_list ()\n", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files and f2py \n\n The f2py_sources() method is pretty much a copy of the swig_sources()\n method in the standard build_ext class , but modified to use f2py. It\n also.\n \n slightly_modified_standard_build_extension() is a verbatim copy of\n the standard build_extension() method with a single line changed so that\n preprocess_sources() is called instead of just swig_sources(). This new\n function is a nice place to stick any source code preprocessing functions\n needed.\n \n build_extension() handles building any needed static fortran libraries\n first and then calls our slightly_modified_..._extenstion() to do the\n rest of the processing in the (mostly) standard way. \n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import *\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nclass build_ext (old_build_ext):\n user_options = old_build_ext.user_options + \\\n [('f2py-options=', None,\n \"command line arguments to f2py\")]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.f2py_options = None\n\n def finalize_options (self): \n old_build_ext.finalize_options(self)\n if self.f2py_options is None:\n self.f2py_options = []\n \n def run (self):\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.libraries.extend(build_flib.get_library_names() or [])\n self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #runtime_dirs = build_flib.get_runtime_library_dirs()\n #self.runtime_library_dirs.extend(runtime_dirs or [])\n \n #?? what is this ??\n self.library_dirs.append(build_flib.build_flib)\n \n old_build_ext.run(self)\n\n def preprocess_sources(self,sources,ext):\n sources = self.swig_sources(sources)\n if self.has_f2py_sources(sources): \n sources = self.f2py_sources(sources,ext)\n return sources\n \n def extra_include_dirs(self,sources):\n if self.has_f2py_sources(sources): \n import f2py2e\n d = os.path.dirname(f2py2e.__file__)\n return [os.path.join(d,'src')]\n else:\n return [] \n \n def build_extension(self, ext):\n # support for building static fortran libraries\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []: \n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n # be sure to include fortran runtime library directory names\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n linker_so = build_flib.fcompiler.get_linker_so()\n if linker_so is not None:\n self.compiler.linker_so = linker_so\n # end of fortran source support\n # f2py support handled slightly_modified..._extenstion.\n return self.slightly_modified_standard_build_extension(ext)\n \n def slightly_modified_standard_build_extension(self, ext):\n \"\"\"\n This is pretty much a verbatim copy of the build_extension()\n function in distutils with a single change to make it possible\n to pre-process f2py as well as swig source files before \n compilation.\n \"\"\"\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 # ignore build-lib -- put the compiled extension into\n # the source tree along with pure Python modules\n\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\n if not (self.force or newer_group(sources, ext_filename, 'newer')):\n self.announce(\"skipping '%s' extension (up-to-date)\" %\n ext.name)\n return\n else:\n self.announce(\"building '%s' extension\" % ext.name)\n\n # I copied this hole stinken function just to change from\n # self.swig_sources to self.preprocess_sources...\n # ! must come before the next line!!\n include_dirs = self.extra_include_dirs(sources) + \\\n (ext.include_dirs or [])\n sources = self.preprocess_sources(sources, ext)\n \n # Next, compile the source code to object files.\n\n # XXX not honouring 'define_macros' or 'undef_macros' -- the\n # CCompiler API needs to change to accommodate this, and I\n # want to do one thing at a time!\n\n # Two possible sources for extra compiler arguments:\n # - 'extra_compile_args' in Extension object\n # - CFLAGS environment variable (not particularly\n # elegant, but people seem to expect it and I\n # guess it's useful)\n # The environment variable should take precedence, and\n # any sensible compiler will give precedence to later\n # command line args. Hence we combine them in order:\n extra_args = ext.extra_compile_args or []\n\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n # XXX and if we support CFLAGS, why not CC (compiler\n # executable), CPPFLAGS (pre-processor options), and LDFLAGS\n # (linker options) too?\n # XXX should we use shlex to properly parse CFLAGS?\n\n if os.environ.has_key('CFLAGS'):\n extra_args.extend(string.split(os.environ['CFLAGS']))\n\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_args)\n\n # Now link the object files together into a \"shared object\" --\n # of course, first we have to figure out all the other things\n # that go into the mix.\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n\n self.compiler.link_shared_object(\n 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)\n\n def has_f2py_sources (self, sources):\n print sources\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == \".pyf\": # f2py interface file\n return 1\n print 'no!' \n return 0\n \n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) files.\n \"\"\"\n\n import f2py2e\n\n new_sources = []\n new_include_dirs = []\n f2py_sources = []\n f2py_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n target_dir = self.build_temp\n print 'target_dir', target_dir\n \n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n target_file = os.path.join(target_dir,base+target_ext)\n new_sources.append(target_file)\n f2py_sources.append(source)\n f2py_targets[source] = new_sources[-1]\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n self.include_dirs.append(os.path.join(d,'src'))\n\n f2py_opts = []\n f2py_options = ext.f2py_options + self.f2py_options\n for i in f2py_options:\n f2py_opts.append('--'+i)\n f2py_opts = ['--build-dir',target_dir] + f2py_opts\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target):\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_opts + [source])\n \n return new_sources\n # f2py_sources ()\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n def check_extensions_list (self, extensions):\n \"\"\"\n Very slightly modified to add f2py_options as a flag... argh.\n \n Ensure that the list of extensions (presumably provided as a\n command option 'extensions') is valid, i.e. it is a list of\n Extension objects. We also support the old-style list of 2-tuples,\n where the tuples are (ext_name, build_info), which are converted to\n Extension instances here.\n\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\n \"\"\"\n if type(extensions) is not ListType:\n raise DistutilsSetupError, \\\n \"'ext_modules' option must be a list of Extension instances\"\n \n for i in range(len(extensions)):\n ext = extensions[i]\n if isinstance(ext, Extension):\n continue # OK! (assume type-checking done\n # by Extension constructor)\n\n (ext_name, build_info) = ext\n self.warn((\"old-style (ext_name, build_info) tuple found in \"\n \"ext_modules for extension '%s'\" \n \"-- please convert to Extension instance\" % ext_name))\n if type(ext) is not TupleType and len(ext) != 2:\n raise DistutilsSetupError, \\\n (\"each element of 'ext_modules' option must be an \"\n \"Extension instance or 2-tuple\")\n\n if not (type(ext_name) is StringType and\n extension_name_re.match(ext_name)):\n raise DistutilsSetupError, \\\n (\"first element of each tuple in 'ext_modules' \"\n \"must be the extension name (a string)\")\n\n if type(build_info) is not DictionaryType:\n raise DistutilsSetupError, \\\n (\"second element of each tuple in 'ext_modules' \"\n \"must be a dictionary (build info)\")\n\n # OK, the (ext_name, build_info) dict is type-safe: convert it\n # to an Extension instance.\n ext = Extension(ext_name, build_info['sources'])\n\n # Easy stuff: one-to-one mapping from dict elements to\n # instance attributes.\n for key in ('include_dirs',\n 'library_dirs',\n 'libraries',\n 'extra_objects',\n 'extra_compile_args',\n 'extra_link_args',\n 'f2py_options'):\n val = build_info.get(key)\n if val is not None:\n setattr(ext, key, val)\n\n # Medium-easy stuff: same syntax/semantics, different names.\n ext.runtime_library_dirs = build_info.get('rpath')\n if build_info.has_key('def_file'):\n self.warn(\"'def_file' element of build info dict \"\n \"no longer supported\")\n\n # Non-trivial stuff: 'macros' split into 'define_macros'\n # and 'undef_macros'.\n macros = build_info.get('macros')\n if macros:\n ext.define_macros = []\n ext.undef_macros = []\n for macro in macros:\n if not (type(macro) is TupleType and\n 1 <= len(macro) <= 2):\n raise DistutilsSetupError, \\\n (\"'macros' element of build info dict \"\n \"must be 1- or 2-tuple\")\n if len(macro) == 1:\n ext.undef_macros.append(macro[0])\n elif len(macro) == 2:\n ext.define_macros.append(macro)\n\n extensions[i] = ext\n\n # for extensions\n\n # check_extensions_list ()\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 34, "end_line": 37, "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": 7, "complexity": 4, "token_count": 68, "parameters": [ "self" ], "start_line": 39, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "preprocess_sources", "long_name": "preprocess_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "sources", "ext" ], "start_line": 53, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "extra_include_dirs", "long_name": "extra_include_dirs( self , sources )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "sources" ], "start_line": 59, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 15, "complexity": 6, "token_count": 105, "parameters": [ "self", "ext" ], "start_line": 67, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "slightly_modified_standard_build_extension", "long_name": "slightly_modified_standard_build_extension( self , ext )", "filename": "build_ext.py", "nloc": 53, "complexity": 12, "token_count": 390, "parameters": [ "self", "ext" ], "start_line": 87, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 97, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self , sources )", "filename": "build_ext.py", "nloc": 8, "complexity": 3, "token_count": 39, "parameters": [ "self", "sources" ], "start_line": 185, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 38, "complexity": 7, "token_count": 270, "parameters": [ "self", "sources", "ext" ], "start_line": 194, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 258, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_extensions_list", "long_name": "check_extensions_list( self , extensions )", "filename": "build_ext.py", "nloc": 55, "complexity": 18, "token_count": 308, "parameters": [ "self", "extensions" ], "start_line": 269, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 1 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 34, "end_line": 37, "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": 7, "complexity": 4, "token_count": 68, "parameters": [ "self" ], "start_line": 39, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "preprocess_sources", "long_name": "preprocess_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "sources", "ext" ], "start_line": 53, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "extra_include_dirs", "long_name": "extra_include_dirs( self , sources )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "sources" ], "start_line": 59, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 15, "complexity": 6, "token_count": 105, "parameters": [ "self", "ext" ], "start_line": 67, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "slightly_modified_standard_build_extension", "long_name": "slightly_modified_standard_build_extension( self , ext )", "filename": "build_ext.py", "nloc": 53, "complexity": 12, "token_count": 390, "parameters": [ "self", "ext" ], "start_line": 87, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 98, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self , sources )", "filename": "build_ext.py", "nloc": 8, "complexity": 3, "token_count": 39, "parameters": [ "self", "sources" ], "start_line": 186, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 38, "complexity": 7, "token_count": 270, "parameters": [ "self", "sources", "ext" ], "start_line": 195, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 259, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_extensions_list", "long_name": "check_extensions_list( self , extensions )", "filename": "build_ext.py", "nloc": 55, "complexity": 18, "token_count": 308, "parameters": [ "self", "extensions" ], "start_line": 270, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "slightly_modified_standard_build_extension", "long_name": "slightly_modified_standard_build_extension( self , ext )", "filename": "build_ext.py", "nloc": 53, "complexity": 12, "token_count": 390, "parameters": [ "self", "ext" ], "start_line": 87, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 98, "top_nesting_level": 1 } ], "nloc": 227, "complexity": 59, "token_count": 1420, "diff_parsed": { "added": [], "deleted": [ "" ] } } ] }, { "hash": "323b6b4040f4752a746873675dff261969d4d0ce", "msg": "Fixed: base of pyf file may be different from what ext module it provides", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-01-09T10:31:07+00:00", "author_timezone": 0, "committer_date": "2002-01-09T10:31:07+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "4882d70b502d95bed7ec3d82f85e0858d9c5336c" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 0, "insertions": 16, "lines": 16, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.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": "@@ -214,11 +214,27 @@ def f2py_sources (self, sources, ext):\n target_ext = 'module.c'\n target_dir = self.build_temp\n print 'target_dir', target_dir\n+\n+ match_module = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',\n+ re.I).match\n \n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n+ # get extension module name\n+ f = open(source)\n+ for line in f.xreadlines():\n+ m = match_module(line)\n+ if m:\n+ base = m.group('name')\n+ break\n+ f.close()\n+ if base != ext.name:\n+ # XXX: Should we do here more than just warn?\n+ print 'Warning: %s provides %s but this extension is %s' \\\n+ % (source,`base`,`ext`)\n+\n target_file = os.path.join(target_dir,base+target_ext)\n new_sources.append(target_file)\n f2py_sources.append(source)\n", "added_lines": 16, "deleted_lines": 0, "source_code": "\"\"\" Modified version of build_ext that handles fortran source files and f2py \n\n The f2py_sources() method is pretty much a copy of the swig_sources()\n method in the standard build_ext class , but modified to use f2py. It\n also.\n \n slightly_modified_standard_build_extension() is a verbatim copy of\n the standard build_extension() method with a single line changed so that\n preprocess_sources() is called instead of just swig_sources(). This new\n function is a nice place to stick any source code preprocessing functions\n needed.\n \n build_extension() handles building any needed static fortran libraries\n first and then calls our slightly_modified_..._extenstion() to do the\n rest of the processing in the (mostly) standard way. \n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import *\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nclass build_ext (old_build_ext):\n user_options = old_build_ext.user_options + \\\n [('f2py-options=', None,\n \"command line arguments to f2py\")]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.f2py_options = None\n\n def finalize_options (self): \n old_build_ext.finalize_options(self)\n if self.f2py_options is None:\n self.f2py_options = []\n \n def run (self):\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.libraries.extend(build_flib.get_library_names() or [])\n self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #runtime_dirs = build_flib.get_runtime_library_dirs()\n #self.runtime_library_dirs.extend(runtime_dirs or [])\n \n #?? what is this ??\n self.library_dirs.append(build_flib.build_flib)\n \n old_build_ext.run(self)\n\n def preprocess_sources(self,sources,ext):\n sources = self.swig_sources(sources)\n if self.has_f2py_sources(sources): \n sources = self.f2py_sources(sources,ext)\n return sources\n \n def extra_include_dirs(self,sources):\n if self.has_f2py_sources(sources): \n import f2py2e\n d = os.path.dirname(f2py2e.__file__)\n return [os.path.join(d,'src')]\n else:\n return [] \n \n def build_extension(self, ext):\n # support for building static fortran libraries\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []: \n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n # be sure to include fortran runtime library directory names\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n linker_so = build_flib.fcompiler.get_linker_so()\n if linker_so is not None:\n self.compiler.linker_so = linker_so\n # end of fortran source support\n # f2py support handled slightly_modified..._extenstion.\n return self.slightly_modified_standard_build_extension(ext)\n \n def slightly_modified_standard_build_extension(self, ext):\n \"\"\"\n This is pretty much a verbatim copy of the build_extension()\n function in distutils with a single change to make it possible\n to pre-process f2py as well as swig source files before \n compilation.\n \"\"\"\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 # ignore build-lib -- put the compiled extension into\n # the source tree along with pure Python modules\n\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\n if not (self.force or newer_group(sources, ext_filename, 'newer')):\n self.announce(\"skipping '%s' extension (up-to-date)\" %\n ext.name)\n return\n else:\n self.announce(\"building '%s' extension\" % ext.name)\n\n # I copied this hole stinken function just to change from\n # self.swig_sources to self.preprocess_sources...\n # ! must come before the next line!!\n include_dirs = self.extra_include_dirs(sources) + \\\n (ext.include_dirs or [])\n sources = self.preprocess_sources(sources, ext)\n \n # Next, compile the source code to object files.\n\n # XXX not honouring 'define_macros' or 'undef_macros' -- the\n # CCompiler API needs to change to accommodate this, and I\n # want to do one thing at a time!\n\n # Two possible sources for extra compiler arguments:\n # - 'extra_compile_args' in Extension object\n # - CFLAGS environment variable (not particularly\n # elegant, but people seem to expect it and I\n # guess it's useful)\n # The environment variable should take precedence, and\n # any sensible compiler will give precedence to later\n # command line args. Hence we combine them in order:\n extra_args = ext.extra_compile_args or []\n\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n # XXX and if we support CFLAGS, why not CC (compiler\n # executable), CPPFLAGS (pre-processor options), and LDFLAGS\n # (linker options) too?\n # XXX should we use shlex to properly parse CFLAGS?\n\n if os.environ.has_key('CFLAGS'):\n extra_args.extend(string.split(os.environ['CFLAGS']))\n\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_args)\n\n # Now link the object files together into a \"shared object\" --\n # of course, first we have to figure out all the other things\n # that go into the mix.\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n self.compiler.link_shared_object(\n 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)\n\n def has_f2py_sources (self, sources):\n print sources\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == \".pyf\": # f2py interface file\n return 1\n print 'no!' \n return 0\n \n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) files.\n \"\"\"\n\n import f2py2e\n\n new_sources = []\n new_include_dirs = []\n f2py_sources = []\n f2py_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n target_dir = self.build_temp\n print 'target_dir', target_dir\n\n match_module = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',\n re.I).match\n \n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n for line in f.xreadlines():\n m = match_module(line)\n if m:\n base = m.group('name')\n break\n f.close()\n if base != ext.name:\n # XXX: Should we do here more than just warn?\n print 'Warning: %s provides %s but this extension is %s' \\\n % (source,`base`,`ext`)\n\n target_file = os.path.join(target_dir,base+target_ext)\n new_sources.append(target_file)\n f2py_sources.append(source)\n f2py_targets[source] = new_sources[-1]\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n self.include_dirs.append(os.path.join(d,'src'))\n\n f2py_opts = []\n f2py_options = ext.f2py_options + self.f2py_options\n for i in f2py_options:\n f2py_opts.append('--'+i)\n f2py_opts = ['--build-dir',target_dir] + f2py_opts\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target):\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_opts + [source])\n \n return new_sources\n # f2py_sources ()\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n def check_extensions_list (self, extensions):\n \"\"\"\n Very slightly modified to add f2py_options as a flag... argh.\n \n Ensure that the list of extensions (presumably provided as a\n command option 'extensions') is valid, i.e. it is a list of\n Extension objects. We also support the old-style list of 2-tuples,\n where the tuples are (ext_name, build_info), which are converted to\n Extension instances here.\n\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\n \"\"\"\n if type(extensions) is not ListType:\n raise DistutilsSetupError, \\\n \"'ext_modules' option must be a list of Extension instances\"\n \n for i in range(len(extensions)):\n ext = extensions[i]\n if isinstance(ext, Extension):\n continue # OK! (assume type-checking done\n # by Extension constructor)\n\n (ext_name, build_info) = ext\n self.warn((\"old-style (ext_name, build_info) tuple found in \"\n \"ext_modules for extension '%s'\" \n \"-- please convert to Extension instance\" % ext_name))\n if type(ext) is not TupleType and len(ext) != 2:\n raise DistutilsSetupError, \\\n (\"each element of 'ext_modules' option must be an \"\n \"Extension instance or 2-tuple\")\n\n if not (type(ext_name) is StringType and\n extension_name_re.match(ext_name)):\n raise DistutilsSetupError, \\\n (\"first element of each tuple in 'ext_modules' \"\n \"must be the extension name (a string)\")\n\n if type(build_info) is not DictionaryType:\n raise DistutilsSetupError, \\\n (\"second element of each tuple in 'ext_modules' \"\n \"must be a dictionary (build info)\")\n\n # OK, the (ext_name, build_info) dict is type-safe: convert it\n # to an Extension instance.\n ext = Extension(ext_name, build_info['sources'])\n\n # Easy stuff: one-to-one mapping from dict elements to\n # instance attributes.\n for key in ('include_dirs',\n 'library_dirs',\n 'libraries',\n 'extra_objects',\n 'extra_compile_args',\n 'extra_link_args',\n 'f2py_options'):\n val = build_info.get(key)\n if val is not None:\n setattr(ext, key, val)\n\n # Medium-easy stuff: same syntax/semantics, different names.\n ext.runtime_library_dirs = build_info.get('rpath')\n if build_info.has_key('def_file'):\n self.warn(\"'def_file' element of build info dict \"\n \"no longer supported\")\n\n # Non-trivial stuff: 'macros' split into 'define_macros'\n # and 'undef_macros'.\n macros = build_info.get('macros')\n if macros:\n ext.define_macros = []\n ext.undef_macros = []\n for macro in macros:\n if not (type(macro) is TupleType and\n 1 <= len(macro) <= 2):\n raise DistutilsSetupError, \\\n (\"'macros' element of build info dict \"\n \"must be 1- or 2-tuple\")\n if len(macro) == 1:\n ext.undef_macros.append(macro[0])\n elif len(macro) == 2:\n ext.define_macros.append(macro)\n\n extensions[i] = ext\n\n # for extensions\n\n # check_extensions_list ()\n", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files and f2py \n\n The f2py_sources() method is pretty much a copy of the swig_sources()\n method in the standard build_ext class , but modified to use f2py. It\n also.\n \n slightly_modified_standard_build_extension() is a verbatim copy of\n the standard build_extension() method with a single line changed so that\n preprocess_sources() is called instead of just swig_sources(). This new\n function is a nice place to stick any source code preprocessing functions\n needed.\n \n build_extension() handles building any needed static fortran libraries\n first and then calls our slightly_modified_..._extenstion() to do the\n rest of the processing in the (mostly) standard way. \n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import *\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nclass build_ext (old_build_ext):\n user_options = old_build_ext.user_options + \\\n [('f2py-options=', None,\n \"command line arguments to f2py\")]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.f2py_options = None\n\n def finalize_options (self): \n old_build_ext.finalize_options(self)\n if self.f2py_options is None:\n self.f2py_options = []\n \n def run (self):\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.libraries.extend(build_flib.get_library_names() or [])\n self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #runtime_dirs = build_flib.get_runtime_library_dirs()\n #self.runtime_library_dirs.extend(runtime_dirs or [])\n \n #?? what is this ??\n self.library_dirs.append(build_flib.build_flib)\n \n old_build_ext.run(self)\n\n def preprocess_sources(self,sources,ext):\n sources = self.swig_sources(sources)\n if self.has_f2py_sources(sources): \n sources = self.f2py_sources(sources,ext)\n return sources\n \n def extra_include_dirs(self,sources):\n if self.has_f2py_sources(sources): \n import f2py2e\n d = os.path.dirname(f2py2e.__file__)\n return [os.path.join(d,'src')]\n else:\n return [] \n \n def build_extension(self, ext):\n # support for building static fortran libraries\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []: \n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n # be sure to include fortran runtime library directory names\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n linker_so = build_flib.fcompiler.get_linker_so()\n if linker_so is not None:\n self.compiler.linker_so = linker_so\n # end of fortran source support\n # f2py support handled slightly_modified..._extenstion.\n return self.slightly_modified_standard_build_extension(ext)\n \n def slightly_modified_standard_build_extension(self, ext):\n \"\"\"\n This is pretty much a verbatim copy of the build_extension()\n function in distutils with a single change to make it possible\n to pre-process f2py as well as swig source files before \n compilation.\n \"\"\"\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 # ignore build-lib -- put the compiled extension into\n # the source tree along with pure Python modules\n\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\n if not (self.force or newer_group(sources, ext_filename, 'newer')):\n self.announce(\"skipping '%s' extension (up-to-date)\" %\n ext.name)\n return\n else:\n self.announce(\"building '%s' extension\" % ext.name)\n\n # I copied this hole stinken function just to change from\n # self.swig_sources to self.preprocess_sources...\n # ! must come before the next line!!\n include_dirs = self.extra_include_dirs(sources) + \\\n (ext.include_dirs or [])\n sources = self.preprocess_sources(sources, ext)\n \n # Next, compile the source code to object files.\n\n # XXX not honouring 'define_macros' or 'undef_macros' -- the\n # CCompiler API needs to change to accommodate this, and I\n # want to do one thing at a time!\n\n # Two possible sources for extra compiler arguments:\n # - 'extra_compile_args' in Extension object\n # - CFLAGS environment variable (not particularly\n # elegant, but people seem to expect it and I\n # guess it's useful)\n # The environment variable should take precedence, and\n # any sensible compiler will give precedence to later\n # command line args. Hence we combine them in order:\n extra_args = ext.extra_compile_args or []\n\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n # XXX and if we support CFLAGS, why not CC (compiler\n # executable), CPPFLAGS (pre-processor options), and LDFLAGS\n # (linker options) too?\n # XXX should we use shlex to properly parse CFLAGS?\n\n if os.environ.has_key('CFLAGS'):\n extra_args.extend(string.split(os.environ['CFLAGS']))\n\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_args)\n\n # Now link the object files together into a \"shared object\" --\n # of course, first we have to figure out all the other things\n # that go into the mix.\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n self.compiler.link_shared_object(\n 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)\n\n def has_f2py_sources (self, sources):\n print sources\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == \".pyf\": # f2py interface file\n return 1\n print 'no!' \n return 0\n \n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) files.\n \"\"\"\n\n import f2py2e\n\n new_sources = []\n new_include_dirs = []\n f2py_sources = []\n f2py_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n target_dir = self.build_temp\n print 'target_dir', target_dir\n \n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n target_file = os.path.join(target_dir,base+target_ext)\n new_sources.append(target_file)\n f2py_sources.append(source)\n f2py_targets[source] = new_sources[-1]\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n self.include_dirs.append(os.path.join(d,'src'))\n\n f2py_opts = []\n f2py_options = ext.f2py_options + self.f2py_options\n for i in f2py_options:\n f2py_opts.append('--'+i)\n f2py_opts = ['--build-dir',target_dir] + f2py_opts\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target):\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_opts + [source])\n \n return new_sources\n # f2py_sources ()\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n def check_extensions_list (self, extensions):\n \"\"\"\n Very slightly modified to add f2py_options as a flag... argh.\n \n Ensure that the list of extensions (presumably provided as a\n command option 'extensions') is valid, i.e. it is a list of\n Extension objects. We also support the old-style list of 2-tuples,\n where the tuples are (ext_name, build_info), which are converted to\n Extension instances here.\n\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\n \"\"\"\n if type(extensions) is not ListType:\n raise DistutilsSetupError, \\\n \"'ext_modules' option must be a list of Extension instances\"\n \n for i in range(len(extensions)):\n ext = extensions[i]\n if isinstance(ext, Extension):\n continue # OK! (assume type-checking done\n # by Extension constructor)\n\n (ext_name, build_info) = ext\n self.warn((\"old-style (ext_name, build_info) tuple found in \"\n \"ext_modules for extension '%s'\" \n \"-- please convert to Extension instance\" % ext_name))\n if type(ext) is not TupleType and len(ext) != 2:\n raise DistutilsSetupError, \\\n (\"each element of 'ext_modules' option must be an \"\n \"Extension instance or 2-tuple\")\n\n if not (type(ext_name) is StringType and\n extension_name_re.match(ext_name)):\n raise DistutilsSetupError, \\\n (\"first element of each tuple in 'ext_modules' \"\n \"must be the extension name (a string)\")\n\n if type(build_info) is not DictionaryType:\n raise DistutilsSetupError, \\\n (\"second element of each tuple in 'ext_modules' \"\n \"must be a dictionary (build info)\")\n\n # OK, the (ext_name, build_info) dict is type-safe: convert it\n # to an Extension instance.\n ext = Extension(ext_name, build_info['sources'])\n\n # Easy stuff: one-to-one mapping from dict elements to\n # instance attributes.\n for key in ('include_dirs',\n 'library_dirs',\n 'libraries',\n 'extra_objects',\n 'extra_compile_args',\n 'extra_link_args',\n 'f2py_options'):\n val = build_info.get(key)\n if val is not None:\n setattr(ext, key, val)\n\n # Medium-easy stuff: same syntax/semantics, different names.\n ext.runtime_library_dirs = build_info.get('rpath')\n if build_info.has_key('def_file'):\n self.warn(\"'def_file' element of build info dict \"\n \"no longer supported\")\n\n # Non-trivial stuff: 'macros' split into 'define_macros'\n # and 'undef_macros'.\n macros = build_info.get('macros')\n if macros:\n ext.define_macros = []\n ext.undef_macros = []\n for macro in macros:\n if not (type(macro) is TupleType and\n 1 <= len(macro) <= 2):\n raise DistutilsSetupError, \\\n (\"'macros' element of build info dict \"\n \"must be 1- or 2-tuple\")\n if len(macro) == 1:\n ext.undef_macros.append(macro[0])\n elif len(macro) == 2:\n ext.define_macros.append(macro)\n\n extensions[i] = ext\n\n # for extensions\n\n # check_extensions_list ()\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 34, "end_line": 37, "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": 7, "complexity": 4, "token_count": 68, "parameters": [ "self" ], "start_line": 39, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "preprocess_sources", "long_name": "preprocess_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "sources", "ext" ], "start_line": 53, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "extra_include_dirs", "long_name": "extra_include_dirs( self , sources )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "sources" ], "start_line": 59, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 15, "complexity": 6, "token_count": 105, "parameters": [ "self", "ext" ], "start_line": 67, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "slightly_modified_standard_build_extension", "long_name": "slightly_modified_standard_build_extension( self , ext )", "filename": "build_ext.py", "nloc": 53, "complexity": 12, "token_count": 390, "parameters": [ "self", "ext" ], "start_line": 87, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 97, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self , sources )", "filename": "build_ext.py", "nloc": 8, "complexity": 3, "token_count": 39, "parameters": [ "self", "sources" ], "start_line": 185, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 50, "complexity": 10, "token_count": 345, "parameters": [ "self", "sources", "ext" ], "start_line": 194, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 274, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_extensions_list", "long_name": "check_extensions_list( self , extensions )", "filename": "build_ext.py", "nloc": 55, "complexity": 18, "token_count": 308, "parameters": [ "self", "extensions" ], "start_line": 285, "end_line": 368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 1 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 34, "end_line": 37, "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": 7, "complexity": 4, "token_count": 68, "parameters": [ "self" ], "start_line": 39, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "preprocess_sources", "long_name": "preprocess_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "sources", "ext" ], "start_line": 53, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "extra_include_dirs", "long_name": "extra_include_dirs( self , sources )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "sources" ], "start_line": 59, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 15, "complexity": 6, "token_count": 105, "parameters": [ "self", "ext" ], "start_line": 67, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "slightly_modified_standard_build_extension", "long_name": "slightly_modified_standard_build_extension( self , ext )", "filename": "build_ext.py", "nloc": 53, "complexity": 12, "token_count": 390, "parameters": [ "self", "ext" ], "start_line": 87, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 97, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self , sources )", "filename": "build_ext.py", "nloc": 8, "complexity": 3, "token_count": 39, "parameters": [ "self", "sources" ], "start_line": 185, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 38, "complexity": 7, "token_count": 270, "parameters": [ "self", "sources", "ext" ], "start_line": 194, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 258, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_extensions_list", "long_name": "check_extensions_list( self , extensions )", "filename": "build_ext.py", "nloc": 55, "complexity": 18, "token_count": 308, "parameters": [ "self", "extensions" ], "start_line": 269, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 50, "complexity": 10, "token_count": 345, "parameters": [ "self", "sources", "ext" ], "start_line": 194, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 1 } ], "nloc": 239, "complexity": 62, "token_count": 1495, "diff_parsed": { "added": [ "", " match_module = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',", " re.I).match", " # get extension module name", " f = open(source)", " for line in f.xreadlines():", " m = match_module(line)", " if m:", " base = m.group('name')", " break", " f.close()", " if base != ext.name:", " # XXX: Should we do here more than just warn?", " print 'Warning: %s provides %s but this extension is %s' \\", " % (source,`base`,`ext`)", "" ], "deleted": [] } } ] }, { "hash": "dda06dcb6c3b3b7c21eb5a41518b9a237345bef3", "msg": "Introduced run_f2py command; fixed a minor bug in cpuinfo about detecting i(5|6)86", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-01-09T14:11:13+00:00", "author_timezone": 0, "committer_date": "2002-01-09T14:11:13+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "323b6b4040f4752a746873675dff261969d4d0ce" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 5, "insertions": 173, "lines": 178, "files": 6, "dmm_unit_size": 0.15294117647058825, "dmm_unit_complexity": 0.32941176470588235, "dmm_unit_interfacing": 0.35294117647058826, "modified_files": [ { "old_path": "scipy_distutils/command/build.py", "new_path": "scipy_distutils/command/build.py", "filename": "build.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -8,10 +8,13 @@\n class build(old_build):\n def has_f_libraries(self):\n return self.distribution.has_f_libraries()\n+ def has_f2py_sources(self):\n+ return self.distribution.has_f2py_sources()\n \n sub_commands = [('build_py', old_build.has_pure_modules),\n ('build_clib', old_build.has_c_libraries),\n- ('build_flib', has_f_libraries), # new feature\n+ ('run_f2py', has_f2py_sources), # new feature\n+ ('build_flib', has_f_libraries), # new feature\n ('build_ext', old_build.has_ext_modules),\n ('build_scripts', old_build.has_scripts),\n ]\n", "added_lines": 4, "deleted_lines": 1, "source_code": "# Need to override the build command to include building of fortran libraries\n# This class must be used as the entry for the build key in the cmdclass\n# dictionary which is given to the setup command.\n\nfrom distutils.command.build import *\nfrom distutils.command.build import build as old_build\n\nclass build(old_build):\n def has_f_libraries(self):\n return self.distribution.has_f_libraries()\n def has_f2py_sources(self):\n return self.distribution.has_f2py_sources()\n\n sub_commands = [('build_py', old_build.has_pure_modules),\n ('build_clib', old_build.has_c_libraries),\n ('run_f2py', has_f2py_sources), # new feature\n ('build_flib', has_f_libraries), # new feature\n ('build_ext', old_build.has_ext_modules),\n ('build_scripts', old_build.has_scripts),\n ]\n", "source_code_before": "# Need to override the build command to include building of fortran libraries\n# This class must be used as the entry for the build key in the cmdclass\n# dictionary which is given to the setup command.\n\nfrom distutils.command.build import *\nfrom distutils.command.build import build as old_build\n\nclass build(old_build):\n def has_f_libraries(self):\n return self.distribution.has_f_libraries()\n\n sub_commands = [('build_py', old_build.has_pure_modules),\n ('build_clib', old_build.has_c_libraries),\n ('build_flib', has_f_libraries), # new feature\n ('build_ext', old_build.has_ext_modules),\n ('build_scripts', old_build.has_scripts),\n ]\n", "methods": [ { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 9, "end_line": 10, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "build.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 11, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 9, "end_line": 10, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "build.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 11, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "nloc": 14, "complexity": 2, "token_count": 100, "diff_parsed": { "added": [ " def has_f2py_sources(self):", " return self.distribution.has_f2py_sources()", " ('run_f2py', has_f2py_sources), # new feature", " ('build_flib', has_f_libraries), # new feature" ], "deleted": [ " ('build_flib', has_f_libraries), # new feature" ] } }, { "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": "@@ -81,6 +81,8 @@ def build_extension(self, ext):\n if linker_so is not None:\n self.compiler.linker_so = linker_so\n # end of fortran source support\n+ return old_build_ext.build_extension(self,ext)\n+ \n # f2py support handled slightly_modified..._extenstion.\n return self.slightly_modified_standard_build_extension(ext)\n \n@@ -266,8 +268,10 @@ def f2py_sources (self, sources, ext):\n if newer(source,target):\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n- f2py2e.run_main(f2py_opts + [source])\n- \n+ f2py2e.run_main(f2py_opts + [source]) \n+ #ext.sources.extend(pyf.data[ext.name].get('fsrc') or [])\n+ #self.distribution.fortran_sources_to_flib(ext)\n+ print new_sources\n return new_sources\n # f2py_sources ()\n \n", "added_lines": 6, "deleted_lines": 2, "source_code": "\"\"\" Modified version of build_ext that handles fortran source files and f2py \n\n The f2py_sources() method is pretty much a copy of the swig_sources()\n method in the standard build_ext class , but modified to use f2py. It\n also.\n \n slightly_modified_standard_build_extension() is a verbatim copy of\n the standard build_extension() method with a single line changed so that\n preprocess_sources() is called instead of just swig_sources(). This new\n function is a nice place to stick any source code preprocessing functions\n needed.\n \n build_extension() handles building any needed static fortran libraries\n first and then calls our slightly_modified_..._extenstion() to do the\n rest of the processing in the (mostly) standard way. \n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import *\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nclass build_ext (old_build_ext):\n user_options = old_build_ext.user_options + \\\n [('f2py-options=', None,\n \"command line arguments to f2py\")]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.f2py_options = None\n\n def finalize_options (self): \n old_build_ext.finalize_options(self)\n if self.f2py_options is None:\n self.f2py_options = []\n \n def run (self):\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.libraries.extend(build_flib.get_library_names() or [])\n self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #runtime_dirs = build_flib.get_runtime_library_dirs()\n #self.runtime_library_dirs.extend(runtime_dirs or [])\n \n #?? what is this ??\n self.library_dirs.append(build_flib.build_flib)\n \n old_build_ext.run(self)\n\n def preprocess_sources(self,sources,ext):\n sources = self.swig_sources(sources)\n if self.has_f2py_sources(sources): \n sources = self.f2py_sources(sources,ext)\n return sources\n \n def extra_include_dirs(self,sources):\n if self.has_f2py_sources(sources): \n import f2py2e\n d = os.path.dirname(f2py2e.__file__)\n return [os.path.join(d,'src')]\n else:\n return [] \n \n def build_extension(self, ext):\n # support for building static fortran libraries\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []: \n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n # be sure to include fortran runtime library directory names\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n linker_so = build_flib.fcompiler.get_linker_so()\n if linker_so is not None:\n self.compiler.linker_so = linker_so\n # end of fortran source support\n return old_build_ext.build_extension(self,ext)\n \n # f2py support handled slightly_modified..._extenstion.\n return self.slightly_modified_standard_build_extension(ext)\n \n def slightly_modified_standard_build_extension(self, ext):\n \"\"\"\n This is pretty much a verbatim copy of the build_extension()\n function in distutils with a single change to make it possible\n to pre-process f2py as well as swig source files before \n compilation.\n \"\"\"\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 # ignore build-lib -- put the compiled extension into\n # the source tree along with pure Python modules\n\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\n if not (self.force or newer_group(sources, ext_filename, 'newer')):\n self.announce(\"skipping '%s' extension (up-to-date)\" %\n ext.name)\n return\n else:\n self.announce(\"building '%s' extension\" % ext.name)\n\n # I copied this hole stinken function just to change from\n # self.swig_sources to self.preprocess_sources...\n # ! must come before the next line!!\n include_dirs = self.extra_include_dirs(sources) + \\\n (ext.include_dirs or [])\n sources = self.preprocess_sources(sources, ext)\n \n # Next, compile the source code to object files.\n\n # XXX not honouring 'define_macros' or 'undef_macros' -- the\n # CCompiler API needs to change to accommodate this, and I\n # want to do one thing at a time!\n\n # Two possible sources for extra compiler arguments:\n # - 'extra_compile_args' in Extension object\n # - CFLAGS environment variable (not particularly\n # elegant, but people seem to expect it and I\n # guess it's useful)\n # The environment variable should take precedence, and\n # any sensible compiler will give precedence to later\n # command line args. Hence we combine them in order:\n extra_args = ext.extra_compile_args or []\n\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n # XXX and if we support CFLAGS, why not CC (compiler\n # executable), CPPFLAGS (pre-processor options), and LDFLAGS\n # (linker options) too?\n # XXX should we use shlex to properly parse CFLAGS?\n\n if os.environ.has_key('CFLAGS'):\n extra_args.extend(string.split(os.environ['CFLAGS']))\n\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_args)\n\n # Now link the object files together into a \"shared object\" --\n # of course, first we have to figure out all the other things\n # that go into the mix.\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n self.compiler.link_shared_object(\n 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)\n\n def has_f2py_sources (self, sources):\n print sources\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == \".pyf\": # f2py interface file\n return 1\n print 'no!' \n return 0\n \n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) files.\n \"\"\"\n\n import f2py2e\n\n new_sources = []\n new_include_dirs = []\n f2py_sources = []\n f2py_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n target_dir = self.build_temp\n print 'target_dir', target_dir\n\n match_module = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',\n re.I).match\n \n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n for line in f.xreadlines():\n m = match_module(line)\n if m:\n base = m.group('name')\n break\n f.close()\n if base != ext.name:\n # XXX: Should we do here more than just warn?\n print 'Warning: %s provides %s but this extension is %s' \\\n % (source,`base`,`ext`)\n\n target_file = os.path.join(target_dir,base+target_ext)\n new_sources.append(target_file)\n f2py_sources.append(source)\n f2py_targets[source] = new_sources[-1]\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n self.include_dirs.append(os.path.join(d,'src'))\n\n f2py_opts = []\n f2py_options = ext.f2py_options + self.f2py_options\n for i in f2py_options:\n f2py_opts.append('--'+i)\n f2py_opts = ['--build-dir',target_dir] + f2py_opts\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target):\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_opts + [source]) \n #ext.sources.extend(pyf.data[ext.name].get('fsrc') or [])\n #self.distribution.fortran_sources_to_flib(ext)\n print new_sources\n return new_sources\n # f2py_sources ()\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n def check_extensions_list (self, extensions):\n \"\"\"\n Very slightly modified to add f2py_options as a flag... argh.\n \n Ensure that the list of extensions (presumably provided as a\n command option 'extensions') is valid, i.e. it is a list of\n Extension objects. We also support the old-style list of 2-tuples,\n where the tuples are (ext_name, build_info), which are converted to\n Extension instances here.\n\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\n \"\"\"\n if type(extensions) is not ListType:\n raise DistutilsSetupError, \\\n \"'ext_modules' option must be a list of Extension instances\"\n \n for i in range(len(extensions)):\n ext = extensions[i]\n if isinstance(ext, Extension):\n continue # OK! (assume type-checking done\n # by Extension constructor)\n\n (ext_name, build_info) = ext\n self.warn((\"old-style (ext_name, build_info) tuple found in \"\n \"ext_modules for extension '%s'\" \n \"-- please convert to Extension instance\" % ext_name))\n if type(ext) is not TupleType and len(ext) != 2:\n raise DistutilsSetupError, \\\n (\"each element of 'ext_modules' option must be an \"\n \"Extension instance or 2-tuple\")\n\n if not (type(ext_name) is StringType and\n extension_name_re.match(ext_name)):\n raise DistutilsSetupError, \\\n (\"first element of each tuple in 'ext_modules' \"\n \"must be the extension name (a string)\")\n\n if type(build_info) is not DictionaryType:\n raise DistutilsSetupError, \\\n (\"second element of each tuple in 'ext_modules' \"\n \"must be a dictionary (build info)\")\n\n # OK, the (ext_name, build_info) dict is type-safe: convert it\n # to an Extension instance.\n ext = Extension(ext_name, build_info['sources'])\n\n # Easy stuff: one-to-one mapping from dict elements to\n # instance attributes.\n for key in ('include_dirs',\n 'library_dirs',\n 'libraries',\n 'extra_objects',\n 'extra_compile_args',\n 'extra_link_args',\n 'f2py_options'):\n val = build_info.get(key)\n if val is not None:\n setattr(ext, key, val)\n\n # Medium-easy stuff: same syntax/semantics, different names.\n ext.runtime_library_dirs = build_info.get('rpath')\n if build_info.has_key('def_file'):\n self.warn(\"'def_file' element of build info dict \"\n \"no longer supported\")\n\n # Non-trivial stuff: 'macros' split into 'define_macros'\n # and 'undef_macros'.\n macros = build_info.get('macros')\n if macros:\n ext.define_macros = []\n ext.undef_macros = []\n for macro in macros:\n if not (type(macro) is TupleType and\n 1 <= len(macro) <= 2):\n raise DistutilsSetupError, \\\n (\"'macros' element of build info dict \"\n \"must be 1- or 2-tuple\")\n if len(macro) == 1:\n ext.undef_macros.append(macro[0])\n elif len(macro) == 2:\n ext.define_macros.append(macro)\n\n extensions[i] = ext\n\n # for extensions\n\n # check_extensions_list ()\n", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files and f2py \n\n The f2py_sources() method is pretty much a copy of the swig_sources()\n method in the standard build_ext class , but modified to use f2py. It\n also.\n \n slightly_modified_standard_build_extension() is a verbatim copy of\n the standard build_extension() method with a single line changed so that\n preprocess_sources() is called instead of just swig_sources(). This new\n function is a nice place to stick any source code preprocessing functions\n needed.\n \n build_extension() handles building any needed static fortran libraries\n first and then calls our slightly_modified_..._extenstion() to do the\n rest of the processing in the (mostly) standard way. \n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import *\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nclass build_ext (old_build_ext):\n user_options = old_build_ext.user_options + \\\n [('f2py-options=', None,\n \"command line arguments to f2py\")]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.f2py_options = None\n\n def finalize_options (self): \n old_build_ext.finalize_options(self)\n if self.f2py_options is None:\n self.f2py_options = []\n \n def run (self):\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.libraries.extend(build_flib.get_library_names() or [])\n self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #runtime_dirs = build_flib.get_runtime_library_dirs()\n #self.runtime_library_dirs.extend(runtime_dirs or [])\n \n #?? what is this ??\n self.library_dirs.append(build_flib.build_flib)\n \n old_build_ext.run(self)\n\n def preprocess_sources(self,sources,ext):\n sources = self.swig_sources(sources)\n if self.has_f2py_sources(sources): \n sources = self.f2py_sources(sources,ext)\n return sources\n \n def extra_include_dirs(self,sources):\n if self.has_f2py_sources(sources): \n import f2py2e\n d = os.path.dirname(f2py2e.__file__)\n return [os.path.join(d,'src')]\n else:\n return [] \n \n def build_extension(self, ext):\n # support for building static fortran libraries\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []: \n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n # be sure to include fortran runtime library directory names\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n linker_so = build_flib.fcompiler.get_linker_so()\n if linker_so is not None:\n self.compiler.linker_so = linker_so\n # end of fortran source support\n # f2py support handled slightly_modified..._extenstion.\n return self.slightly_modified_standard_build_extension(ext)\n \n def slightly_modified_standard_build_extension(self, ext):\n \"\"\"\n This is pretty much a verbatim copy of the build_extension()\n function in distutils with a single change to make it possible\n to pre-process f2py as well as swig source files before \n compilation.\n \"\"\"\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 # ignore build-lib -- put the compiled extension into\n # the source tree along with pure Python modules\n\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\n if not (self.force or newer_group(sources, ext_filename, 'newer')):\n self.announce(\"skipping '%s' extension (up-to-date)\" %\n ext.name)\n return\n else:\n self.announce(\"building '%s' extension\" % ext.name)\n\n # I copied this hole stinken function just to change from\n # self.swig_sources to self.preprocess_sources...\n # ! must come before the next line!!\n include_dirs = self.extra_include_dirs(sources) + \\\n (ext.include_dirs or [])\n sources = self.preprocess_sources(sources, ext)\n \n # Next, compile the source code to object files.\n\n # XXX not honouring 'define_macros' or 'undef_macros' -- the\n # CCompiler API needs to change to accommodate this, and I\n # want to do one thing at a time!\n\n # Two possible sources for extra compiler arguments:\n # - 'extra_compile_args' in Extension object\n # - CFLAGS environment variable (not particularly\n # elegant, but people seem to expect it and I\n # guess it's useful)\n # The environment variable should take precedence, and\n # any sensible compiler will give precedence to later\n # command line args. Hence we combine them in order:\n extra_args = ext.extra_compile_args or []\n\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n # XXX and if we support CFLAGS, why not CC (compiler\n # executable), CPPFLAGS (pre-processor options), and LDFLAGS\n # (linker options) too?\n # XXX should we use shlex to properly parse CFLAGS?\n\n if os.environ.has_key('CFLAGS'):\n extra_args.extend(string.split(os.environ['CFLAGS']))\n\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_args)\n\n # Now link the object files together into a \"shared object\" --\n # of course, first we have to figure out all the other things\n # that go into the mix.\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n self.compiler.link_shared_object(\n 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)\n\n def has_f2py_sources (self, sources):\n print sources\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == \".pyf\": # f2py interface file\n return 1\n print 'no!' \n return 0\n \n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) files.\n \"\"\"\n\n import f2py2e\n\n new_sources = []\n new_include_dirs = []\n f2py_sources = []\n f2py_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n target_dir = self.build_temp\n print 'target_dir', target_dir\n\n match_module = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',\n re.I).match\n \n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n for line in f.xreadlines():\n m = match_module(line)\n if m:\n base = m.group('name')\n break\n f.close()\n if base != ext.name:\n # XXX: Should we do here more than just warn?\n print 'Warning: %s provides %s but this extension is %s' \\\n % (source,`base`,`ext`)\n\n target_file = os.path.join(target_dir,base+target_ext)\n new_sources.append(target_file)\n f2py_sources.append(source)\n f2py_targets[source] = new_sources[-1]\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n self.include_dirs.append(os.path.join(d,'src'))\n\n f2py_opts = []\n f2py_options = ext.f2py_options + self.f2py_options\n for i in f2py_options:\n f2py_opts.append('--'+i)\n f2py_opts = ['--build-dir',target_dir] + f2py_opts\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target):\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_opts + [source])\n \n return new_sources\n # f2py_sources ()\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n def check_extensions_list (self, extensions):\n \"\"\"\n Very slightly modified to add f2py_options as a flag... argh.\n \n Ensure that the list of extensions (presumably provided as a\n command option 'extensions') is valid, i.e. it is a list of\n Extension objects. We also support the old-style list of 2-tuples,\n where the tuples are (ext_name, build_info), which are converted to\n Extension instances here.\n\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\n \"\"\"\n if type(extensions) is not ListType:\n raise DistutilsSetupError, \\\n \"'ext_modules' option must be a list of Extension instances\"\n \n for i in range(len(extensions)):\n ext = extensions[i]\n if isinstance(ext, Extension):\n continue # OK! (assume type-checking done\n # by Extension constructor)\n\n (ext_name, build_info) = ext\n self.warn((\"old-style (ext_name, build_info) tuple found in \"\n \"ext_modules for extension '%s'\" \n \"-- please convert to Extension instance\" % ext_name))\n if type(ext) is not TupleType and len(ext) != 2:\n raise DistutilsSetupError, \\\n (\"each element of 'ext_modules' option must be an \"\n \"Extension instance or 2-tuple\")\n\n if not (type(ext_name) is StringType and\n extension_name_re.match(ext_name)):\n raise DistutilsSetupError, \\\n (\"first element of each tuple in 'ext_modules' \"\n \"must be the extension name (a string)\")\n\n if type(build_info) is not DictionaryType:\n raise DistutilsSetupError, \\\n (\"second element of each tuple in 'ext_modules' \"\n \"must be a dictionary (build info)\")\n\n # OK, the (ext_name, build_info) dict is type-safe: convert it\n # to an Extension instance.\n ext = Extension(ext_name, build_info['sources'])\n\n # Easy stuff: one-to-one mapping from dict elements to\n # instance attributes.\n for key in ('include_dirs',\n 'library_dirs',\n 'libraries',\n 'extra_objects',\n 'extra_compile_args',\n 'extra_link_args',\n 'f2py_options'):\n val = build_info.get(key)\n if val is not None:\n setattr(ext, key, val)\n\n # Medium-easy stuff: same syntax/semantics, different names.\n ext.runtime_library_dirs = build_info.get('rpath')\n if build_info.has_key('def_file'):\n self.warn(\"'def_file' element of build info dict \"\n \"no longer supported\")\n\n # Non-trivial stuff: 'macros' split into 'define_macros'\n # and 'undef_macros'.\n macros = build_info.get('macros')\n if macros:\n ext.define_macros = []\n ext.undef_macros = []\n for macro in macros:\n if not (type(macro) is TupleType and\n 1 <= len(macro) <= 2):\n raise DistutilsSetupError, \\\n (\"'macros' element of build info dict \"\n \"must be 1- or 2-tuple\")\n if len(macro) == 1:\n ext.undef_macros.append(macro[0])\n elif len(macro) == 2:\n ext.define_macros.append(macro)\n\n extensions[i] = ext\n\n # for extensions\n\n # check_extensions_list ()\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 34, "end_line": 37, "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": 7, "complexity": 4, "token_count": 68, "parameters": [ "self" ], "start_line": 39, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "preprocess_sources", "long_name": "preprocess_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "sources", "ext" ], "start_line": 53, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "extra_include_dirs", "long_name": "extra_include_dirs( self , sources )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "sources" ], "start_line": 59, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 16, "complexity": 6, "token_count": 114, "parameters": [ "self", "ext" ], "start_line": 67, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "slightly_modified_standard_build_extension", "long_name": "slightly_modified_standard_build_extension( self , ext )", "filename": "build_ext.py", "nloc": 53, "complexity": 12, "token_count": 390, "parameters": [ "self", "ext" ], "start_line": 89, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 97, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self , sources )", "filename": "build_ext.py", "nloc": 8, "complexity": 3, "token_count": 39, "parameters": [ "self", "sources" ], "start_line": 187, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 51, "complexity": 10, "token_count": 347, "parameters": [ "self", "sources", "ext" ], "start_line": 196, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 278, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_extensions_list", "long_name": "check_extensions_list( self , extensions )", "filename": "build_ext.py", "nloc": 55, "complexity": 18, "token_count": 308, "parameters": [ "self", "extensions" ], "start_line": 289, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 1 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 34, "end_line": 37, "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": 7, "complexity": 4, "token_count": 68, "parameters": [ "self" ], "start_line": 39, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "preprocess_sources", "long_name": "preprocess_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "sources", "ext" ], "start_line": 53, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "extra_include_dirs", "long_name": "extra_include_dirs( self , sources )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "sources" ], "start_line": 59, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 15, "complexity": 6, "token_count": 105, "parameters": [ "self", "ext" ], "start_line": 67, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "slightly_modified_standard_build_extension", "long_name": "slightly_modified_standard_build_extension( self , ext )", "filename": "build_ext.py", "nloc": 53, "complexity": 12, "token_count": 390, "parameters": [ "self", "ext" ], "start_line": 87, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 97, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self , sources )", "filename": "build_ext.py", "nloc": 8, "complexity": 3, "token_count": 39, "parameters": [ "self", "sources" ], "start_line": 185, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 50, "complexity": 10, "token_count": 345, "parameters": [ "self", "sources", "ext" ], "start_line": 194, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 274, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_extensions_list", "long_name": "check_extensions_list( self , extensions )", "filename": "build_ext.py", "nloc": 55, "complexity": 18, "token_count": 308, "parameters": [ "self", "extensions" ], "start_line": 285, "end_line": 368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 16, "complexity": 6, "token_count": 114, "parameters": [ "self", "ext" ], "start_line": 67, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 51, "complexity": 10, "token_count": 347, "parameters": [ "self", "sources", "ext" ], "start_line": 196, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 } ], "nloc": 241, "complexity": 62, "token_count": 1506, "diff_parsed": { "added": [ " return old_build_ext.build_extension(self,ext)", "", " f2py2e.run_main(f2py_opts + [source])", " #ext.sources.extend(pyf.data[ext.name].get('fsrc') or [])", " #self.distribution.fortran_sources_to_flib(ext)", " print new_sources" ], "deleted": [ " f2py2e.run_main(f2py_opts + [source])", "" ] } }, { "old_path": "scipy_distutils/command/cpuinfo.py", "new_path": "scipy_distutils/command/cpuinfo.py", "filename": "cpuinfo.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -107,10 +107,10 @@ def _is_i486(self):\n return self.info[0]['cpu']=='i486'\n \n def _is_i586(self):\n- return self.is_Intel() and self.info[0]['model'] == '5'\n+ return self.is_Intel() and self.info[0]['cpu family'] == '5'\n \n def _is_i686(self):\n- return self.is_Intel() and self.info[0]['model'] == '6'\n+ return self.is_Intel() and self.info[0]['cpu family'] == '6'\n \n def _is_Celeron(self):\n return re.match(r'.*?Celeron',\n", "added_lines": 2, "deleted_lines": 2, "source_code": "#!/usr/bin/env python\n\"\"\"\ncpuinfo\n\nCopyright 2001 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNote: This should be merged into proc at some point. Perhaps proc should\nbe returning classes like this instead of using dictionaries.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision$\n$Date$\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id$\"\n\n__all__ = ['cpuinfo']\n\nimport sys,string,re,types\n\nclass cpuinfo_base:\n \"\"\"Holds CPU information and provides methods for requiring\n the availability of various CPU features.\n \"\"\"\n\n def _try_call(self,func):\n try:\n return func()\n except:\n pass\n\n def __getattr__(self,name):\n if name[0]!='_':\n if hasattr(self,'_'+name):\n attr = getattr(self,'_'+name)\n if type(attr) is types.MethodType:\n return lambda func=self._try_call,attr=attr : func(attr)\n else:\n return lambda : None\n raise AttributeError,name \n\n\nclass linux_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n for line in open('/proc/cpuinfo').readlines():\n name_value = map(string.strip,string.split(line,':',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info or info[-1].has_key(name): # next processor\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['vendor_id']=='AuthenticAMD'\n\n def _is_AthlonK6(self):\n return re.match(r'.*?AMD-K6',self.info[0]['model name']) is not None\n\n def _is_AthlonK7(self):\n return re.match(r'.*?AMD-K7',self.info[0]['model name']) is not None\n\n # Alpha\n\n def _is_Alpha(self):\n return self.info[0]['cpu']=='Alpha'\n\n def _is_EV4(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV4'\n\n def _is_EV5(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV5'\n\n def _is_EV56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV56'\n\n def _is_PCA56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'PCA56'\n\n # Intel\n\n #XXX\n _is_i386 = _not_impl\n\n def _is_Intel(self):\n return self.info[0]['vendor_id']=='GenuineIntel'\n\n def _is_i486(self):\n return self.info[0]['cpu']=='i486'\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '5'\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '6'\n\n def _is_Celeron(self):\n return re.match(r'.*?Celeron',\n self.info[0]['model name']) is not None\n\n #XXX\n _is_Pentium = _is_PentiumPro = _is_PentiumIII = _is_PentiumIV = _not_impl\n\n def _is_PentiumII(self):\n return re.match(r'.*?Pentium II\\b',\n self.info[0]['model name']) is not None\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _has_fdiv_bug(self):\n return self.info[0]['fdiv_bug']=='yes'\n\n def _has_f00f_bug(self):\n return self.info[0]['f00f_bug']=='yes'\n\n def _has_mmx(self):\n return re.match(r'.*?\\bmmx',self.info[0]['flags']) is not None\n\nif sys.platform[:5] == 'linux': # variations: linux2,linux-i386 (any others?)\n cpuinfo = linux_cpuinfo\n#XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.\nelse:\n cpuinfo = cpuinfo_base\n\n\n\"\"\"\nlaptop:\n[{'cache size': '256 KB', 'cpu MHz': '399.129', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '6', 'cpuid level': '2', 'model name': 'Mobile Pentium II', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '796.26', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '13', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr'}]\n\nkev:\n[{'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '699.59', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}, {'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '1', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '701.23', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}]\n\nath:\n[{'cache size': '512 KB', 'cpu MHz': '503.542', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '1', 'cpuid level': '1', 'model name': 'AMD-K7(tm) Processor', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '1002.70', 'vendor_id': 'AuthenticAMD', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '2', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat mmx syscall mmxext 3dnowext 3dnow'}]\n\nfiasco:\n[{'max. addr. space #': '127', 'cpu': 'Alpha', 'cpu serial number': 'Linux_is_Great!', 'kernel unaligned acc': '0 (pc=0,va=0)', 'system revision': '0', 'system variation': 'LX164', 'cycle frequency [Hz]': '533185472', 'system serial number': 'MILO-2.0.35-c5.', 'timer frequency [Hz]': '1024.00', 'cpu model': 'EV56', 'platform string': 'N/A', 'cpu revision': '0', 'BogoMIPS': '530.57', 'cpus detected': '0', 'phys. address bits': '40', 'user unaligned acc': '1340 (pc=2000000ec90,va=20001156da4)', 'page size [bytes]': '8192', 'system type': 'EB164', 'cpu variation': '0'}]\n\"\"\"\n\nif __name__ == \"__main__\":\n cpu = cpuinfo()\n\n cpu.is_blaa()\n cpu.is_Intel()\n cpu.is_Alpha()\n\n print 'CPU information:',\n for name in dir(cpuinfo):\n if name[0]=='_' and name[1]!='_' and getattr(cpu,name[1:])():\n print name[1:],\n print\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\ncpuinfo\n\nCopyright 2001 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNote: This should be merged into proc at some point. Perhaps proc should\nbe returning classes like this instead of using dictionaries.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision$\n$Date$\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id$\"\n\n__all__ = ['cpuinfo']\n\nimport sys,string,re,types\n\nclass cpuinfo_base:\n \"\"\"Holds CPU information and provides methods for requiring\n the availability of various CPU features.\n \"\"\"\n\n def _try_call(self,func):\n try:\n return func()\n except:\n pass\n\n def __getattr__(self,name):\n if name[0]!='_':\n if hasattr(self,'_'+name):\n attr = getattr(self,'_'+name)\n if type(attr) is types.MethodType:\n return lambda func=self._try_call,attr=attr : func(attr)\n else:\n return lambda : None\n raise AttributeError,name \n\n\nclass linux_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n for line in open('/proc/cpuinfo').readlines():\n name_value = map(string.strip,string.split(line,':',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info or info[-1].has_key(name): # next processor\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['vendor_id']=='AuthenticAMD'\n\n def _is_AthlonK6(self):\n return re.match(r'.*?AMD-K6',self.info[0]['model name']) is not None\n\n def _is_AthlonK7(self):\n return re.match(r'.*?AMD-K7',self.info[0]['model name']) is not None\n\n # Alpha\n\n def _is_Alpha(self):\n return self.info[0]['cpu']=='Alpha'\n\n def _is_EV4(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV4'\n\n def _is_EV5(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV5'\n\n def _is_EV56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV56'\n\n def _is_PCA56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'PCA56'\n\n # Intel\n\n #XXX\n _is_i386 = _not_impl\n\n def _is_Intel(self):\n return self.info[0]['vendor_id']=='GenuineIntel'\n\n def _is_i486(self):\n return self.info[0]['cpu']=='i486'\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['model'] == '5'\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['model'] == '6'\n\n def _is_Celeron(self):\n return re.match(r'.*?Celeron',\n self.info[0]['model name']) is not None\n\n #XXX\n _is_Pentium = _is_PentiumPro = _is_PentiumIII = _is_PentiumIV = _not_impl\n\n def _is_PentiumII(self):\n return re.match(r'.*?Pentium II\\b',\n self.info[0]['model name']) is not None\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _has_fdiv_bug(self):\n return self.info[0]['fdiv_bug']=='yes'\n\n def _has_f00f_bug(self):\n return self.info[0]['f00f_bug']=='yes'\n\n def _has_mmx(self):\n return re.match(r'.*?\\bmmx',self.info[0]['flags']) is not None\n\nif sys.platform[:5] == 'linux': # variations: linux2,linux-i386 (any others?)\n cpuinfo = linux_cpuinfo\n#XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.\nelse:\n cpuinfo = cpuinfo_base\n\n\n\"\"\"\nlaptop:\n[{'cache size': '256 KB', 'cpu MHz': '399.129', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '6', 'cpuid level': '2', 'model name': 'Mobile Pentium II', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '796.26', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '13', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr'}]\n\nkev:\n[{'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '699.59', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}, {'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '1', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '701.23', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}]\n\nath:\n[{'cache size': '512 KB', 'cpu MHz': '503.542', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '1', 'cpuid level': '1', 'model name': 'AMD-K7(tm) Processor', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '1002.70', 'vendor_id': 'AuthenticAMD', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '2', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat mmx syscall mmxext 3dnowext 3dnow'}]\n\nfiasco:\n[{'max. addr. space #': '127', 'cpu': 'Alpha', 'cpu serial number': 'Linux_is_Great!', 'kernel unaligned acc': '0 (pc=0,va=0)', 'system revision': '0', 'system variation': 'LX164', 'cycle frequency [Hz]': '533185472', 'system serial number': 'MILO-2.0.35-c5.', 'timer frequency [Hz]': '1024.00', 'cpu model': 'EV56', 'platform string': 'N/A', 'cpu revision': '0', 'BogoMIPS': '530.57', 'cpus detected': '0', 'phys. address bits': '40', 'user unaligned acc': '1340 (pc=2000000ec90,va=20001156da4)', 'page size [bytes]': '8192', 'system type': 'EB164', 'cpu variation': '0'}]\n\"\"\"\n\nif __name__ == \"__main__\":\n cpu = cpuinfo()\n\n cpu.is_blaa()\n cpu.is_Intel()\n cpu.is_Alpha()\n\n print 'CPU information:',\n for name in dir(cpuinfo):\n if name[0]=='_' and name[1]!='_' and getattr(cpu,name[1:])():\n print name[1:],\n print\n", "methods": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 30, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 36, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 16, "complexity": 7, "token_count": 112, "parameters": [ "self" ], "start_line": 51, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 75, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 78, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 83, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 89, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 92, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 103, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 106, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 109, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 112, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 122, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 128, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 131, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 134, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 137, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 30, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 36, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 16, "complexity": 7, "token_count": 112, "parameters": [ "self" ], "start_line": 51, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 75, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 78, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 83, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 89, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 92, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 103, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 106, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 109, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 112, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 122, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 128, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 131, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 134, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 137, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 109, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 112, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "nloc": 123, "complexity": 37, "token_count": 745, "diff_parsed": { "added": [ " return self.is_Intel() and self.info[0]['cpu family'] == '5'", " return self.is_Intel() and self.info[0]['cpu family'] == '6'" ], "deleted": [ " return self.is_Intel() and self.info[0]['model'] == '5'", " return self.is_Intel() and self.info[0]['model'] == '6'" ] } }, { "old_path": null, "new_path": "scipy_distutils/command/run_f2py.py", "filename": "run_f2py.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,148 @@\n+\"\"\"distutils.command.run_f2py\n+\n+Implements the Distutils 'run_f2py' command.\n+\"\"\"\n+\n+# created 2002/01/09, Pearu Peterson \n+\n+__revision__ = \"$Id$\"\n+\n+from distutils.dep_util import newer\n+from scipy_distutils.core import Command\n+\n+import re,os\n+\n+module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\n+\n+class run_f2py(Command):\n+\n+ description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n+ \"(C and occasionally Fortran).\"\n+\n+ user_options = [('build-dir=', 'b',\n+ \"directory to build fortran wrappers to\"),\n+ ('debug-capi', None,\n+ \"generate C/API extensions with debugging code\"),\n+ ('force', 'f',\n+ \"forcibly build everything (ignore file timestamps)\"),\n+ ]\n+\n+ def initialize_options (self):\n+ self.build_dir = None\n+ self.debug_capi = None\n+ self.force = None\n+ self.f2py_options = []\n+ # initialize_options()\n+\n+\n+ def finalize_options (self):\n+ self.set_undefined_options('build',\n+ ('build_temp', 'build_dir'),\n+ ('force', 'force'))\n+\n+ self.f2py_options.extend(['--build-dir',self.build_dir])\n+\n+ if self.debug_capi is not None:\n+ self.f2py_options.append('--debug-capi')\n+\n+ # finalize_options()\n+\n+ def run (self):\n+ if self.distribution.has_ext_modules():\n+ for ext in self.distribution.ext_modules:\n+ ext.sources = self.f2py_sources(ext.sources,ext)\n+ self.distribution.fortran_sources_to_flib(ext)\n+ # run()\n+\n+ def f2py_sources (self, sources, ext):\n+\n+ \"\"\"Walk the list of source files in 'sources', looking for f2py\n+ interface (.pyf) files. Run f2py on all that are found, and\n+ return a modified 'sources' list with f2py source files replaced\n+ by the generated C (or C++) and Fortran files.\n+ \"\"\"\n+\n+ import f2py2e\n+ # f2py generates the following files for an extension module\n+ # with a name :\n+ # module.c\n+ # -f2pywrappers.f [occasionally]\n+ # In addition, /src/fortranobject.{c,h} are needed\n+ # for building f2py generated extension modules.\n+ # It is assumed that one pyf file contains defintions for exactly\n+ # one extension module.\n+\n+ new_sources = []\n+ f2py_sources = []\n+ f2py_targets = {}\n+ f2py_fortran_targets = {}\n+\n+ # XXX this drops generated C/C++ files into the source tree, which\n+ # is fine for developers who want to distribute the generated\n+ # source -- but there should be an option to put f2py output in\n+ # the temp dir.\n+\n+ target_ext = 'module.c'\n+ fortran_target_ext = '-f2pywrappers.f'\n+ target_dir = self.build_dir\n+ print 'target_dir', target_dir\n+\n+ for source in sources:\n+ (base, source_ext) = os.path.splitext(source)\n+ (source_dir, base) = os.path.split(base)\n+ if source_ext == \".pyf\": # f2py interface file\n+ # get extension module name\n+ f = open(source)\n+ for line in f.xreadlines():\n+ m = module_name_re(line)\n+ if m:\n+ base = m.group('name')\n+ break\n+ f.close()\n+ if base != ext.name:\n+ # XXX: Should we do here more than just warn?\n+ self.warn('%s provides %s but this extension is %s' \\\n+ % (source,`base`,`ext`))\n+\n+ target_file = os.path.join(target_dir,base+target_ext)\n+ fortran_target_file = os.path.join(target_dir,base+fortran_target_ext)\n+ f2py_sources.append(source)\n+ f2py_targets[source] = target_file\n+ f2py_fortran_targets[source] = fortran_target_file\n+ else:\n+ new_sources.append(source)\n+\n+ if not f2py_sources:\n+ return new_sources\n+\n+ # a bit of a hack, but I think it'll work. Just include one of\n+ # the fortranobject.c files that was copied into most \n+ d = os.path.dirname(f2py2e.__file__)\n+ new_sources.append(os.path.join(d,'src','fortranobject.c'))\n+ ext.include_dirs.append(os.path.join(d,'src'))\n+\n+ f2py_options = []\n+ for i in ext.f2py_options:\n+ f2py_opts.append('--'+i) # XXX: ???\n+ f2py_options = self.f2py_options + f2py_options\n+ \n+ # make sure the target dir exists\n+ from distutils.dir_util import mkpath\n+ mkpath(target_dir)\n+\n+ for source in f2py_sources:\n+ target = f2py_targets[source]\n+ fortran_target = f2py_fortran_targets[source]\n+ if newer(source,target) or self.force:\n+ self.announce(\"f2py-ing %s to %s\" % (source, target))\n+ self.announce(\"f2py-args: %s\" % f2py_options)\n+ f2py2e.run_main(f2py_options + [source])\n+ new_sources.append(target)\n+ if os.path.exists(fortran_target):\n+ new_sources.append(fortran_target)\n+\n+ print new_sources\n+ return new_sources\n+ # f2py_sources ()\n+ \n+# class x\n", "added_lines": 148, "deleted_lines": 0, "source_code": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom scipy_distutils.core import Command\n\nimport re,os\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.distribution.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n \"\"\"\n\n import f2py2e\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains defintions for exactly\n # one extension module.\n\n new_sources = []\n f2py_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n target_dir = self.build_dir\n print 'target_dir', target_dir\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n for line in f.xreadlines():\n m = module_name_re(line)\n if m:\n base = m.group('name')\n break\n f.close()\n if base != ext.name:\n # XXX: Should we do here more than just warn?\n self.warn('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext`))\n\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,base+fortran_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = fortran_target_file\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n f2py_options = []\n for i in ext.f2py_options:\n f2py_opts.append('--'+i) # XXX: ???\n f2py_options = self.f2py_options + f2py_options\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n fortran_target = f2py_fortran_targets[source]\n if newer(source,target) or self.force:\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n\n print new_sources\n return new_sources\n # f2py_sources ()\n \n# class x\n", "source_code_before": null, "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 30, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 38, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 54, "complexity": 12, "token_count": 372, "parameters": [ "self", "sources", "ext" ], "start_line": 57, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 89, "top_nesting_level": 1 } ], "methods_before": [], "changed_methods": [ { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 54, "complexity": 12, "token_count": 372, "parameters": [ "self", "sources", "ext" ], "start_line": 57, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 89, "top_nesting_level": 1 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 30, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 38, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "nloc": 90, "complexity": 18, "token_count": 574, "diff_parsed": { "added": [ "\"\"\"distutils.command.run_f2py", "", "Implements the Distutils 'run_f2py' command.", "\"\"\"", "", "# created 2002/01/09, Pearu Peterson", "", "__revision__ = \"$Id$\"", "", "from distutils.dep_util import newer", "from scipy_distutils.core import Command", "", "import re,os", "", "module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match", "", "class run_f2py(Command):", "", " description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\", " \"(C and occasionally Fortran).\"", "", " user_options = [('build-dir=', 'b',", " \"directory to build fortran wrappers to\"),", " ('debug-capi', None,", " \"generate C/API extensions with debugging code\"),", " ('force', 'f',", " \"forcibly build everything (ignore file timestamps)\"),", " ]", "", " def initialize_options (self):", " self.build_dir = None", " self.debug_capi = None", " self.force = None", " self.f2py_options = []", " # initialize_options()", "", "", " def finalize_options (self):", " self.set_undefined_options('build',", " ('build_temp', 'build_dir'),", " ('force', 'force'))", "", " self.f2py_options.extend(['--build-dir',self.build_dir])", "", " if self.debug_capi is not None:", " self.f2py_options.append('--debug-capi')", "", " # finalize_options()", "", " def run (self):", " if self.distribution.has_ext_modules():", " for ext in self.distribution.ext_modules:", " ext.sources = self.f2py_sources(ext.sources,ext)", " self.distribution.fortran_sources_to_flib(ext)", " # run()", "", " def f2py_sources (self, sources, ext):", "", " \"\"\"Walk the list of source files in 'sources', looking for f2py", " interface (.pyf) files. Run f2py on all that are found, and", " return a modified 'sources' list with f2py source files replaced", " by the generated C (or C++) and Fortran files.", " \"\"\"", "", " import f2py2e", " # f2py generates the following files for an extension module", " # with a name :", " # module.c", " # -f2pywrappers.f [occasionally]", " # In addition, /src/fortranobject.{c,h} are needed", " # for building f2py generated extension modules.", " # It is assumed that one pyf file contains defintions for exactly", " # one extension module.", "", " new_sources = []", " f2py_sources = []", " f2py_targets = {}", " f2py_fortran_targets = {}", "", " # XXX this drops generated C/C++ files into the source tree, which", " # is fine for developers who want to distribute the generated", " # source -- but there should be an option to put f2py output in", " # the temp dir.", "", " target_ext = 'module.c'", " fortran_target_ext = '-f2pywrappers.f'", " target_dir = self.build_dir", " print 'target_dir', target_dir", "", " for source in sources:", " (base, source_ext) = os.path.splitext(source)", " (source_dir, base) = os.path.split(base)", " if source_ext == \".pyf\": # f2py interface file", " # get extension module name", " f = open(source)", " for line in f.xreadlines():", " m = module_name_re(line)", " if m:", " base = m.group('name')", " break", " f.close()", " if base != ext.name:", " # XXX: Should we do here more than just warn?", " self.warn('%s provides %s but this extension is %s' \\", " % (source,`base`,`ext`))", "", " target_file = os.path.join(target_dir,base+target_ext)", " fortran_target_file = os.path.join(target_dir,base+fortran_target_ext)", " f2py_sources.append(source)", " f2py_targets[source] = target_file", " f2py_fortran_targets[source] = fortran_target_file", " else:", " new_sources.append(source)", "", " if not f2py_sources:", " return new_sources", "", " # a bit of a hack, but I think it'll work. Just include one of", " # the fortranobject.c files that was copied into most", " d = os.path.dirname(f2py2e.__file__)", " new_sources.append(os.path.join(d,'src','fortranobject.c'))", " ext.include_dirs.append(os.path.join(d,'src'))", "", " f2py_options = []", " for i in ext.f2py_options:", " f2py_opts.append('--'+i) # XXX: ???", " f2py_options = self.f2py_options + f2py_options", "", " # make sure the target dir exists", " from distutils.dir_util import mkpath", " mkpath(target_dir)", "", " for source in f2py_sources:", " target = f2py_targets[source]", " fortran_target = f2py_fortran_targets[source]", " if newer(source,target) or self.force:", " self.announce(\"f2py-ing %s to %s\" % (source, target))", " self.announce(\"f2py-args: %s\" % f2py_options)", " f2py2e.run_main(f2py_options + [source])", " new_sources.append(target)", " if os.path.exists(fortran_target):", " new_sources.append(fortran_target)", "", " print new_sources", " return new_sources", " # f2py_sources ()", "", "# class x" ], "deleted": [] } }, { "old_path": "scipy_distutils/core.py", "new_path": "scipy_distutils/core.py", "filename": "core.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -12,6 +12,7 @@\n from scipy_distutils.command import build_ext\n from scipy_distutils.command import build_clib\n from scipy_distutils.command import build_flib\n+from scipy_distutils.command import run_f2py\n from scipy_distutils.command import sdist\n from scipy_distutils.command import install_data\n from scipy_distutils.command import install\n@@ -24,6 +25,7 @@ def setup(**attr):\n 'build_ext': build_ext.build_ext,\n 'build_py': build_py.build_py, \n 'build_clib': build_clib.build_clib,\n+ 'run_f2py': run_f2py.run_f2py,\n 'sdist': sdist.sdist,\n 'install_data': install_data.install_data,\n 'install': install.install,\n", "added_lines": 2, "deleted_lines": 0, "source_code": "from distutils.core import *\nfrom distutils.core import setup as old_setup\n\nfrom distutils.cmd import Command\nfrom scipy_distutils.extension import Extension\n\n# Our dist is different than the standard one.\nfrom scipy_distutils.dist import Distribution\n\nfrom scipy_distutils.command import build\nfrom scipy_distutils.command import build_py\nfrom scipy_distutils.command import build_ext\nfrom scipy_distutils.command import build_clib\nfrom scipy_distutils.command import build_flib\nfrom scipy_distutils.command import run_f2py\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\ndef setup(**attr):\n distclass = Distribution\n cmdclass = {'build': build.build,\n 'build_flib': build_flib.build_flib,\n 'build_ext': build_ext.build_ext,\n 'build_py': build_py.build_py, \n 'build_clib': build_clib.build_clib,\n 'run_f2py': run_f2py.run_f2py,\n 'sdist': sdist.sdist,\n 'install_data': install_data.install_data,\n 'install': install.install,\n 'install_headers': install_headers.install_headers\n }\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 return old_setup(**new_attr)\n", "source_code_before": "from distutils.core import *\nfrom distutils.core import setup as old_setup\n\nfrom distutils.cmd import Command\nfrom scipy_distutils.extension import Extension\n\n# Our dist is different than the standard one.\nfrom scipy_distutils.dist import Distribution\n\nfrom scipy_distutils.command import build\nfrom scipy_distutils.command import build_py\nfrom scipy_distutils.command import build_ext\nfrom scipy_distutils.command import build_clib\nfrom scipy_distutils.command import build_flib\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\ndef setup(**attr):\n distclass = Distribution\n cmdclass = {'build': build.build,\n 'build_flib': build_flib.build_flib,\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 \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 return old_setup(**new_attr)\n", "methods": [ { "name": "setup", "long_name": "setup( ** attr )", "filename": "core.py", "nloc": 20, "complexity": 3, "token_count": 123, "parameters": [ "attr" ], "start_line": 21, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 } ], "methods_before": [ { "name": "setup", "long_name": "setup( ** attr )", "filename": "core.py", "nloc": 19, "complexity": 3, "token_count": 117, "parameters": [ "attr" ], "start_line": 20, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "setup", "long_name": "setup( ** attr )", "filename": "core.py", "nloc": 20, "complexity": 3, "token_count": 123, "parameters": [ "attr" ], "start_line": 21, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 } ], "nloc": 35, "complexity": 3, "token_count": 216, "diff_parsed": { "added": [ "from scipy_distutils.command import run_f2py", " 'run_f2py': run_f2py.run_f2py," ], "deleted": [] } }, { "old_path": "scipy_distutils/dist.py", "new_path": "scipy_distutils/dist.py", "filename": "dist.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -8,10 +8,21 @@ class Distribution (OldDistribution):\n def __init__ (self, attrs=None):\n self.fortran_libraries = None\n OldDistribution.__init__(self, attrs)\n+\n+ def has_f2py_sources (self):\n+ if self.has_ext_modules():\n+ for ext in self.ext_modules:\n+ for source in ext.sources:\n+ (base, file_ext) = os.path.splitext(source)\n+ if file_ext == \".pyf\": # f2py interface file\n+ return 1\n+ return 0\n \n def has_f_libraries(self):\n if self.fortran_libraries and len(self.fortran_libraries) > 0:\n return 1\n+ return self.has_f2py_sources() # f2py might generate fortran sources.\n+\n if hasattr(self,'_been_here_has_f_libraries'):\n return 0\n if self.has_ext_modules():\n", "added_lines": 11, "deleted_lines": 0, "source_code": "from distutils.dist import *\nfrom distutils.dist import Distribution as OldDistribution\nfrom distutils.errors import DistutilsSetupError\n\nfrom types import *\n\nclass Distribution (OldDistribution):\n def __init__ (self, attrs=None):\n self.fortran_libraries = None\n OldDistribution.__init__(self, attrs)\n\n def has_f2py_sources (self):\n if self.has_ext_modules():\n for ext in self.ext_modules:\n for source in ext.sources:\n (base, file_ext) = os.path.splitext(source)\n if file_ext == \".pyf\": # f2py interface file\n return 1\n return 0\n \n def has_f_libraries(self):\n if self.fortran_libraries and len(self.fortran_libraries) > 0:\n return 1\n return self.has_f2py_sources() # f2py might generate fortran sources.\n\n if hasattr(self,'_been_here_has_f_libraries'):\n return 0\n if self.has_ext_modules():\n # extension module sources may contain fortran files,\n # extract them to fortran_libraries.\n for ext in self.ext_modules:\n self.fortran_sources_to_flib(ext)\n self._been_here_has_f_libraries = None\n return self.fortran_libraries and len(self.fortran_libraries) > 0\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n for file in ext.sources:\n if match(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.fortran_libraries is None:\n self.fortran_libraries = []\n\n name = ext.name\n flib = None\n for n,d in self.fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {'sources':[]}\n self.fortran_libraries.append((name,flib))\n\n flib['sources'].extend(f_files)\n\n def check_data_file_list(self):\n \"\"\"Ensure that the list of data_files (presumably provided as a\n command option 'data_files') is valid, i.e. it is a list of\n 2-tuples, where the tuples are (name, list_of_libraries).\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\"\"\"\n print 'check_data_file_list'\n if type(self.data_files) is not ListType:\n raise DistutilsSetupError, \\\n \"'data_files' option must be a list of tuples\"\n\n for lib in self.data_files:\n if type(lib) is not TupleType and len(lib) != 2:\n raise DistutilsSetupError, \\\n \"each element of 'data_files' must a 2-tuple\"\n\n if type(lib[0]) is not StringType:\n raise DistutilsSetupError, \\\n \"first element of each tuple in 'data_files' \" + \\\n \"must be a string (the package with the data_file)\"\n\n if type(lib[1]) is not ListType:\n raise DistutilsSetupError, \\\n \"second element of each tuple in 'data_files' \" + \\\n \"must be a list of files.\"\n # for lib\n\n # check_data_file_list ()\n \n def get_data_files (self):\n print 'get_data_files'\n self.check_data_file_list()\n filenames = []\n \n # Gets data files specified\n for ext in self.data_files:\n filenames.extend(ext[1])\n\n return filenames\n", "source_code_before": "from distutils.dist import *\nfrom distutils.dist import Distribution as OldDistribution\nfrom distutils.errors import DistutilsSetupError\n\nfrom types import *\n\nclass Distribution (OldDistribution):\n def __init__ (self, attrs=None):\n self.fortran_libraries = None\n OldDistribution.__init__(self, attrs)\n \n def has_f_libraries(self):\n if self.fortran_libraries and len(self.fortran_libraries) > 0:\n return 1\n if hasattr(self,'_been_here_has_f_libraries'):\n return 0\n if self.has_ext_modules():\n # extension module sources may contain fortran files,\n # extract them to fortran_libraries.\n for ext in self.ext_modules:\n self.fortran_sources_to_flib(ext)\n self._been_here_has_f_libraries = None\n return self.fortran_libraries and len(self.fortran_libraries) > 0\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n for file in ext.sources:\n if match(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.fortran_libraries is None:\n self.fortran_libraries = []\n\n name = ext.name\n flib = None\n for n,d in self.fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {'sources':[]}\n self.fortran_libraries.append((name,flib))\n\n flib['sources'].extend(f_files)\n\n def check_data_file_list(self):\n \"\"\"Ensure that the list of data_files (presumably provided as a\n command option 'data_files') is valid, i.e. it is a list of\n 2-tuples, where the tuples are (name, list_of_libraries).\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\"\"\"\n print 'check_data_file_list'\n if type(self.data_files) is not ListType:\n raise DistutilsSetupError, \\\n \"'data_files' option must be a list of tuples\"\n\n for lib in self.data_files:\n if type(lib) is not TupleType and len(lib) != 2:\n raise DistutilsSetupError, \\\n \"each element of 'data_files' must a 2-tuple\"\n\n if type(lib[0]) is not StringType:\n raise DistutilsSetupError, \\\n \"first element of each tuple in 'data_files' \" + \\\n \"must be a string (the package with the data_file)\"\n\n if type(lib[1]) is not ListType:\n raise DistutilsSetupError, \\\n \"second element of each tuple in 'data_files' \" + \\\n \"must be a list of files.\"\n # for lib\n\n # check_data_file_list ()\n \n def get_data_files (self):\n print 'get_data_files'\n self.check_data_file_list()\n filenames = []\n \n # Gets data files specified\n for ext in self.data_files:\n filenames.extend(ext[1])\n\n return filenames\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , attrs = None )", "filename": "dist.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self", "attrs" ], "start_line": 8, "end_line": 10, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "dist.py", "nloc": 8, "complexity": 5, "token_count": 49, "parameters": [ "self" ], "start_line": 12, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "dist.py", "nloc": 11, "complexity": 7, "token_count": 75, "parameters": [ "self" ], "start_line": 21, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "dist.py", "nloc": 24, "complexity": 8, "token_count": 141, "parameters": [ "self", "ext" ], "start_line": 36, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "check_data_file_list", "long_name": "check_data_file_list( self )", "filename": "dist.py", "nloc": 17, "complexity": 7, "token_count": 92, "parameters": [ "self" ], "start_line": 69, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_data_files", "long_name": "get_data_files( self )", "filename": "dist.py", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [ "self" ], "start_line": 98, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , attrs = None )", "filename": "dist.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self", "attrs" ], "start_line": 8, "end_line": 10, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "dist.py", "nloc": 10, "complexity": 7, "token_count": 69, "parameters": [ "self" ], "start_line": 12, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "dist.py", "nloc": 24, "complexity": 8, "token_count": 141, "parameters": [ "self", "ext" ], "start_line": 25, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "check_data_file_list", "long_name": "check_data_file_list( self )", "filename": "dist.py", "nloc": 17, "complexity": 7, "token_count": 92, "parameters": [ "self" ], "start_line": 58, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_data_files", "long_name": "get_data_files( self )", "filename": "dist.py", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [ "self" ], "start_line": 87, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "dist.py", "nloc": 8, "complexity": 5, "token_count": 49, "parameters": [ "self" ], "start_line": 12, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "dist.py", "nloc": 11, "complexity": 7, "token_count": 75, "parameters": [ "self" ], "start_line": 21, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 } ], "nloc": 75, "complexity": 30, "token_count": 449, "diff_parsed": { "added": [ "", " def has_f2py_sources (self):", " if self.has_ext_modules():", " for ext in self.ext_modules:", " for source in ext.sources:", " (base, file_ext) = os.path.splitext(source)", " if file_ext == \".pyf\": # f2py interface file", " return 1", " return 0", " return self.has_f2py_sources() # f2py might generate fortran sources.", "" ], "deleted": [] } } ] }, { "hash": "830fc21645c00b53518609d68feec014605d3595", "msg": "version update", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-01-09T14:21:53+00:00", "author_timezone": 0, "committer_date": "2002-01-09T14:21:53+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "dda06dcb6c3b3b7c21eb5a41518b9a237345bef3" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/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/__version__.py", "new_path": "scipy_distutils/__version__.py", "filename": "__version__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n # This file is automatically updated with get_version\n # function from scipy_distutils.misc_utils.py\n-version = '0.5.21-alpha-56'\n-version_info = (0, 5, 21, 'alpha', 56)\n+version = '0.6.23-alpha-70'\n+version_info = (0, 6, 23, 'alpha', 70)\n", "added_lines": 2, "deleted_lines": 2, "source_code": "# This file is automatically updated with get_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.6.23-alpha-70'\nversion_info = (0, 6, 23, 'alpha', 70)\n", "source_code_before": "# This file is automatically updated with get_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.5.21-alpha-56'\nversion_info = (0, 5, 21, 'alpha', 56)\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 2, "complexity": 0, "token_count": 16, "diff_parsed": { "added": [ "version = '0.6.23-alpha-70'", "version_info = (0, 6, 23, 'alpha', 70)" ], "deleted": [ "version = '0.5.21-alpha-56'", "version_info = (0, 5, 21, 'alpha', 56)" ] } } ] }, { "hash": "6996767df452f83f6482ca12de762fc65cdafb76", "msg": "Fixed typo in run_f2py", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-01-09T15:26:47+00:00", "author_timezone": 0, "committer_date": "2002-01-09T15:26:47+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "830fc21645c00b53518609d68feec014605d3595" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/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/run_f2py.py", "new_path": "scipy_distutils/command/run_f2py.py", "filename": "run_f2py.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -123,7 +123,7 @@ def f2py_sources (self, sources, ext):\n \n f2py_options = []\n for i in ext.f2py_options:\n- f2py_opts.append('--'+i) # XXX: ???\n+ f2py_options.append('--'+i) # XXX: ???\n f2py_options = self.f2py_options + f2py_options\n \n # make sure the target dir exists\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom scipy_distutils.core import Command\n\nimport re,os\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.distribution.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n \"\"\"\n\n import f2py2e\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains defintions for exactly\n # one extension module.\n\n new_sources = []\n f2py_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n target_dir = self.build_dir\n print 'target_dir', target_dir\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n for line in f.xreadlines():\n m = module_name_re(line)\n if m:\n base = m.group('name')\n break\n f.close()\n if base != ext.name:\n # XXX: Should we do here more than just warn?\n self.warn('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext`))\n\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,base+fortran_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = fortran_target_file\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n f2py_options = []\n for i in ext.f2py_options:\n f2py_options.append('--'+i) # XXX: ???\n f2py_options = self.f2py_options + f2py_options\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n fortran_target = f2py_fortran_targets[source]\n if newer(source,target) or self.force:\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n\n print new_sources\n return new_sources\n # f2py_sources ()\n \n# class x\n", "source_code_before": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom scipy_distutils.core import Command\n\nimport re,os\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.distribution.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n \"\"\"\n\n import f2py2e\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains defintions for exactly\n # one extension module.\n\n new_sources = []\n f2py_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n target_dir = self.build_dir\n print 'target_dir', target_dir\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n for line in f.xreadlines():\n m = module_name_re(line)\n if m:\n base = m.group('name')\n break\n f.close()\n if base != ext.name:\n # XXX: Should we do here more than just warn?\n self.warn('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext`))\n\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,base+fortran_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = fortran_target_file\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n f2py_options = []\n for i in ext.f2py_options:\n f2py_opts.append('--'+i) # XXX: ???\n f2py_options = self.f2py_options + f2py_options\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n fortran_target = f2py_fortran_targets[source]\n if newer(source,target) or self.force:\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n\n print new_sources\n return new_sources\n # f2py_sources ()\n \n# class x\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 30, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 38, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 54, "complexity": 12, "token_count": 372, "parameters": [ "self", "sources", "ext" ], "start_line": 57, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 89, "top_nesting_level": 1 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 30, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 38, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 54, "complexity": 12, "token_count": 372, "parameters": [ "self", "sources", "ext" ], "start_line": 57, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 89, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 54, "complexity": 12, "token_count": 372, "parameters": [ "self", "sources", "ext" ], "start_line": 57, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 89, "top_nesting_level": 1 } ], "nloc": 90, "complexity": 18, "token_count": 574, "diff_parsed": { "added": [ " f2py_options.append('--'+i) # XXX: ???" ], "deleted": [ " f2py_opts.append('--'+i) # XXX: ???" ] } } ] }, { "hash": "40c05dba1aac683240967d768530fe5372207c35", "msg": "Fixed bug in run_f2py that detected names *__user__* as ext names", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-01-09T15:43:02+00:00", "author_timezone": 0, "committer_date": "2002-01-09T15:43:02+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "6996767df452f83f6482ca12de762fc65cdafb76" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 0, "insertions": 3, "lines": 3, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/command/run_f2py.py", "new_path": "scipy_distutils/command/run_f2py.py", "filename": "run_f2py.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -13,6 +13,7 @@\n import re,os\n \n module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\n+user_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?__user__[\\w_]*)',re.I).match\n \n class run_f2py(Command):\n \n@@ -96,6 +97,8 @@ def f2py_sources (self, sources, ext):\n for line in f.xreadlines():\n m = module_name_re(line)\n if m:\n+ if user_module_name_re(line): # skip *__user__* names\n+ continue\n base = m.group('name')\n break\n f.close()\n", "added_lines": 3, "deleted_lines": 0, "source_code": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom scipy_distutils.core import Command\n\nimport re,os\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?__user__[\\w_]*)',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.distribution.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n \"\"\"\n\n import f2py2e\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains defintions for exactly\n # one extension module.\n\n new_sources = []\n f2py_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n target_dir = self.build_dir\n print 'target_dir', target_dir\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n for line in f.xreadlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if base != ext.name:\n # XXX: Should we do here more than just warn?\n self.warn('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext`))\n\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,base+fortran_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = fortran_target_file\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n f2py_options = []\n for i in ext.f2py_options:\n f2py_options.append('--'+i) # XXX: ???\n f2py_options = self.f2py_options + f2py_options\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n fortran_target = f2py_fortran_targets[source]\n if newer(source,target) or self.force:\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n\n print new_sources\n return new_sources\n # f2py_sources ()\n \n# class x\n", "source_code_before": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom scipy_distutils.core import Command\n\nimport re,os\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.distribution.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n \"\"\"\n\n import f2py2e\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains defintions for exactly\n # one extension module.\n\n new_sources = []\n f2py_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n target_dir = self.build_dir\n print 'target_dir', target_dir\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n for line in f.xreadlines():\n m = module_name_re(line)\n if m:\n base = m.group('name')\n break\n f.close()\n if base != ext.name:\n # XXX: Should we do here more than just warn?\n self.warn('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext`))\n\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,base+fortran_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = fortran_target_file\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n f2py_options = []\n for i in ext.f2py_options:\n f2py_options.append('--'+i) # XXX: ???\n f2py_options = self.f2py_options + f2py_options\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n fortran_target = f2py_fortran_targets[source]\n if newer(source,target) or self.force:\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n\n print new_sources\n return new_sources\n # f2py_sources ()\n \n# class x\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 39, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 51, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 56, "complexity": 13, "token_count": 379, "parameters": [ "self", "sources", "ext" ], "start_line": 58, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 1 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 30, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 38, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 54, "complexity": 12, "token_count": 372, "parameters": [ "self", "sources", "ext" ], "start_line": 57, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 89, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 56, "complexity": 13, "token_count": 379, "parameters": [ "self", "sources", "ext" ], "start_line": 58, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 1 } ], "nloc": 93, "complexity": 19, "token_count": 596, "diff_parsed": { "added": [ "user_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?__user__[\\w_]*)',re.I).match", " if user_module_name_re(line): # skip *__user__* names", " continue" ], "deleted": [] } } ] }, { "hash": "b8ae576bfb13d9511b35a12b1b404527ff3131ab", "msg": "version serial increase", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-01-09T15:43:58+00:00", "author_timezone": 0, "committer_date": "2002-01-09T15:43:58+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "40c05dba1aac683240967d768530fe5372207c35" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/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/__version__.py", "new_path": "scipy_distutils/__version__.py", "filename": "__version__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n # This file is automatically updated with get_version\n # function from scipy_distutils.misc_utils.py\n-version = '0.6.23-alpha-70'\n-version_info = (0, 6, 23, 'alpha', 70)\n+version = '0.6.23-alpha-72'\n+version_info = (0, 6, 23, 'alpha', 72)\n", "added_lines": 2, "deleted_lines": 2, "source_code": "# This file is automatically updated with get_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.6.23-alpha-72'\nversion_info = (0, 6, 23, 'alpha', 72)\n", "source_code_before": "# This file is automatically updated with get_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.6.23-alpha-70'\nversion_info = (0, 6, 23, 'alpha', 70)\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 2, "complexity": 0, "token_count": 16, "diff_parsed": { "added": [ "version = '0.6.23-alpha-72'", "version_info = (0, 6, 23, 'alpha', 72)" ], "deleted": [ "version = '0.6.23-alpha-70'", "version_info = (0, 6, 23, 'alpha', 70)" ] } } ] }, { "hash": "98070b5a3dc9a5abf6a57ef6eb2b300181968f79", "msg": "Added -w90/95 flags to Intel compiler", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-01-09T18:00:39+00:00", "author_timezone": 0, "committer_date": "2002-01-09T18:00:39+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "b8ae576bfb13d9511b35a12b1b404527ff3131ab" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 1, "insertions": 5, "lines": 6, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -650,7 +650,7 @@ def __init__(self, fc = None, f90c = None):\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n- self.f77_switches = self.f77_switches + ' -FI '\n+ self.f77_switches = self.f77_switches + ' -FI -w90 -w95 '\n \n self.f77_opt = self.f90_opt = self.get_opt()\n \n@@ -816,13 +816,17 @@ def get_fortran_files(files):\n def find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\n for compiler_class in all_compilers:\n+ print vendor,compiler_class.vendor\n if vendor is not None and vendor != compiler_class.vendor:\n+ print 1\n continue\n+ print 2\n print compiler_class\n compiler = compiler_class(fc,f90c)\n if compiler.is_available():\n fcompiler = compiler\n break\n+ print 3,all_compilers\n return fcompiler\n \n all_compilers = [absoft_fortran_compiler,\n", "added_lines": 5, "deleted_lines": 1, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** Option --force has no effect when switching a compiler. One must\n manually remove .o files that were generated earlier by a\n different compiler.\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n \ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print compiler\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'%(self.fcompiler)\n else:\n self.announce(' using %s Fortran compiler' % fc)\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n\n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.has_f_libraries()\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def get_library_names(self):\n if not self.has_f_libraries():\n return None\n\n lib_names = [] \n\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n \n return lib_names\n\n # get_library_names ()\n\n def get_library_dirs(self):\n if not self.has_f_libraries():\n return []#None\n\n lib_dirs = [] \n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n if not self.has_f_libraries():\n return []#None\n\n lib_dirs = [] \n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n self.announce(\" building '%s' library\" % lib_name)\n \n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n\nclass fortran_compiler_base:\n\n vendor = None\n ver_match = None\n \n def __init__(self):\n # Default initialization. Constructors of derived classes MUST\n # call this functions.\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n self.libraries = []\n self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,dirty_files,module_dirs=None, temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + \\\n module_switch + ' -c ' + source + ' -o ' + object \n print cmd\n failure = os.system(cmd)\n if failure:\n raise ValueError, 'failure during compile' \n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None):\n lib_file = os.path.join(output_dir,'lib'+library_name+'.a')\n newer = distutils.dep_util.newer\n # This doesn't work -- no way to know if the file is in the archive\n #object_files = filter(lambda o,lib=lib_file:\\\n # distutils.dep_util.newer(o,lib),object_files)\n objects = string.join(object_files)\n if objects:\n cmd = 'ar -cur %s %s' % (lib_file,objects)\n print cmd\n os.system(cmd)\n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n #this compiles the files\n object_list = self.to_object(source_list,module_dirs,temp_dir)\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n #self.create_static_lib(object_list,library_name,temp_dir) \n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k)\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n obj,objects = objects[:20],objects[20:]\n self.create_static_lib(obj,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Is there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix... \n #print 'command:', self.ver_cmd\n exit_status, out_text = run_command(self.ver_cmd)\n #print exit_status, out_text\n if not exit_status:\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Sun'\n ver_match = r'f77: (?P[^\\s*,]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -pic '\n self.f77_opt = ' -fast -dalign '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -fixed ' # ??? why fixed?\n self.f90_opt = ' -fast -dalign '\n\n self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n #print 'sun:',self.library_dirs\n\n self.ver_cmd = self.f77_compiler + ' -V'\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = []\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n def get_extra_link_args(self):\n return ['-mimpure-text']\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n \n self.libraries = ['fortran', 'ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n self.ver_cmd = self.f77_compiler + ' -version'\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'g77 version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if sys.platform == 'win32':\n self.libraries = ['gcc','g2c']\n self.library_dirs = self.find_lib_directories()\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fpic '\n\n self.f77_switches = switches\n\n self.ver_cmd = self.f77_compiler + ' -v '\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n \n # only check for more optimization if g77 can handle\n # it.\n if self.get_version():\n if self.version[0]=='3': # is g77 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double ' \n return opt\n \n def find_lib_directories(self):\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix... \n exit_status, out_text = run_command('g77 -v')\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n lib_dir= m #m[0] \n return lib_dir\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n if sys.platform != 'win32':\n return [self.f77_compiler,'-shared']\n \n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f50/linux/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n \n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler for the Itanium\\(TM\\)-based applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)\\s+(?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n # XXX: is -shared needed?\n return [self.f77_compiler,'-shared']\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\n for compiler_class in all_compilers:\n print vendor,compiler_class.vendor\n if vendor is not None and vendor != compiler_class.vendor:\n print 1\n continue\n print 2\n print compiler_class\n compiler = compiler_class(fc,f90c)\n if compiler.is_available():\n fcompiler = compiler\n break\n print 3,all_compilers\n return fcompiler\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** Option --force has no effect when switching a compiler. One must\n manually remove .o files that were generated earlier by a\n different compiler.\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n \ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print compiler\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'%(self.fcompiler)\n else:\n self.announce(' using %s Fortran compiler' % fc)\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n\n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.has_f_libraries()\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def get_library_names(self):\n if not self.has_f_libraries():\n return None\n\n lib_names = [] \n\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n \n return lib_names\n\n # get_library_names ()\n\n def get_library_dirs(self):\n if not self.has_f_libraries():\n return []#None\n\n lib_dirs = [] \n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n if not self.has_f_libraries():\n return []#None\n\n lib_dirs = [] \n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n self.announce(\" building '%s' library\" % lib_name)\n \n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n\nclass fortran_compiler_base:\n\n vendor = None\n ver_match = None\n \n def __init__(self):\n # Default initialization. Constructors of derived classes MUST\n # call this functions.\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n self.libraries = []\n self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,dirty_files,module_dirs=None, temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + \\\n module_switch + ' -c ' + source + ' -o ' + object \n print cmd\n failure = os.system(cmd)\n if failure:\n raise ValueError, 'failure during compile' \n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None):\n lib_file = os.path.join(output_dir,'lib'+library_name+'.a')\n newer = distutils.dep_util.newer\n # This doesn't work -- no way to know if the file is in the archive\n #object_files = filter(lambda o,lib=lib_file:\\\n # distutils.dep_util.newer(o,lib),object_files)\n objects = string.join(object_files)\n if objects:\n cmd = 'ar -cur %s %s' % (lib_file,objects)\n print cmd\n os.system(cmd)\n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n #this compiles the files\n object_list = self.to_object(source_list,module_dirs,temp_dir)\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n #self.create_static_lib(object_list,library_name,temp_dir) \n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k)\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n obj,objects = objects[:20],objects[20:]\n self.create_static_lib(obj,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Is there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix... \n #print 'command:', self.ver_cmd\n exit_status, out_text = run_command(self.ver_cmd)\n #print exit_status, out_text\n if not exit_status:\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Sun'\n ver_match = r'f77: (?P[^\\s*,]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -pic '\n self.f77_opt = ' -fast -dalign '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -fixed ' # ??? why fixed?\n self.f90_opt = ' -fast -dalign '\n\n self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n #print 'sun:',self.library_dirs\n\n self.ver_cmd = self.f77_compiler + ' -V'\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = []\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n def get_extra_link_args(self):\n return ['-mimpure-text']\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n \n self.libraries = ['fortran', 'ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n self.ver_cmd = self.f77_compiler + ' -version'\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'g77 version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if sys.platform == 'win32':\n self.libraries = ['gcc','g2c']\n self.library_dirs = self.find_lib_directories()\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fpic '\n\n self.f77_switches = switches\n\n self.ver_cmd = self.f77_compiler + ' -v '\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n \n # only check for more optimization if g77 can handle\n # it.\n if self.get_version():\n if self.version[0]=='3': # is g77 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double ' \n return opt\n \n def find_lib_directories(self):\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix... \n exit_status, out_text = run_command('g77 -v')\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n lib_dir= m #m[0] \n return lib_dir\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n if sys.platform != 'win32':\n return [self.f77_compiler,'-shared']\n \n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f50/linux/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n \n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler for the Itanium\\(TM\\)-based applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)\\s+(?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n # XXX: is -shared needed?\n return [self.f77_compiler,'-shared']\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n print compiler_class\n compiler = compiler_class(fc,f90c)\n if compiler.is_available():\n fcompiler = compiler\n break\n return fcompiler\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 56, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 23, "parameters": [], "start_line": 65, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 11, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 99, "end_line": 111, "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_flib.py", "nloc": 17, "complexity": 3, "token_count": 104, "parameters": [ "self" ], "start_line": 115, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 135, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 138, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 4, "token_count": 58, "parameters": [ "self" ], "start_line": 145, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 161, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 174, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 187, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 122, "parameters": [ "self", "fortran_libraries" ], "start_line": 197, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 88, "parameters": [ "self" ], "start_line": 230, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 253, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 267, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 274, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 103, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 279, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 297, "end_line": 300, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 302, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 308, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None )", "filename": "build_flib.py", "nloc": 9, "complexity": 2, "token_count": 68, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug" ], "start_line": 311, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 10, "complexity": 2, "token_count": 85, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 324, "end_line": 345, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 347, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 356, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 10, "complexity": 4, "token_count": 66, "parameters": [ "self" ], "start_line": 359, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 379, "end_line": 380, "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": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 381, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 383, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 385, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 387, "end_line": 392, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 394, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 177, "parameters": [ "self", "fc", "f90c" ], "start_line": 403, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 443, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 450, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 98, "parameters": [ "self", "fc", "f90c" ], "start_line": 464, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 488, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 99, "parameters": [ "self" ], "start_line": 495, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 510, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 512, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 94, "parameters": [ "self", "fc", "f90c" ], "start_line": 521, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 547, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 549, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 103, "parameters": [ "self", "fc", "f90c" ], "start_line": 558, "end_line": 579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 21, "complexity": 10, "token_count": 120, "parameters": [ "self" ], "start_line": 581, "end_line": 604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 606, "end_line": 616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 20, "parameters": [ "self" ], "start_line": 618, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 623, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 140, "parameters": [ "self", "fc", "f90c" ], "start_line": 633, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 663, "end_line": 677, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 680, "end_line": 681, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 31, "parameters": [ "self", "fc", "f90c" ], "start_line": 689, "end_line": 692, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c" ], "start_line": 700, "end_line": 719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 721, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 725, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 128, "parameters": [ "self", "fc", "f90c" ], "start_line": 734, "end_line": 758, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 762, "end_line": 763, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 91, "parameters": [ "self", "fc", "f90c" ], "start_line": 770, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 794, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 798, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 803, "end_line": 805, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 807, "end_line": 808, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 810, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 813, "end_line": 814, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 5, "token_count": 73, "parameters": [ "vendor", "fc", "f90c" ], "start_line": 816, "end_line": 830, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 } ], "methods_before": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 56, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 23, "parameters": [], "start_line": 65, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 11, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 99, "end_line": 111, "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_flib.py", "nloc": 17, "complexity": 3, "token_count": 104, "parameters": [ "self" ], "start_line": 115, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 135, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 138, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 4, "token_count": 58, "parameters": [ "self" ], "start_line": 145, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 161, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 174, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 187, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 122, "parameters": [ "self", "fortran_libraries" ], "start_line": 197, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 88, "parameters": [ "self" ], "start_line": 230, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 253, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 267, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 274, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 103, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 279, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 297, "end_line": 300, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 302, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 308, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None )", "filename": "build_flib.py", "nloc": 9, "complexity": 2, "token_count": 68, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug" ], "start_line": 311, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 10, "complexity": 2, "token_count": 85, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 324, "end_line": 345, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 347, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 356, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 10, "complexity": 4, "token_count": 66, "parameters": [ "self" ], "start_line": 359, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 379, "end_line": 380, "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": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 381, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 383, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 385, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 387, "end_line": 392, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 394, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 177, "parameters": [ "self", "fc", "f90c" ], "start_line": 403, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 443, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 450, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 98, "parameters": [ "self", "fc", "f90c" ], "start_line": 464, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 488, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 99, "parameters": [ "self" ], "start_line": 495, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 510, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 512, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 94, "parameters": [ "self", "fc", "f90c" ], "start_line": 521, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 547, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 549, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 103, "parameters": [ "self", "fc", "f90c" ], "start_line": 558, "end_line": 579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 21, "complexity": 10, "token_count": 120, "parameters": [ "self" ], "start_line": 581, "end_line": 604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 606, "end_line": 616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 20, "parameters": [ "self" ], "start_line": 618, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 623, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 140, "parameters": [ "self", "fc", "f90c" ], "start_line": 633, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 663, "end_line": 677, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 680, "end_line": 681, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 31, "parameters": [ "self", "fc", "f90c" ], "start_line": 689, "end_line": 692, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c" ], "start_line": 700, "end_line": 719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 721, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 725, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 128, "parameters": [ "self", "fc", "f90c" ], "start_line": 734, "end_line": 758, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 762, "end_line": 763, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 91, "parameters": [ "self", "fc", "f90c" ], "start_line": 770, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 794, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 798, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 803, "end_line": 805, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 807, "end_line": 808, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 810, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 813, "end_line": 814, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 11, "complexity": 5, "token_count": 59, "parameters": [ "vendor", "fc", "f90c" ], "start_line": 816, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 5, "token_count": 73, "parameters": [ "vendor", "fc", "f90c" ], "start_line": 816, "end_line": 830, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 140, "parameters": [ "self", "fc", "f90c" ], "start_line": 633, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 } ], "nloc": 608, "complexity": 147, "token_count": 3473, "diff_parsed": { "added": [ " self.f77_switches = self.f77_switches + ' -FI -w90 -w95 '", " print vendor,compiler_class.vendor", " print 1", " print 2", " print 3,all_compilers" ], "deleted": [ " self.f77_switches = self.f77_switches + ' -FI '" ] } } ] }, { "hash": "7f46db2574e477ce4535334f7a2e51956b7f1599", "msg": "Added -w90/95 flags to Intel compiler", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-01-09T18:25:45+00:00", "author_timezone": 0, "committer_date": "2002-01-09T18:25:45+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "98070b5a3dc9a5abf6a57ef6eb2b300181968f79" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 4, "insertions": 0, "lines": 4, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -816,17 +816,13 @@ def get_fortran_files(files):\n def find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\n for compiler_class in all_compilers:\n- print vendor,compiler_class.vendor\n if vendor is not None and vendor != compiler_class.vendor:\n- print 1\n continue\n- print 2\n print compiler_class\n compiler = compiler_class(fc,f90c)\n if compiler.is_available():\n fcompiler = compiler\n break\n- print 3,all_compilers\n return fcompiler\n \n all_compilers = [absoft_fortran_compiler,\n", "added_lines": 0, "deleted_lines": 4, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** Option --force has no effect when switching a compiler. One must\n manually remove .o files that were generated earlier by a\n different compiler.\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n \ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print compiler\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'%(self.fcompiler)\n else:\n self.announce(' using %s Fortran compiler' % fc)\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n\n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.has_f_libraries()\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def get_library_names(self):\n if not self.has_f_libraries():\n return None\n\n lib_names = [] \n\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n \n return lib_names\n\n # get_library_names ()\n\n def get_library_dirs(self):\n if not self.has_f_libraries():\n return []#None\n\n lib_dirs = [] \n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n if not self.has_f_libraries():\n return []#None\n\n lib_dirs = [] \n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n self.announce(\" building '%s' library\" % lib_name)\n \n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n\nclass fortran_compiler_base:\n\n vendor = None\n ver_match = None\n \n def __init__(self):\n # Default initialization. Constructors of derived classes MUST\n # call this functions.\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n self.libraries = []\n self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,dirty_files,module_dirs=None, temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + \\\n module_switch + ' -c ' + source + ' -o ' + object \n print cmd\n failure = os.system(cmd)\n if failure:\n raise ValueError, 'failure during compile' \n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None):\n lib_file = os.path.join(output_dir,'lib'+library_name+'.a')\n newer = distutils.dep_util.newer\n # This doesn't work -- no way to know if the file is in the archive\n #object_files = filter(lambda o,lib=lib_file:\\\n # distutils.dep_util.newer(o,lib),object_files)\n objects = string.join(object_files)\n if objects:\n cmd = 'ar -cur %s %s' % (lib_file,objects)\n print cmd\n os.system(cmd)\n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n #this compiles the files\n object_list = self.to_object(source_list,module_dirs,temp_dir)\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n #self.create_static_lib(object_list,library_name,temp_dir) \n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k)\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n obj,objects = objects[:20],objects[20:]\n self.create_static_lib(obj,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Is there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix... \n #print 'command:', self.ver_cmd\n exit_status, out_text = run_command(self.ver_cmd)\n #print exit_status, out_text\n if not exit_status:\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Sun'\n ver_match = r'f77: (?P[^\\s*,]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -pic '\n self.f77_opt = ' -fast -dalign '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -fixed ' # ??? why fixed?\n self.f90_opt = ' -fast -dalign '\n\n self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n #print 'sun:',self.library_dirs\n\n self.ver_cmd = self.f77_compiler + ' -V'\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = []\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n def get_extra_link_args(self):\n return ['-mimpure-text']\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n \n self.libraries = ['fortran', 'ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n self.ver_cmd = self.f77_compiler + ' -version'\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'g77 version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if sys.platform == 'win32':\n self.libraries = ['gcc','g2c']\n self.library_dirs = self.find_lib_directories()\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fpic '\n\n self.f77_switches = switches\n\n self.ver_cmd = self.f77_compiler + ' -v '\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n \n # only check for more optimization if g77 can handle\n # it.\n if self.get_version():\n if self.version[0]=='3': # is g77 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double ' \n return opt\n \n def find_lib_directories(self):\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix... \n exit_status, out_text = run_command('g77 -v')\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n lib_dir= m #m[0] \n return lib_dir\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n if sys.platform != 'win32':\n return [self.f77_compiler,'-shared']\n \n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f50/linux/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n \n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler for the Itanium\\(TM\\)-based applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)\\s+(?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n # XXX: is -shared needed?\n return [self.f77_compiler,'-shared']\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n print compiler_class\n compiler = compiler_class(fc,f90c)\n if compiler.is_available():\n fcompiler = compiler\n break\n return fcompiler\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** Option --force has no effect when switching a compiler. One must\n manually remove .o files that were generated earlier by a\n different compiler.\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n \ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print compiler\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'%(self.fcompiler)\n else:\n self.announce(' using %s Fortran compiler' % fc)\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n\n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.has_f_libraries()\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def get_library_names(self):\n if not self.has_f_libraries():\n return None\n\n lib_names = [] \n\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n \n return lib_names\n\n # get_library_names ()\n\n def get_library_dirs(self):\n if not self.has_f_libraries():\n return []#None\n\n lib_dirs = [] \n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n if not self.has_f_libraries():\n return []#None\n\n lib_dirs = [] \n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n self.announce(\" building '%s' library\" % lib_name)\n \n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n\nclass fortran_compiler_base:\n\n vendor = None\n ver_match = None\n \n def __init__(self):\n # Default initialization. Constructors of derived classes MUST\n # call this functions.\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n self.libraries = []\n self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,dirty_files,module_dirs=None, temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + \\\n module_switch + ' -c ' + source + ' -o ' + object \n print cmd\n failure = os.system(cmd)\n if failure:\n raise ValueError, 'failure during compile' \n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None):\n lib_file = os.path.join(output_dir,'lib'+library_name+'.a')\n newer = distutils.dep_util.newer\n # This doesn't work -- no way to know if the file is in the archive\n #object_files = filter(lambda o,lib=lib_file:\\\n # distutils.dep_util.newer(o,lib),object_files)\n objects = string.join(object_files)\n if objects:\n cmd = 'ar -cur %s %s' % (lib_file,objects)\n print cmd\n os.system(cmd)\n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n #this compiles the files\n object_list = self.to_object(source_list,module_dirs,temp_dir)\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n #self.create_static_lib(object_list,library_name,temp_dir) \n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k)\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n obj,objects = objects[:20],objects[20:]\n self.create_static_lib(obj,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Is there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix... \n #print 'command:', self.ver_cmd\n exit_status, out_text = run_command(self.ver_cmd)\n #print exit_status, out_text\n if not exit_status:\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Sun'\n ver_match = r'f77: (?P[^\\s*,]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -pic '\n self.f77_opt = ' -fast -dalign '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -fixed ' # ??? why fixed?\n self.f90_opt = ' -fast -dalign '\n\n self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n #print 'sun:',self.library_dirs\n\n self.ver_cmd = self.f77_compiler + ' -V'\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = []\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n def get_extra_link_args(self):\n return ['-mimpure-text']\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n \n self.libraries = ['fortran', 'ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n self.ver_cmd = self.f77_compiler + ' -version'\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'g77 version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if sys.platform == 'win32':\n self.libraries = ['gcc','g2c']\n self.library_dirs = self.find_lib_directories()\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fpic '\n\n self.f77_switches = switches\n\n self.ver_cmd = self.f77_compiler + ' -v '\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n \n # only check for more optimization if g77 can handle\n # it.\n if self.get_version():\n if self.version[0]=='3': # is g77 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double ' \n return opt\n \n def find_lib_directories(self):\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix... \n exit_status, out_text = run_command('g77 -v')\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n lib_dir= m #m[0] \n return lib_dir\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n if sys.platform != 'win32':\n return [self.f77_compiler,'-shared']\n \n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f50/linux/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n \n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler for the Itanium\\(TM\\)-based applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)\\s+(?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n # XXX: is -shared needed?\n return [self.f77_compiler,'-shared']\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\n for compiler_class in all_compilers:\n print vendor,compiler_class.vendor\n if vendor is not None and vendor != compiler_class.vendor:\n print 1\n continue\n print 2\n print compiler_class\n compiler = compiler_class(fc,f90c)\n if compiler.is_available():\n fcompiler = compiler\n break\n print 3,all_compilers\n return fcompiler\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 56, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 23, "parameters": [], "start_line": 65, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 11, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 99, "end_line": 111, "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_flib.py", "nloc": 17, "complexity": 3, "token_count": 104, "parameters": [ "self" ], "start_line": 115, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 135, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 138, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 4, "token_count": 58, "parameters": [ "self" ], "start_line": 145, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 161, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 174, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 187, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 122, "parameters": [ "self", "fortran_libraries" ], "start_line": 197, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 88, "parameters": [ "self" ], "start_line": 230, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 253, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 267, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 274, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 103, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 279, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 297, "end_line": 300, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 302, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 308, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None )", "filename": "build_flib.py", "nloc": 9, "complexity": 2, "token_count": 68, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug" ], "start_line": 311, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 10, "complexity": 2, "token_count": 85, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 324, "end_line": 345, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 347, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 356, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 10, "complexity": 4, "token_count": 66, "parameters": [ "self" ], "start_line": 359, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 379, "end_line": 380, "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": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 381, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 383, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 385, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 387, "end_line": 392, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 394, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 177, "parameters": [ "self", "fc", "f90c" ], "start_line": 403, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 443, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 450, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 98, "parameters": [ "self", "fc", "f90c" ], "start_line": 464, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 488, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 99, "parameters": [ "self" ], "start_line": 495, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 510, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 512, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 94, "parameters": [ "self", "fc", "f90c" ], "start_line": 521, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 547, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 549, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 103, "parameters": [ "self", "fc", "f90c" ], "start_line": 558, "end_line": 579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 21, "complexity": 10, "token_count": 120, "parameters": [ "self" ], "start_line": 581, "end_line": 604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 606, "end_line": 616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 20, "parameters": [ "self" ], "start_line": 618, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 623, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 140, "parameters": [ "self", "fc", "f90c" ], "start_line": 633, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 663, "end_line": 677, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 680, "end_line": 681, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 31, "parameters": [ "self", "fc", "f90c" ], "start_line": 689, "end_line": 692, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c" ], "start_line": 700, "end_line": 719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 721, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 725, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 128, "parameters": [ "self", "fc", "f90c" ], "start_line": 734, "end_line": 758, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 762, "end_line": 763, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 91, "parameters": [ "self", "fc", "f90c" ], "start_line": 770, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 794, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 798, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 803, "end_line": 805, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 807, "end_line": 808, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 810, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 813, "end_line": 814, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 11, "complexity": 5, "token_count": 59, "parameters": [ "vendor", "fc", "f90c" ], "start_line": 816, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "methods_before": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 56, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 23, "parameters": [], "start_line": 65, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 11, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 99, "end_line": 111, "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_flib.py", "nloc": 17, "complexity": 3, "token_count": 104, "parameters": [ "self" ], "start_line": 115, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 135, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 138, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 4, "token_count": 58, "parameters": [ "self" ], "start_line": 145, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 161, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 174, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 187, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 122, "parameters": [ "self", "fortran_libraries" ], "start_line": 197, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 88, "parameters": [ "self" ], "start_line": 230, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 253, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 267, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 274, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 103, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 279, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 297, "end_line": 300, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 302, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 308, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None )", "filename": "build_flib.py", "nloc": 9, "complexity": 2, "token_count": 68, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug" ], "start_line": 311, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 10, "complexity": 2, "token_count": 85, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 324, "end_line": 345, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 347, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 356, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 10, "complexity": 4, "token_count": 66, "parameters": [ "self" ], "start_line": 359, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 379, "end_line": 380, "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": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 381, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 383, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 385, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 387, "end_line": 392, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 394, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 177, "parameters": [ "self", "fc", "f90c" ], "start_line": 403, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 443, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 450, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 98, "parameters": [ "self", "fc", "f90c" ], "start_line": 464, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 488, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 99, "parameters": [ "self" ], "start_line": 495, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 510, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 512, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 94, "parameters": [ "self", "fc", "f90c" ], "start_line": 521, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 547, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 549, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 103, "parameters": [ "self", "fc", "f90c" ], "start_line": 558, "end_line": 579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 21, "complexity": 10, "token_count": 120, "parameters": [ "self" ], "start_line": 581, "end_line": 604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 606, "end_line": 616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 20, "parameters": [ "self" ], "start_line": 618, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 623, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 140, "parameters": [ "self", "fc", "f90c" ], "start_line": 633, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 663, "end_line": 677, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 680, "end_line": 681, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 31, "parameters": [ "self", "fc", "f90c" ], "start_line": 689, "end_line": 692, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c" ], "start_line": 700, "end_line": 719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 721, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 725, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 128, "parameters": [ "self", "fc", "f90c" ], "start_line": 734, "end_line": 758, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 762, "end_line": 763, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 91, "parameters": [ "self", "fc", "f90c" ], "start_line": 770, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 794, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 798, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 803, "end_line": 805, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 807, "end_line": 808, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 810, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 813, "end_line": 814, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 5, "token_count": 73, "parameters": [ "vendor", "fc", "f90c" ], "start_line": 816, "end_line": 830, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 5, "token_count": 73, "parameters": [ "vendor", "fc", "f90c" ], "start_line": 816, "end_line": 830, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 } ], "nloc": 604, "complexity": 147, "token_count": 3459, "diff_parsed": { "added": [], "deleted": [ " print vendor,compiler_class.vendor", " print 1", " print 2", " print 3,all_compilers" ] } } ] }, { "hash": "7e0eac3f6ac7372c18dd0b629e56e6b7fc42175f", "msg": "Cleanup after introducing run_f2py", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-01-09T20:12:34+00:00", "author_timezone": 0, "committer_date": "2002-01-09T20:12:34+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "7f46db2574e477ce4535334f7a2e51956b7f1599" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 380, "insertions": 55, "lines": 435, "files": 7, "dmm_unit_size": 0.9214659685863874, "dmm_unit_complexity": 0.900523560209424, "dmm_unit_interfacing": 0.29842931937172773, "modified_files": [ { "old_path": "scipy_distutils/command/__init__.py", "new_path": "scipy_distutils/command/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -22,6 +22,7 @@\n 'build_ext',\n 'build_clib',\n 'build_flib',\n+ 'run_f2py',\n 'install',\n 'install_data',\n 'install_headers',\n", "added_lines": 1, "deleted_lines": 0, "source_code": "\"\"\"distutils.command\n\nPackage containing implementation of all the standard Distutils\ncommands.\"\"\"\n\n__revision__ = \"$Id$\"\n\ndistutils_all = [ 'build_py',\n 'build_scripts',\n 'clean',\n 'install_lib',\n 'install_scripts',\n 'bdist',\n 'bdist_dumb',\n 'bdist_rpm',\n 'bdist_wininst',\n ]\n\n__import__('distutils.command',globals(),locals(),distutils_all)\n\n__all__ = ['build',\n 'build_ext',\n 'build_clib',\n 'build_flib',\n 'run_f2py',\n 'install',\n 'install_data',\n 'install_headers',\n 'sdist',\n ] + distutils_all\n", "source_code_before": "\"\"\"distutils.command\n\nPackage containing implementation of all the standard Distutils\ncommands.\"\"\"\n\n__revision__ = \"$Id$\"\n\ndistutils_all = [ 'build_py',\n 'build_scripts',\n 'clean',\n 'install_lib',\n 'install_scripts',\n 'bdist',\n 'bdist_dumb',\n 'bdist_rpm',\n 'bdist_wininst',\n ]\n\n__import__('distutils.command',globals(),locals(),distutils_all)\n\n__all__ = ['build',\n 'build_ext',\n 'build_clib',\n 'build_flib',\n 'install',\n 'install_data',\n 'install_headers',\n 'sdist',\n ] + distutils_all\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 26, "complexity": 0, "token_count": 64, "diff_parsed": { "added": [ " 'run_f2py'," ], "deleted": [] } }, { "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": "@@ -1,18 +1,4 @@\n-\"\"\" Modified version of build_ext that handles fortran source files and f2py \n-\n- The f2py_sources() method is pretty much a copy of the swig_sources()\n- method in the standard build_ext class , but modified to use f2py. It\n- also.\n- \n- slightly_modified_standard_build_extension() is a verbatim copy of\n- the standard build_extension() method with a single line changed so that\n- preprocess_sources() is called instead of just swig_sources(). This new\n- function is a nice place to stick any source code preprocessing functions\n- needed.\n- \n- build_extension() handles building any needed static fortran libraries\n- first and then calls our slightly_modified_..._extenstion() to do the\n- rest of the processing in the (mostly) standard way. \n+\"\"\" Modified version of build_ext that handles fortran source files.\n \"\"\"\n \n import os, string\n@@ -23,18 +9,6 @@\n from distutils.command.build_ext import build_ext as old_build_ext\n \n class build_ext (old_build_ext):\n- user_options = old_build_ext.user_options + \\\n- [('f2py-options=', None,\n- \"command line arguments to f2py\")]\n-\n- def initialize_options(self):\n- old_build_ext.initialize_options(self)\n- self.f2py_options = None\n-\n- def finalize_options (self): \n- old_build_ext.finalize_options(self)\n- if self.f2py_options is None:\n- self.f2py_options = []\n \n def run (self):\n if self.distribution.has_f_libraries():\n@@ -50,20 +24,6 @@ def run (self):\n \n old_build_ext.run(self)\n \n- def preprocess_sources(self,sources,ext):\n- sources = self.swig_sources(sources)\n- if self.has_f2py_sources(sources): \n- sources = self.f2py_sources(sources,ext)\n- return sources\n- \n- def extra_include_dirs(self,sources):\n- if self.has_f2py_sources(sources): \n- import f2py2e\n- d = os.path.dirname(f2py2e.__file__)\n- return [os.path.join(d,'src')]\n- else:\n- return [] \n- \n def build_extension(self, ext):\n # support for building static fortran libraries\n if self.distribution.has_f_libraries():\n@@ -82,198 +42,6 @@ def build_extension(self, ext):\n self.compiler.linker_so = linker_so\n # end of fortran source support\n return old_build_ext.build_extension(self,ext)\n- \n- # f2py support handled slightly_modified..._extenstion.\n- return self.slightly_modified_standard_build_extension(ext)\n- \n- def slightly_modified_standard_build_extension(self, ext):\n- \"\"\"\n- This is pretty much a verbatim copy of the build_extension()\n- function in distutils with a single change to make it possible\n- to pre-process f2py as well as swig source files before \n- compilation.\n- \"\"\"\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- # ignore build-lib -- put the compiled extension into\n- # the source tree along with pure Python modules\n-\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-\n- if not (self.force or newer_group(sources, ext_filename, 'newer')):\n- self.announce(\"skipping '%s' extension (up-to-date)\" %\n- ext.name)\n- return\n- else:\n- self.announce(\"building '%s' extension\" % ext.name)\n-\n- # I copied this hole stinken function just to change from\n- # self.swig_sources to self.preprocess_sources...\n- # ! must come before the next line!!\n- include_dirs = self.extra_include_dirs(sources) + \\\n- (ext.include_dirs or [])\n- sources = self.preprocess_sources(sources, ext)\n- \n- # Next, compile the source code to object files.\n-\n- # XXX not honouring 'define_macros' or 'undef_macros' -- the\n- # CCompiler API needs to change to accommodate this, and I\n- # want to do one thing at a time!\n-\n- # Two possible sources for extra compiler arguments:\n- # - 'extra_compile_args' in Extension object\n- # - CFLAGS environment variable (not particularly\n- # elegant, but people seem to expect it and I\n- # guess it's useful)\n- # The environment variable should take precedence, and\n- # any sensible compiler will give precedence to later\n- # command line args. Hence we combine them in order:\n- extra_args = ext.extra_compile_args or []\n-\n- macros = ext.define_macros[:]\n- for undef in ext.undef_macros:\n- macros.append((undef,))\n-\n- # XXX and if we support CFLAGS, why not CC (compiler\n- # executable), CPPFLAGS (pre-processor options), and LDFLAGS\n- # (linker options) too?\n- # XXX should we use shlex to properly parse CFLAGS?\n-\n- if os.environ.has_key('CFLAGS'):\n- extra_args.extend(string.split(os.environ['CFLAGS']))\n-\n- objects = self.compiler.compile(sources,\n- output_dir=self.build_temp,\n- macros=macros,\n- include_dirs=include_dirs,\n- debug=self.debug,\n- extra_postargs=extra_args)\n-\n- # Now link the object files together into a \"shared object\" --\n- # of course, first we have to figure out all the other things\n- # that go into the mix.\n- if ext.extra_objects:\n- objects.extend(ext.extra_objects)\n- extra_args = ext.extra_link_args or []\n-\n- self.compiler.link_shared_object(\n- 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)\n-\n- def has_f2py_sources (self, sources):\n- print sources\n- for source in sources:\n- (base, ext) = os.path.splitext(source)\n- if ext == \".pyf\": # f2py interface file\n- return 1\n- print 'no!' \n- return 0\n- \n- def f2py_sources (self, sources, ext):\n-\n- \"\"\"Walk the list of source files in 'sources', looking for f2py\n- interface (.pyf) files. Run f2py on all that are found, and\n- return a modified 'sources' list with f2py source files replaced\n- by the generated C (or C++) files.\n- \"\"\"\n-\n- import f2py2e\n-\n- new_sources = []\n- new_include_dirs = []\n- f2py_sources = []\n- f2py_targets = {}\n-\n- # XXX this drops generated C/C++ files into the source tree, which\n- # is fine for developers who want to distribute the generated\n- # source -- but there should be an option to put f2py output in\n- # the temp dir.\n-\n- target_ext = 'module.c'\n- target_dir = self.build_temp\n- print 'target_dir', target_dir\n-\n- match_module = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',\n- re.I).match\n- \n- for source in sources:\n- (base, source_ext) = os.path.splitext(source)\n- (source_dir, base) = os.path.split(base)\n- if source_ext == \".pyf\": # f2py interface file\n- # get extension module name\n- f = open(source)\n- for line in f.xreadlines():\n- m = match_module(line)\n- if m:\n- base = m.group('name')\n- break\n- f.close()\n- if base != ext.name:\n- # XXX: Should we do here more than just warn?\n- print 'Warning: %s provides %s but this extension is %s' \\\n- % (source,`base`,`ext`)\n-\n- target_file = os.path.join(target_dir,base+target_ext)\n- new_sources.append(target_file)\n- f2py_sources.append(source)\n- f2py_targets[source] = new_sources[-1]\n- else:\n- new_sources.append(source)\n-\n- if not f2py_sources:\n- return new_sources\n-\n- # a bit of a hack, but I think it'll work. Just include one of\n- # the fortranobject.c files that was copied into most \n- d = os.path.dirname(f2py2e.__file__)\n- new_sources.append(os.path.join(d,'src','fortranobject.c'))\n- self.include_dirs.append(os.path.join(d,'src'))\n-\n- f2py_opts = []\n- f2py_options = ext.f2py_options + self.f2py_options\n- for i in f2py_options:\n- f2py_opts.append('--'+i)\n- f2py_opts = ['--build-dir',target_dir] + f2py_opts\n- \n- # make sure the target dir exists\n- from distutils.dir_util import mkpath\n- mkpath(target_dir)\n-\n- for source in f2py_sources:\n- target = f2py_targets[source]\n- if newer(source,target):\n- self.announce(\"f2py-ing %s to %s\" % (source, target))\n- self.announce(\"f2py-args: %s\" % f2py_options)\n- f2py2e.run_main(f2py_opts + [source]) \n- #ext.sources.extend(pyf.data[ext.name].get('fsrc') or [])\n- #self.distribution.fortran_sources_to_flib(ext)\n- print new_sources\n- return new_sources\n- # f2py_sources ()\n \n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n@@ -285,92 +53,3 @@ def get_source_files (self):\n filenames.extend(get_headers(get_directories(ext.sources)))\n \n return filenames\n-\n- def check_extensions_list (self, extensions):\n- \"\"\"\n- Very slightly modified to add f2py_options as a flag... argh.\n- \n- Ensure that the list of extensions (presumably provided as a\n- command option 'extensions') is valid, i.e. it is a list of\n- Extension objects. We also support the old-style list of 2-tuples,\n- where the tuples are (ext_name, build_info), which are converted to\n- Extension instances here.\n-\n- Raise DistutilsSetupError if the structure is invalid anywhere;\n- just returns otherwise.\n- \"\"\"\n- if type(extensions) is not ListType:\n- raise DistutilsSetupError, \\\n- \"'ext_modules' option must be a list of Extension instances\"\n- \n- for i in range(len(extensions)):\n- ext = extensions[i]\n- if isinstance(ext, Extension):\n- continue # OK! (assume type-checking done\n- # by Extension constructor)\n-\n- (ext_name, build_info) = ext\n- self.warn((\"old-style (ext_name, build_info) tuple found in \"\n- \"ext_modules for extension '%s'\" \n- \"-- please convert to Extension instance\" % ext_name))\n- if type(ext) is not TupleType and len(ext) != 2:\n- raise DistutilsSetupError, \\\n- (\"each element of 'ext_modules' option must be an \"\n- \"Extension instance or 2-tuple\")\n-\n- if not (type(ext_name) is StringType and\n- extension_name_re.match(ext_name)):\n- raise DistutilsSetupError, \\\n- (\"first element of each tuple in 'ext_modules' \"\n- \"must be the extension name (a string)\")\n-\n- if type(build_info) is not DictionaryType:\n- raise DistutilsSetupError, \\\n- (\"second element of each tuple in 'ext_modules' \"\n- \"must be a dictionary (build info)\")\n-\n- # OK, the (ext_name, build_info) dict is type-safe: convert it\n- # to an Extension instance.\n- ext = Extension(ext_name, build_info['sources'])\n-\n- # Easy stuff: one-to-one mapping from dict elements to\n- # instance attributes.\n- for key in ('include_dirs',\n- 'library_dirs',\n- 'libraries',\n- 'extra_objects',\n- 'extra_compile_args',\n- 'extra_link_args',\n- 'f2py_options'):\n- val = build_info.get(key)\n- if val is not None:\n- setattr(ext, key, val)\n-\n- # Medium-easy stuff: same syntax/semantics, different names.\n- ext.runtime_library_dirs = build_info.get('rpath')\n- if build_info.has_key('def_file'):\n- self.warn(\"'def_file' element of build info dict \"\n- \"no longer supported\")\n-\n- # Non-trivial stuff: 'macros' split into 'define_macros'\n- # and 'undef_macros'.\n- macros = build_info.get('macros')\n- if macros:\n- ext.define_macros = []\n- ext.undef_macros = []\n- for macro in macros:\n- if not (type(macro) is TupleType and\n- 1 <= len(macro) <= 2):\n- raise DistutilsSetupError, \\\n- (\"'macros' element of build info dict \"\n- \"must be 1- or 2-tuple\")\n- if len(macro) == 1:\n- ext.undef_macros.append(macro[0])\n- elif len(macro) == 2:\n- ext.define_macros.append(macro)\n-\n- extensions[i] = ext\n-\n- # for extensions\n-\n- # check_extensions_list ()\n", "added_lines": 1, "deleted_lines": 322, "source_code": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import *\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nclass build_ext (old_build_ext):\n \n def run (self):\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.libraries.extend(build_flib.get_library_names() or [])\n self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #runtime_dirs = build_flib.get_runtime_library_dirs()\n #self.runtime_library_dirs.extend(runtime_dirs or [])\n \n #?? what is this ??\n self.library_dirs.append(build_flib.build_flib)\n \n old_build_ext.run(self)\n\n def build_extension(self, ext):\n # support for building static fortran libraries\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []: \n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n # be sure to include fortran runtime library directory names\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n linker_so = build_flib.fcompiler.get_linker_so()\n if linker_so is not None:\n self.compiler.linker_so = linker_so\n # end of fortran source support\n return old_build_ext.build_extension(self,ext)\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files and f2py \n\n The f2py_sources() method is pretty much a copy of the swig_sources()\n method in the standard build_ext class , but modified to use f2py. It\n also.\n \n slightly_modified_standard_build_extension() is a verbatim copy of\n the standard build_extension() method with a single line changed so that\n preprocess_sources() is called instead of just swig_sources(). This new\n function is a nice place to stick any source code preprocessing functions\n needed.\n \n build_extension() handles building any needed static fortran libraries\n first and then calls our slightly_modified_..._extenstion() to do the\n rest of the processing in the (mostly) standard way. \n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import *\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nclass build_ext (old_build_ext):\n user_options = old_build_ext.user_options + \\\n [('f2py-options=', None,\n \"command line arguments to f2py\")]\n\n def initialize_options(self):\n old_build_ext.initialize_options(self)\n self.f2py_options = None\n\n def finalize_options (self): \n old_build_ext.finalize_options(self)\n if self.f2py_options is None:\n self.f2py_options = []\n \n def run (self):\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.libraries.extend(build_flib.get_library_names() or [])\n self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #self.library_dirs.extend(build_flib.get_library_dirs() or [])\n #runtime_dirs = build_flib.get_runtime_library_dirs()\n #self.runtime_library_dirs.extend(runtime_dirs or [])\n \n #?? what is this ??\n self.library_dirs.append(build_flib.build_flib)\n \n old_build_ext.run(self)\n\n def preprocess_sources(self,sources,ext):\n sources = self.swig_sources(sources)\n if self.has_f2py_sources(sources): \n sources = self.f2py_sources(sources,ext)\n return sources\n \n def extra_include_dirs(self,sources):\n if self.has_f2py_sources(sources): \n import f2py2e\n d = os.path.dirname(f2py2e.__file__)\n return [os.path.join(d,'src')]\n else:\n return [] \n \n def build_extension(self, ext):\n # support for building static fortran libraries\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []: \n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n # be sure to include fortran runtime library directory names\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n linker_so = build_flib.fcompiler.get_linker_so()\n if linker_so is not None:\n self.compiler.linker_so = linker_so\n # end of fortran source support\n return old_build_ext.build_extension(self,ext)\n \n # f2py support handled slightly_modified..._extenstion.\n return self.slightly_modified_standard_build_extension(ext)\n \n def slightly_modified_standard_build_extension(self, ext):\n \"\"\"\n This is pretty much a verbatim copy of the build_extension()\n function in distutils with a single change to make it possible\n to pre-process f2py as well as swig source files before \n compilation.\n \"\"\"\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 # ignore build-lib -- put the compiled extension into\n # the source tree along with pure Python modules\n\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\n if not (self.force or newer_group(sources, ext_filename, 'newer')):\n self.announce(\"skipping '%s' extension (up-to-date)\" %\n ext.name)\n return\n else:\n self.announce(\"building '%s' extension\" % ext.name)\n\n # I copied this hole stinken function just to change from\n # self.swig_sources to self.preprocess_sources...\n # ! must come before the next line!!\n include_dirs = self.extra_include_dirs(sources) + \\\n (ext.include_dirs or [])\n sources = self.preprocess_sources(sources, ext)\n \n # Next, compile the source code to object files.\n\n # XXX not honouring 'define_macros' or 'undef_macros' -- the\n # CCompiler API needs to change to accommodate this, and I\n # want to do one thing at a time!\n\n # Two possible sources for extra compiler arguments:\n # - 'extra_compile_args' in Extension object\n # - CFLAGS environment variable (not particularly\n # elegant, but people seem to expect it and I\n # guess it's useful)\n # The environment variable should take precedence, and\n # any sensible compiler will give precedence to later\n # command line args. Hence we combine them in order:\n extra_args = ext.extra_compile_args or []\n\n macros = ext.define_macros[:]\n for undef in ext.undef_macros:\n macros.append((undef,))\n\n # XXX and if we support CFLAGS, why not CC (compiler\n # executable), CPPFLAGS (pre-processor options), and LDFLAGS\n # (linker options) too?\n # XXX should we use shlex to properly parse CFLAGS?\n\n if os.environ.has_key('CFLAGS'):\n extra_args.extend(string.split(os.environ['CFLAGS']))\n\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_args)\n\n # Now link the object files together into a \"shared object\" --\n # of course, first we have to figure out all the other things\n # that go into the mix.\n if ext.extra_objects:\n objects.extend(ext.extra_objects)\n extra_args = ext.extra_link_args or []\n\n self.compiler.link_shared_object(\n 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)\n\n def has_f2py_sources (self, sources):\n print sources\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == \".pyf\": # f2py interface file\n return 1\n print 'no!' \n return 0\n \n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) files.\n \"\"\"\n\n import f2py2e\n\n new_sources = []\n new_include_dirs = []\n f2py_sources = []\n f2py_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n target_dir = self.build_temp\n print 'target_dir', target_dir\n\n match_module = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',\n re.I).match\n \n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n for line in f.xreadlines():\n m = match_module(line)\n if m:\n base = m.group('name')\n break\n f.close()\n if base != ext.name:\n # XXX: Should we do here more than just warn?\n print 'Warning: %s provides %s but this extension is %s' \\\n % (source,`base`,`ext`)\n\n target_file = os.path.join(target_dir,base+target_ext)\n new_sources.append(target_file)\n f2py_sources.append(source)\n f2py_targets[source] = new_sources[-1]\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n self.include_dirs.append(os.path.join(d,'src'))\n\n f2py_opts = []\n f2py_options = ext.f2py_options + self.f2py_options\n for i in f2py_options:\n f2py_opts.append('--'+i)\n f2py_opts = ['--build-dir',target_dir] + f2py_opts\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target):\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_opts + [source]) \n #ext.sources.extend(pyf.data[ext.name].get('fsrc') or [])\n #self.distribution.fortran_sources_to_flib(ext)\n print new_sources\n return new_sources\n # f2py_sources ()\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n def check_extensions_list (self, extensions):\n \"\"\"\n Very slightly modified to add f2py_options as a flag... argh.\n \n Ensure that the list of extensions (presumably provided as a\n command option 'extensions') is valid, i.e. it is a list of\n Extension objects. We also support the old-style list of 2-tuples,\n where the tuples are (ext_name, build_info), which are converted to\n Extension instances here.\n\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\n \"\"\"\n if type(extensions) is not ListType:\n raise DistutilsSetupError, \\\n \"'ext_modules' option must be a list of Extension instances\"\n \n for i in range(len(extensions)):\n ext = extensions[i]\n if isinstance(ext, Extension):\n continue # OK! (assume type-checking done\n # by Extension constructor)\n\n (ext_name, build_info) = ext\n self.warn((\"old-style (ext_name, build_info) tuple found in \"\n \"ext_modules for extension '%s'\" \n \"-- please convert to Extension instance\" % ext_name))\n if type(ext) is not TupleType and len(ext) != 2:\n raise DistutilsSetupError, \\\n (\"each element of 'ext_modules' option must be an \"\n \"Extension instance or 2-tuple\")\n\n if not (type(ext_name) is StringType and\n extension_name_re.match(ext_name)):\n raise DistutilsSetupError, \\\n (\"first element of each tuple in 'ext_modules' \"\n \"must be the extension name (a string)\")\n\n if type(build_info) is not DictionaryType:\n raise DistutilsSetupError, \\\n (\"second element of each tuple in 'ext_modules' \"\n \"must be a dictionary (build info)\")\n\n # OK, the (ext_name, build_info) dict is type-safe: convert it\n # to an Extension instance.\n ext = Extension(ext_name, build_info['sources'])\n\n # Easy stuff: one-to-one mapping from dict elements to\n # instance attributes.\n for key in ('include_dirs',\n 'library_dirs',\n 'libraries',\n 'extra_objects',\n 'extra_compile_args',\n 'extra_link_args',\n 'f2py_options'):\n val = build_info.get(key)\n if val is not None:\n setattr(ext, key, val)\n\n # Medium-easy stuff: same syntax/semantics, different names.\n ext.runtime_library_dirs = build_info.get('rpath')\n if build_info.has_key('def_file'):\n self.warn(\"'def_file' element of build info dict \"\n \"no longer supported\")\n\n # Non-trivial stuff: 'macros' split into 'define_macros'\n # and 'undef_macros'.\n macros = build_info.get('macros')\n if macros:\n ext.define_macros = []\n ext.undef_macros = []\n for macro in macros:\n if not (type(macro) is TupleType and\n 1 <= len(macro) <= 2):\n raise DistutilsSetupError, \\\n (\"'macros' element of build info dict \"\n \"must be 1- or 2-tuple\")\n if len(macro) == 1:\n ext.undef_macros.append(macro[0])\n elif len(macro) == 2:\n ext.define_macros.append(macro)\n\n extensions[i] = ext\n\n # for extensions\n\n # check_extensions_list ()\n", "methods": [ { "name": "run", "long_name": "run( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 4, "token_count": 68, "parameters": [ "self" ], "start_line": 13, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 15, "complexity": 6, "token_count": 107, "parameters": [ "self", "ext" ], "start_line": 27, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 46, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 34, "end_line": 37, "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": 7, "complexity": 4, "token_count": 68, "parameters": [ "self" ], "start_line": 39, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "preprocess_sources", "long_name": "preprocess_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "sources", "ext" ], "start_line": 53, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "extra_include_dirs", "long_name": "extra_include_dirs( self , sources )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "sources" ], "start_line": 59, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 16, "complexity": 6, "token_count": 114, "parameters": [ "self", "ext" ], "start_line": 67, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "slightly_modified_standard_build_extension", "long_name": "slightly_modified_standard_build_extension( self , ext )", "filename": "build_ext.py", "nloc": 53, "complexity": 12, "token_count": 390, "parameters": [ "self", "ext" ], "start_line": 89, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 97, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self , sources )", "filename": "build_ext.py", "nloc": 8, "complexity": 3, "token_count": 39, "parameters": [ "self", "sources" ], "start_line": 187, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 51, "complexity": 10, "token_count": 347, "parameters": [ "self", "sources", "ext" ], "start_line": 196, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 278, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_extensions_list", "long_name": "check_extensions_list( self , extensions )", "filename": "build_ext.py", "nloc": 55, "complexity": 18, "token_count": 308, "parameters": [ "self", "extensions" ], "start_line": 289, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 16, "complexity": 6, "token_count": 114, "parameters": [ "self", "ext" ], "start_line": 67, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "check_extensions_list", "long_name": "check_extensions_list( self , extensions )", "filename": "build_ext.py", "nloc": 55, "complexity": 18, "token_count": 308, "parameters": [ "self", "extensions" ], "start_line": 289, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 1 }, { "name": "preprocess_sources", "long_name": "preprocess_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "sources", "ext" ], "start_line": 53, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 34, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self , sources )", "filename": "build_ext.py", "nloc": 8, "complexity": 3, "token_count": 39, "parameters": [ "self", "sources" ], "start_line": 187, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_ext.py", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "build_ext.py", "nloc": 51, "complexity": 10, "token_count": 347, "parameters": [ "self", "sources", "ext" ], "start_line": 196, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 }, { "name": "slightly_modified_standard_build_extension", "long_name": "slightly_modified_standard_build_extension( self , ext )", "filename": "build_ext.py", "nloc": 53, "complexity": 12, "token_count": 390, "parameters": [ "self", "ext" ], "start_line": 89, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 97, "top_nesting_level": 1 }, { "name": "extra_include_dirs", "long_name": "extra_include_dirs( self , sources )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "sources" ], "start_line": 59, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "nloc": 37, "complexity": 12, "token_count": 267, "diff_parsed": { "added": [ "\"\"\" Modified version of build_ext that handles fortran source files." ], "deleted": [ "\"\"\" Modified version of build_ext that handles fortran source files and f2py", "", " The f2py_sources() method is pretty much a copy of the swig_sources()", " method in the standard build_ext class , but modified to use f2py. It", " also.", "", " slightly_modified_standard_build_extension() is a verbatim copy of", " the standard build_extension() method with a single line changed so that", " preprocess_sources() is called instead of just swig_sources(). This new", " function is a nice place to stick any source code preprocessing functions", " needed.", "", " build_extension() handles building any needed static fortran libraries", " first and then calls our slightly_modified_..._extenstion() to do the", " rest of the processing in the (mostly) standard way.", " user_options = old_build_ext.user_options + \\", " [('f2py-options=', None,", " \"command line arguments to f2py\")]", "", " def initialize_options(self):", " old_build_ext.initialize_options(self)", " self.f2py_options = None", "", " def finalize_options (self):", " old_build_ext.finalize_options(self)", " if self.f2py_options is None:", " self.f2py_options = []", " def preprocess_sources(self,sources,ext):", " sources = self.swig_sources(sources)", " if self.has_f2py_sources(sources):", " sources = self.f2py_sources(sources,ext)", " return sources", "", " def extra_include_dirs(self,sources):", " if self.has_f2py_sources(sources):", " import f2py2e", " d = os.path.dirname(f2py2e.__file__)", " return [os.path.join(d,'src')]", " else:", " return []", "", "", " # f2py support handled slightly_modified..._extenstion.", " return self.slightly_modified_standard_build_extension(ext)", "", " def slightly_modified_standard_build_extension(self, ext):", " \"\"\"", " This is pretty much a verbatim copy of the build_extension()", " function in distutils with a single change to make it possible", " to pre-process f2py as well as swig source files before", " compilation.", " \"\"\"", " sources = ext.sources", " if sources is None or type(sources) not in (ListType, TupleType):", " raise DistutilsSetupError, \\", " (\"in 'ext_modules' option (extension '%s'), \" +", " \"'sources' must be present and must be \" +", " \"a list of source filenames\") % ext.name", " sources = list(sources)", "", " fullname = self.get_ext_fullname(ext.name)", " if self.inplace:", " # ignore build-lib -- put the compiled extension into", " # the source tree along with pure Python modules", "", " modpath = string.split(fullname, '.')", " package = string.join(modpath[0:-1], '.')", " base = modpath[-1]", "", " build_py = self.get_finalized_command('build_py')", " package_dir = build_py.get_package_dir(package)", " ext_filename = os.path.join(package_dir,", " self.get_ext_filename(base))", " else:", " ext_filename = os.path.join(self.build_lib,", " self.get_ext_filename(fullname))", "", " if not (self.force or newer_group(sources, ext_filename, 'newer')):", " self.announce(\"skipping '%s' extension (up-to-date)\" %", " ext.name)", " return", " else:", " self.announce(\"building '%s' extension\" % ext.name)", "", " # I copied this hole stinken function just to change from", " # self.swig_sources to self.preprocess_sources...", " # ! must come before the next line!!", " include_dirs = self.extra_include_dirs(sources) + \\", " (ext.include_dirs or [])", " sources = self.preprocess_sources(sources, ext)", "", " # Next, compile the source code to object files.", "", " # XXX not honouring 'define_macros' or 'undef_macros' -- the", " # CCompiler API needs to change to accommodate this, and I", " # want to do one thing at a time!", "", " # Two possible sources for extra compiler arguments:", " # - 'extra_compile_args' in Extension object", " # - CFLAGS environment variable (not particularly", " # elegant, but people seem to expect it and I", " # guess it's useful)", " # The environment variable should take precedence, and", " # any sensible compiler will give precedence to later", " # command line args. Hence we combine them in order:", " extra_args = ext.extra_compile_args or []", "", " macros = ext.define_macros[:]", " for undef in ext.undef_macros:", " macros.append((undef,))", "", " # XXX and if we support CFLAGS, why not CC (compiler", " # executable), CPPFLAGS (pre-processor options), and LDFLAGS", " # (linker options) too?", " # XXX should we use shlex to properly parse CFLAGS?", "", " if os.environ.has_key('CFLAGS'):", " extra_args.extend(string.split(os.environ['CFLAGS']))", "", " objects = self.compiler.compile(sources,", " output_dir=self.build_temp,", " macros=macros,", " include_dirs=include_dirs,", " debug=self.debug,", " extra_postargs=extra_args)", "", " # Now link the object files together into a \"shared object\" --", " # of course, first we have to figure out all the other things", " # that go into the mix.", " if ext.extra_objects:", " objects.extend(ext.extra_objects)", " extra_args = ext.extra_link_args or []", "", " self.compiler.link_shared_object(", " objects, ext_filename,", " libraries=self.get_libraries(ext),", " library_dirs=ext.library_dirs,", " runtime_library_dirs=ext.runtime_library_dirs,", " extra_postargs=extra_args,", " export_symbols=self.get_export_symbols(ext),", " debug=self.debug,", " build_temp=self.build_temp)", "", " def has_f2py_sources (self, sources):", " print sources", " for source in sources:", " (base, ext) = os.path.splitext(source)", " if ext == \".pyf\": # f2py interface file", " return 1", " print 'no!'", " return 0", "", " def f2py_sources (self, sources, ext):", "", " \"\"\"Walk the list of source files in 'sources', looking for f2py", " interface (.pyf) files. Run f2py on all that are found, and", " return a modified 'sources' list with f2py source files replaced", " by the generated C (or C++) files.", " \"\"\"", "", " import f2py2e", "", " new_sources = []", " new_include_dirs = []", " f2py_sources = []", " f2py_targets = {}", "", " # XXX this drops generated C/C++ files into the source tree, which", " # is fine for developers who want to distribute the generated", " # source -- but there should be an option to put f2py output in", " # the temp dir.", "", " target_ext = 'module.c'", " target_dir = self.build_temp", " print 'target_dir', target_dir", "", " match_module = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',", " re.I).match", "", " for source in sources:", " (base, source_ext) = os.path.splitext(source)", " (source_dir, base) = os.path.split(base)", " if source_ext == \".pyf\": # f2py interface file", " # get extension module name", " f = open(source)", " for line in f.xreadlines():", " m = match_module(line)", " if m:", " base = m.group('name')", " break", " f.close()", " if base != ext.name:", " # XXX: Should we do here more than just warn?", " print 'Warning: %s provides %s but this extension is %s' \\", " % (source,`base`,`ext`)", "", " target_file = os.path.join(target_dir,base+target_ext)", " new_sources.append(target_file)", " f2py_sources.append(source)", " f2py_targets[source] = new_sources[-1]", " else:", " new_sources.append(source)", "", " if not f2py_sources:", " return new_sources", "", " # a bit of a hack, but I think it'll work. Just include one of", " # the fortranobject.c files that was copied into most", " d = os.path.dirname(f2py2e.__file__)", " new_sources.append(os.path.join(d,'src','fortranobject.c'))", " self.include_dirs.append(os.path.join(d,'src'))", "", " f2py_opts = []", " f2py_options = ext.f2py_options + self.f2py_options", " for i in f2py_options:", " f2py_opts.append('--'+i)", " f2py_opts = ['--build-dir',target_dir] + f2py_opts", "", " # make sure the target dir exists", " from distutils.dir_util import mkpath", " mkpath(target_dir)", "", " for source in f2py_sources:", " target = f2py_targets[source]", " if newer(source,target):", " self.announce(\"f2py-ing %s to %s\" % (source, target))", " self.announce(\"f2py-args: %s\" % f2py_options)", " f2py2e.run_main(f2py_opts + [source])", " #ext.sources.extend(pyf.data[ext.name].get('fsrc') or [])", " #self.distribution.fortran_sources_to_flib(ext)", " print new_sources", " return new_sources", " # f2py_sources ()", "", " def check_extensions_list (self, extensions):", " \"\"\"", " Very slightly modified to add f2py_options as a flag... argh.", "", " Ensure that the list of extensions (presumably provided as a", " command option 'extensions') is valid, i.e. it is a list of", " Extension objects. We also support the old-style list of 2-tuples,", " where the tuples are (ext_name, build_info), which are converted to", " Extension instances here.", "", " Raise DistutilsSetupError if the structure is invalid anywhere;", " just returns otherwise.", " \"\"\"", " if type(extensions) is not ListType:", " raise DistutilsSetupError, \\", " \"'ext_modules' option must be a list of Extension instances\"", "", " for i in range(len(extensions)):", " ext = extensions[i]", " if isinstance(ext, Extension):", " continue # OK! (assume type-checking done", " # by Extension constructor)", "", " (ext_name, build_info) = ext", " self.warn((\"old-style (ext_name, build_info) tuple found in \"", " \"ext_modules for extension '%s'\"", " \"-- please convert to Extension instance\" % ext_name))", " if type(ext) is not TupleType and len(ext) != 2:", " raise DistutilsSetupError, \\", " (\"each element of 'ext_modules' option must be an \"", " \"Extension instance or 2-tuple\")", "", " if not (type(ext_name) is StringType and", " extension_name_re.match(ext_name)):", " raise DistutilsSetupError, \\", " (\"first element of each tuple in 'ext_modules' \"", " \"must be the extension name (a string)\")", "", " if type(build_info) is not DictionaryType:", " raise DistutilsSetupError, \\", " (\"second element of each tuple in 'ext_modules' \"", " \"must be a dictionary (build info)\")", "", " # OK, the (ext_name, build_info) dict is type-safe: convert it", " # to an Extension instance.", " ext = Extension(ext_name, build_info['sources'])", "", " # Easy stuff: one-to-one mapping from dict elements to", " # instance attributes.", " for key in ('include_dirs',", " 'library_dirs',", " 'libraries',", " 'extra_objects',", " 'extra_compile_args',", " 'extra_link_args',", " 'f2py_options'):", " val = build_info.get(key)", " if val is not None:", " setattr(ext, key, val)", "", " # Medium-easy stuff: same syntax/semantics, different names.", " ext.runtime_library_dirs = build_info.get('rpath')", " if build_info.has_key('def_file'):", " self.warn(\"'def_file' element of build info dict \"", " \"no longer supported\")", "", " # Non-trivial stuff: 'macros' split into 'define_macros'", " # and 'undef_macros'.", " macros = build_info.get('macros')", " if macros:", " ext.define_macros = []", " ext.undef_macros = []", " for macro in macros:", " if not (type(macro) is TupleType and", " 1 <= len(macro) <= 2):", " raise DistutilsSetupError, \\", " (\"'macros' element of build info dict \"", " \"must be 1- or 2-tuple\")", " if len(macro) == 1:", " ext.undef_macros.append(macro[0])", " elif len(macro) == 2:", " ext.define_macros.append(macro)", "", " extensions[i] = ext", "", " # for extensions", "", " # check_extensions_list ()" ] } }, { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -16,9 +16,6 @@\n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n- *** Option --force has no effect when switching a compiler. One must\n- manually remove .o files that were generated earlier by a\n- different compiler.\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n@@ -133,7 +130,8 @@ def finalize_options (self):\n # finalize_options()\n \n def has_f_libraries(self):\n- return self.distribution.has_f_libraries()\n+ return self.distribution.fortran_libraries \\\n+ and len(self.distribution.fortran_libraries) > 0\n \n def run (self):\n if not self.has_f_libraries():\n", "added_lines": 2, "deleted_lines": 4, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n \ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print compiler\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'%(self.fcompiler)\n else:\n self.announce(' using %s Fortran compiler' % fc)\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n\n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def get_library_names(self):\n if not self.has_f_libraries():\n return None\n\n lib_names = [] \n\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n \n return lib_names\n\n # get_library_names ()\n\n def get_library_dirs(self):\n if not self.has_f_libraries():\n return []#None\n\n lib_dirs = [] \n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n if not self.has_f_libraries():\n return []#None\n\n lib_dirs = [] \n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n self.announce(\" building '%s' library\" % lib_name)\n \n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n\nclass fortran_compiler_base:\n\n vendor = None\n ver_match = None\n \n def __init__(self):\n # Default initialization. Constructors of derived classes MUST\n # call this functions.\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n self.libraries = []\n self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,dirty_files,module_dirs=None, temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + \\\n module_switch + ' -c ' + source + ' -o ' + object \n print cmd\n failure = os.system(cmd)\n if failure:\n raise ValueError, 'failure during compile' \n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None):\n lib_file = os.path.join(output_dir,'lib'+library_name+'.a')\n newer = distutils.dep_util.newer\n # This doesn't work -- no way to know if the file is in the archive\n #object_files = filter(lambda o,lib=lib_file:\\\n # distutils.dep_util.newer(o,lib),object_files)\n objects = string.join(object_files)\n if objects:\n cmd = 'ar -cur %s %s' % (lib_file,objects)\n print cmd\n os.system(cmd)\n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n #this compiles the files\n object_list = self.to_object(source_list,module_dirs,temp_dir)\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n #self.create_static_lib(object_list,library_name,temp_dir) \n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k)\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n obj,objects = objects[:20],objects[20:]\n self.create_static_lib(obj,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Is there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix... \n #print 'command:', self.ver_cmd\n exit_status, out_text = run_command(self.ver_cmd)\n #print exit_status, out_text\n if not exit_status:\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Sun'\n ver_match = r'f77: (?P[^\\s*,]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -pic '\n self.f77_opt = ' -fast -dalign '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -fixed ' # ??? why fixed?\n self.f90_opt = ' -fast -dalign '\n\n self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n #print 'sun:',self.library_dirs\n\n self.ver_cmd = self.f77_compiler + ' -V'\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = []\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n def get_extra_link_args(self):\n return ['-mimpure-text']\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n \n self.libraries = ['fortran', 'ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n self.ver_cmd = self.f77_compiler + ' -version'\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'g77 version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if sys.platform == 'win32':\n self.libraries = ['gcc','g2c']\n self.library_dirs = self.find_lib_directories()\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fpic '\n\n self.f77_switches = switches\n\n self.ver_cmd = self.f77_compiler + ' -v '\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n \n # only check for more optimization if g77 can handle\n # it.\n if self.get_version():\n if self.version[0]=='3': # is g77 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double ' \n return opt\n \n def find_lib_directories(self):\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix... \n exit_status, out_text = run_command('g77 -v')\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n lib_dir= m #m[0] \n return lib_dir\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n if sys.platform != 'win32':\n return [self.f77_compiler,'-shared']\n \n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f50/linux/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n \n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler for the Itanium\\(TM\\)-based applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)\\s+(?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n # XXX: is -shared needed?\n return [self.f77_compiler,'-shared']\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n print compiler_class\n compiler = compiler_class(fc,f90c)\n if compiler.is_available():\n fcompiler = compiler\n break\n return fcompiler\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** Option --force has no effect when switching a compiler. One must\n manually remove .o files that were generated earlier by a\n different compiler.\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n \ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print compiler\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'%(self.fcompiler)\n else:\n self.announce(' using %s Fortran compiler' % fc)\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n\n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.has_f_libraries()\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def get_library_names(self):\n if not self.has_f_libraries():\n return None\n\n lib_names = [] \n\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n \n return lib_names\n\n # get_library_names ()\n\n def get_library_dirs(self):\n if not self.has_f_libraries():\n return []#None\n\n lib_dirs = [] \n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n if not self.has_f_libraries():\n return []#None\n\n lib_dirs = [] \n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n self.announce(\" building '%s' library\" % lib_name)\n \n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n\nclass fortran_compiler_base:\n\n vendor = None\n ver_match = None\n \n def __init__(self):\n # Default initialization. Constructors of derived classes MUST\n # call this functions.\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n self.libraries = []\n self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,dirty_files,module_dirs=None, temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + \\\n module_switch + ' -c ' + source + ' -o ' + object \n print cmd\n failure = os.system(cmd)\n if failure:\n raise ValueError, 'failure during compile' \n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None):\n lib_file = os.path.join(output_dir,'lib'+library_name+'.a')\n newer = distutils.dep_util.newer\n # This doesn't work -- no way to know if the file is in the archive\n #object_files = filter(lambda o,lib=lib_file:\\\n # distutils.dep_util.newer(o,lib),object_files)\n objects = string.join(object_files)\n if objects:\n cmd = 'ar -cur %s %s' % (lib_file,objects)\n print cmd\n os.system(cmd)\n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n #this compiles the files\n object_list = self.to_object(source_list,module_dirs,temp_dir)\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n #self.create_static_lib(object_list,library_name,temp_dir) \n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k)\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n obj,objects = objects[:20],objects[20:]\n self.create_static_lib(obj,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Is there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix... \n #print 'command:', self.ver_cmd\n exit_status, out_text = run_command(self.ver_cmd)\n #print exit_status, out_text\n if not exit_status:\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Sun'\n ver_match = r'f77: (?P[^\\s*,]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -pic '\n self.f77_opt = ' -fast -dalign '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -fixed ' # ??? why fixed?\n self.f90_opt = ' -fast -dalign '\n\n self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n #print 'sun:',self.library_dirs\n\n self.ver_cmd = self.f77_compiler + ' -V'\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = []\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n def get_extra_link_args(self):\n return ['-mimpure-text']\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n \n self.libraries = ['fortran', 'ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n self.ver_cmd = self.f77_compiler + ' -version'\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'g77 version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if sys.platform == 'win32':\n self.libraries = ['gcc','g2c']\n self.library_dirs = self.find_lib_directories()\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fpic '\n\n self.f77_switches = switches\n\n self.ver_cmd = self.f77_compiler + ' -v '\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n \n # only check for more optimization if g77 can handle\n # it.\n if self.get_version():\n if self.version[0]=='3': # is g77 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double ' \n return opt\n \n def find_lib_directories(self):\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix... \n exit_status, out_text = run_command('g77 -v')\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n lib_dir= m #m[0] \n return lib_dir\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n if sys.platform != 'win32':\n return [self.f77_compiler,'-shared']\n \n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f50/linux/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n \n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler for the Itanium\\(TM\\)-based applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)\\s+(?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n # XXX: is -shared needed?\n return [self.f77_compiler,'-shared']\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n print compiler_class\n compiler = compiler_class(fc,f90c)\n if compiler.is_available():\n fcompiler = compiler\n break\n return fcompiler\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 53, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 23, "parameters": [], "start_line": 62, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 11, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 96, "end_line": 108, "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_flib.py", "nloc": 17, "complexity": 3, "token_count": 104, "parameters": [ "self" ], "start_line": 112, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 132, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 136, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 4, "token_count": 58, "parameters": [ "self" ], "start_line": 143, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 159, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 172, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 185, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 122, "parameters": [ "self", "fortran_libraries" ], "start_line": 195, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 88, "parameters": [ "self" ], "start_line": 228, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 251, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 265, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 272, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 103, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 277, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 295, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 300, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 306, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None )", "filename": "build_flib.py", "nloc": 9, "complexity": 2, "token_count": 68, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug" ], "start_line": 309, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 10, "complexity": 2, "token_count": 85, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 322, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 345, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 354, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 10, "complexity": 4, "token_count": 66, "parameters": [ "self" ], "start_line": 357, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 377, "end_line": 378, "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": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 379, "end_line": 380, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 381, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 383, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 385, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 392, "end_line": 393, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 177, "parameters": [ "self", "fc", "f90c" ], "start_line": 401, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 441, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 448, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 98, "parameters": [ "self", "fc", "f90c" ], "start_line": 462, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 486, "end_line": 491, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 99, "parameters": [ "self" ], "start_line": 493, "end_line": 507, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 508, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 510, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 94, "parameters": [ "self", "fc", "f90c" ], "start_line": 519, "end_line": 537, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 539, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 542, "end_line": 544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 545, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 547, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 103, "parameters": [ "self", "fc", "f90c" ], "start_line": 556, "end_line": 577, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 21, "complexity": 10, "token_count": 120, "parameters": [ "self" ], "start_line": 579, "end_line": 602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 604, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 20, "parameters": [ "self" ], "start_line": 616, "end_line": 619, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 621, "end_line": 622, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 140, "parameters": [ "self", "fc", "f90c" ], "start_line": 631, "end_line": 659, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 661, "end_line": 675, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 678, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 31, "parameters": [ "self", "fc", "f90c" ], "start_line": 687, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c" ], "start_line": 698, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 719, "end_line": 721, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 723, "end_line": 724, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 128, "parameters": [ "self", "fc", "f90c" ], "start_line": 732, "end_line": 756, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 760, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 91, "parameters": [ "self", "fc", "f90c" ], "start_line": 768, "end_line": 790, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 792, "end_line": 794, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 796, "end_line": 798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 801, "end_line": 803, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 805, "end_line": 806, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 808, "end_line": 809, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 811, "end_line": 812, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 11, "complexity": 5, "token_count": 59, "parameters": [ "vendor", "fc", "f90c" ], "start_line": 814, "end_line": 824, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "methods_before": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 56, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 23, "parameters": [], "start_line": 65, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 11, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 99, "end_line": 111, "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_flib.py", "nloc": 17, "complexity": 3, "token_count": 104, "parameters": [ "self" ], "start_line": 115, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 135, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 138, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 4, "token_count": 58, "parameters": [ "self" ], "start_line": 145, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 161, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 174, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 187, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 122, "parameters": [ "self", "fortran_libraries" ], "start_line": 197, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 88, "parameters": [ "self" ], "start_line": 230, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 13, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 253, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 267, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 274, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 103, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 279, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 297, "end_line": 300, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 302, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 308, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None )", "filename": "build_flib.py", "nloc": 9, "complexity": 2, "token_count": 68, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug" ], "start_line": 311, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 10, "complexity": 2, "token_count": 85, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 324, "end_line": 345, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 347, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 356, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 10, "complexity": 4, "token_count": 66, "parameters": [ "self" ], "start_line": 359, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 379, "end_line": 380, "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": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 381, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 383, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 385, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 387, "end_line": 392, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 394, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 177, "parameters": [ "self", "fc", "f90c" ], "start_line": 403, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 443, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 450, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 98, "parameters": [ "self", "fc", "f90c" ], "start_line": 464, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 488, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 99, "parameters": [ "self" ], "start_line": 495, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 510, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 512, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 94, "parameters": [ "self", "fc", "f90c" ], "start_line": 521, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 547, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 549, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 103, "parameters": [ "self", "fc", "f90c" ], "start_line": 558, "end_line": 579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 21, "complexity": 10, "token_count": 120, "parameters": [ "self" ], "start_line": 581, "end_line": 604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 606, "end_line": 616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 20, "parameters": [ "self" ], "start_line": 618, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 623, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 140, "parameters": [ "self", "fc", "f90c" ], "start_line": 633, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 663, "end_line": 677, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 680, "end_line": 681, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 31, "parameters": [ "self", "fc", "f90c" ], "start_line": 689, "end_line": 692, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c" ], "start_line": 700, "end_line": 719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 721, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 725, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 128, "parameters": [ "self", "fc", "f90c" ], "start_line": 734, "end_line": 758, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 762, "end_line": 763, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 91, "parameters": [ "self", "fc", "f90c" ], "start_line": 770, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 794, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 798, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 803, "end_line": 805, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 807, "end_line": 808, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 810, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 813, "end_line": 814, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", "filename": "build_flib.py", "nloc": 11, "complexity": 5, "token_count": 59, "parameters": [ "vendor", "fc", "f90c" ], "start_line": 816, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 132, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 } ], "nloc": 602, "complexity": 148, "token_count": 3469, "diff_parsed": { "added": [ " return self.distribution.fortran_libraries \\", " and len(self.distribution.fortran_libraries) > 0" ], "deleted": [ " *** Option --force has no effect when switching a compiler. One must", " manually remove .o files that were generated earlier by a", " different compiler.", " return self.distribution.has_f_libraries()" ] } }, { "old_path": "scipy_distutils/command/run_f2py.py", "new_path": "scipy_distutils/command/run_f2py.py", "filename": "run_f2py.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -14,6 +14,7 @@\n \n module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\n user_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?__user__[\\w_]*)',re.I).match\n+fortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n \n class run_f2py(Command):\n \n@@ -24,6 +25,8 @@ class run_f2py(Command):\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n+ ('no-wrap-functions', None,\n+ \"do not generate wrappers for Fortran functions,etc.\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n@@ -32,6 +35,7 @@ def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n+ self.no_wrap_functions = None\n self.f2py_options = []\n # initialize_options()\n \n@@ -45,14 +49,21 @@ def finalize_options (self):\n \n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n+ if self.no_wrap_functions is not None:\n+ self.f2py_options.append('--no-wrap-functions')\n \n # finalize_options()\n \n def run (self):\n if self.distribution.has_ext_modules():\n+ # XXX: might need also\n+ # build_flib = self.get_finalized_command('build_flib')\n+ # ...\n+ # for getting extra f2py_options that are specific to\n+ # the given fortran compiler.\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n- self.distribution.fortran_sources_to_flib(ext)\n+ self.fortran_sources_to_flib(ext)\n # run()\n \n def f2py_sources (self, sources, ext):\n@@ -78,11 +89,6 @@ def f2py_sources (self, sources, ext):\n f2py_targets = {}\n f2py_fortran_targets = {}\n \n- # XXX this drops generated C/C++ files into the source tree, which\n- # is fine for developers who want to distribute the generated\n- # source -- but there should be an option to put f2py output in\n- # the temp dir.\n-\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n target_dir = self.build_dir\n@@ -91,7 +97,7 @@ def f2py_sources (self, sources, ext):\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n- if source_ext == \".pyf\": # f2py interface file\n+ if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n for line in f.xreadlines():\n@@ -144,8 +150,42 @@ def f2py_sources (self, sources, ext):\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n \n- print new_sources\n return new_sources\n+\n # f2py_sources ()\n+\n+ def fortran_sources_to_flib(self, ext):\n+ \"\"\"\n+ Extract fortran files from ext.sources and append them to\n+ fortran_libraries item having the same name as ext.\n+ \"\"\"\n+ sources = []\n+ f_files = []\n+\n+ for file in ext.sources:\n+ if fortran_ext_re(file):\n+ f_files.append(file)\n+ else:\n+ sources.append(file)\n+ if not f_files:\n+ return\n+\n+ ext.sources = sources\n+\n+ if self.distribution.fortran_libraries is None:\n+ self.distribution.fortran_libraries = []\n+ fortran_libraries = self.distribution.fortran_libraries\n+\n+ name = ext.name\n+ flib = None\n+ for n,d in fortran_libraries:\n+ if n == name:\n+ flib = d\n+ break\n+ if flib is None:\n+ flib = {'sources':[]}\n+ fortran_libraries.append((name,flib))\n+\n+ flib['sources'].extend(f_files)\n \n-# class x\n+# class run_f2py\n", "added_lines": 49, "deleted_lines": 9, "source_code": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom scipy_distutils.core import Command\n\nimport re,os\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?__user__[\\w_]*)',re.I).match\nfortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('no-wrap-functions', None,\n \"do not generate wrappers for Fortran functions,etc.\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.no_wrap_functions = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n if self.no_wrap_functions is not None:\n self.f2py_options.append('--no-wrap-functions')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n # XXX: might need also\n # build_flib = self.get_finalized_command('build_flib')\n # ...\n # for getting extra f2py_options that are specific to\n # the given fortran compiler.\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n \"\"\"\n\n import f2py2e\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains defintions for exactly\n # one extension module.\n\n new_sources = []\n f2py_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n target_dir = self.build_dir\n print 'target_dir', target_dir\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n for line in f.xreadlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if base != ext.name:\n # XXX: Should we do here more than just warn?\n self.warn('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext`))\n\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,base+fortran_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = fortran_target_file\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n f2py_options = []\n for i in ext.f2py_options:\n f2py_options.append('--'+i) # XXX: ???\n f2py_options = self.f2py_options + f2py_options\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n fortran_target = f2py_fortran_targets[source]\n if newer(source,target) or self.force:\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n name = ext.name\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {'sources':[]}\n fortran_libraries.append((name,flib))\n\n flib['sources'].extend(f_files)\n \n# class run_f2py\n", "source_code_before": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom scipy_distutils.core import Command\n\nimport re,os\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?__user__[\\w_]*)',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.distribution.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\"Walk the list of source files in 'sources', looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n \"\"\"\n\n import f2py2e\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains defintions for exactly\n # one extension module.\n\n new_sources = []\n f2py_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n\n # XXX this drops generated C/C++ files into the source tree, which\n # is fine for developers who want to distribute the generated\n # source -- but there should be an option to put f2py output in\n # the temp dir.\n\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n target_dir = self.build_dir\n print 'target_dir', target_dir\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n for line in f.xreadlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if base != ext.name:\n # XXX: Should we do here more than just warn?\n self.warn('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext`))\n\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,base+fortran_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = fortran_target_file\n else:\n new_sources.append(source)\n\n if not f2py_sources:\n return new_sources\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n f2py_options = []\n for i in ext.f2py_options:\n f2py_options.append('--'+i) # XXX: ???\n f2py_options = self.f2py_options + f2py_options\n \n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n for source in f2py_sources:\n target = f2py_targets[source]\n fortran_target = f2py_fortran_targets[source]\n if newer(source,target) or self.force:\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-args: %s\" % f2py_options)\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n\n print new_sources\n return new_sources\n # f2py_sources ()\n \n# class x\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 34, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 9, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 43, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 57, "end_line": 66, "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 , ext )", "filename": "run_f2py.py", "nloc": 55, "complexity": 13, "token_count": 377, "parameters": [ "self", "sources", "ext" ], "start_line": 69, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 24, "complexity": 8, "token_count": 133, "parameters": [ "self", "ext" ], "start_line": 157, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 39, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 51, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 56, "complexity": 13, "token_count": 379, "parameters": [ "self", "sources", "ext" ], "start_line": 58, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 34, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 55, "complexity": 13, "token_count": 377, "parameters": [ "self", "sources", "ext" ], "start_line": 69, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 57, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 24, "complexity": 8, "token_count": 133, "parameters": [ "self", "ext" ], "start_line": 157, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 9, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 43, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "nloc": 122, "complexity": 28, "token_count": 770, "diff_parsed": { "added": [ "fortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match", " ('no-wrap-functions', None,", " \"do not generate wrappers for Fortran functions,etc.\"),", " self.no_wrap_functions = None", " if self.no_wrap_functions is not None:", " self.f2py_options.append('--no-wrap-functions')", " # XXX: might need also", " # build_flib = self.get_finalized_command('build_flib')", " # ...", " # for getting extra f2py_options that are specific to", " # the given fortran compiler.", " self.fortran_sources_to_flib(ext)", " if source_ext == \".pyf\": # f2py interface file", "", "", " def fortran_sources_to_flib(self, ext):", " \"\"\"", " Extract fortran files from ext.sources and append them to", " fortran_libraries item having the same name as ext.", " \"\"\"", " sources = []", " f_files = []", "", " for file in ext.sources:", " if fortran_ext_re(file):", " f_files.append(file)", " else:", " sources.append(file)", " if not f_files:", " return", "", " ext.sources = sources", "", " if self.distribution.fortran_libraries is None:", " self.distribution.fortran_libraries = []", " fortran_libraries = self.distribution.fortran_libraries", "", " name = ext.name", " flib = None", " for n,d in fortran_libraries:", " if n == name:", " flib = d", " break", " if flib is None:", " flib = {'sources':[]}", " fortran_libraries.append((name,flib))", "", " flib['sources'].extend(f_files)", "# class run_f2py" ], "deleted": [ " self.distribution.fortran_sources_to_flib(ext)", " # XXX this drops generated C/C++ files into the source tree, which", " # is fine for developers who want to distribute the generated", " # source -- but there should be an option to put f2py output in", " # the temp dir.", "", " if source_ext == \".pyf\": # f2py interface file", " print new_sources", "# class x" ] } }, { "old_path": "scipy_distutils/core.py", "new_path": "scipy_distutils/core.py", "filename": "core.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -25,7 +25,7 @@ def setup(**attr):\n 'build_ext': build_ext.build_ext,\n 'build_py': build_py.build_py, \n 'build_clib': build_clib.build_clib,\n- 'run_f2py': run_f2py.run_f2py,\n+ 'run_f2py': run_f2py.run_f2py,\n 'sdist': sdist.sdist,\n 'install_data': install_data.install_data,\n 'install': install.install,\n", "added_lines": 1, "deleted_lines": 1, "source_code": "from distutils.core import *\nfrom distutils.core import setup as old_setup\n\nfrom distutils.cmd import Command\nfrom scipy_distutils.extension import Extension\n\n# Our dist is different than the standard one.\nfrom scipy_distutils.dist import Distribution\n\nfrom scipy_distutils.command import build\nfrom scipy_distutils.command import build_py\nfrom scipy_distutils.command import build_ext\nfrom scipy_distutils.command import build_clib\nfrom scipy_distutils.command import build_flib\nfrom scipy_distutils.command import run_f2py\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\ndef setup(**attr):\n distclass = Distribution\n cmdclass = {'build': build.build,\n 'build_flib': build_flib.build_flib,\n 'build_ext': build_ext.build_ext,\n 'build_py': build_py.build_py, \n 'build_clib': build_clib.build_clib,\n 'run_f2py': run_f2py.run_f2py,\n 'sdist': sdist.sdist,\n 'install_data': install_data.install_data,\n 'install': install.install,\n 'install_headers': install_headers.install_headers\n }\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 return old_setup(**new_attr)\n", "source_code_before": "from distutils.core import *\nfrom distutils.core import setup as old_setup\n\nfrom distutils.cmd import Command\nfrom scipy_distutils.extension import Extension\n\n# Our dist is different than the standard one.\nfrom scipy_distutils.dist import Distribution\n\nfrom scipy_distutils.command import build\nfrom scipy_distutils.command import build_py\nfrom scipy_distutils.command import build_ext\nfrom scipy_distutils.command import build_clib\nfrom scipy_distutils.command import build_flib\nfrom scipy_distutils.command import run_f2py\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\ndef setup(**attr):\n distclass = Distribution\n cmdclass = {'build': build.build,\n 'build_flib': build_flib.build_flib,\n 'build_ext': build_ext.build_ext,\n 'build_py': build_py.build_py, \n 'build_clib': build_clib.build_clib,\n 'run_f2py': run_f2py.run_f2py,\n 'sdist': sdist.sdist,\n 'install_data': install_data.install_data,\n 'install': install.install,\n 'install_headers': install_headers.install_headers\n }\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 return old_setup(**new_attr)\n", "methods": [ { "name": "setup", "long_name": "setup( ** attr )", "filename": "core.py", "nloc": 20, "complexity": 3, "token_count": 123, "parameters": [ "attr" ], "start_line": 21, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 } ], "methods_before": [ { "name": "setup", "long_name": "setup( ** attr )", "filename": "core.py", "nloc": 20, "complexity": 3, "token_count": 123, "parameters": [ "attr" ], "start_line": 21, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "setup", "long_name": "setup( ** attr )", "filename": "core.py", "nloc": 20, "complexity": 3, "token_count": 123, "parameters": [ "attr" ], "start_line": 21, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 } ], "nloc": 35, "complexity": 3, "token_count": 216, "diff_parsed": { "added": [ " 'run_f2py': run_f2py.run_f2py," ], "deleted": [ " 'run_f2py': run_f2py.run_f2py," ] } }, { "old_path": "scipy_distutils/dist.py", "new_path": "scipy_distutils/dist.py", "filename": "dist.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -23,49 +23,6 @@ def has_f_libraries(self):\n return 1\n return self.has_f2py_sources() # f2py might generate fortran sources.\n \n- if hasattr(self,'_been_here_has_f_libraries'):\n- return 0\n- if self.has_ext_modules():\n- # extension module sources may contain fortran files,\n- # extract them to fortran_libraries.\n- for ext in self.ext_modules:\n- self.fortran_sources_to_flib(ext)\n- self._been_here_has_f_libraries = None\n- return self.fortran_libraries and len(self.fortran_libraries) > 0\n-\n- def fortran_sources_to_flib(self, ext):\n- \"\"\"\n- Extract fortran files from ext.sources and append them to\n- fortran_libraries item having the same name as ext.\n- \"\"\"\n- sources = []\n- f_files = []\n- match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n- for file in ext.sources:\n- if match(file):\n- f_files.append(file)\n- else:\n- sources.append(file)\n- if not f_files:\n- return\n-\n- ext.sources = sources\n-\n- if self.fortran_libraries is None:\n- self.fortran_libraries = []\n-\n- name = ext.name\n- flib = None\n- for n,d in self.fortran_libraries:\n- if n == name:\n- flib = d\n- break\n- if flib is None:\n- flib = {'sources':[]}\n- self.fortran_libraries.append((name,flib))\n-\n- flib['sources'].extend(f_files)\n-\n def check_data_file_list(self):\n \"\"\"Ensure that the list of data_files (presumably provided as a\n command option 'data_files') is valid, i.e. it is a list of\n", "added_lines": 0, "deleted_lines": 43, "source_code": "from distutils.dist import *\nfrom distutils.dist import Distribution as OldDistribution\nfrom distutils.errors import DistutilsSetupError\n\nfrom types import *\n\nclass Distribution (OldDistribution):\n def __init__ (self, attrs=None):\n self.fortran_libraries = None\n OldDistribution.__init__(self, attrs)\n\n def has_f2py_sources (self):\n if self.has_ext_modules():\n for ext in self.ext_modules:\n for source in ext.sources:\n (base, file_ext) = os.path.splitext(source)\n if file_ext == \".pyf\": # f2py interface file\n return 1\n return 0\n \n def has_f_libraries(self):\n if self.fortran_libraries and len(self.fortran_libraries) > 0:\n return 1\n return self.has_f2py_sources() # f2py might generate fortran sources.\n\n def check_data_file_list(self):\n \"\"\"Ensure that the list of data_files (presumably provided as a\n command option 'data_files') is valid, i.e. it is a list of\n 2-tuples, where the tuples are (name, list_of_libraries).\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\"\"\"\n print 'check_data_file_list'\n if type(self.data_files) is not ListType:\n raise DistutilsSetupError, \\\n \"'data_files' option must be a list of tuples\"\n\n for lib in self.data_files:\n if type(lib) is not TupleType and len(lib) != 2:\n raise DistutilsSetupError, \\\n \"each element of 'data_files' must a 2-tuple\"\n\n if type(lib[0]) is not StringType:\n raise DistutilsSetupError, \\\n \"first element of each tuple in 'data_files' \" + \\\n \"must be a string (the package with the data_file)\"\n\n if type(lib[1]) is not ListType:\n raise DistutilsSetupError, \\\n \"second element of each tuple in 'data_files' \" + \\\n \"must be a list of files.\"\n # for lib\n\n # check_data_file_list ()\n \n def get_data_files (self):\n print 'get_data_files'\n self.check_data_file_list()\n filenames = []\n \n # Gets data files specified\n for ext in self.data_files:\n filenames.extend(ext[1])\n\n return filenames\n", "source_code_before": "from distutils.dist import *\nfrom distutils.dist import Distribution as OldDistribution\nfrom distutils.errors import DistutilsSetupError\n\nfrom types import *\n\nclass Distribution (OldDistribution):\n def __init__ (self, attrs=None):\n self.fortran_libraries = None\n OldDistribution.__init__(self, attrs)\n\n def has_f2py_sources (self):\n if self.has_ext_modules():\n for ext in self.ext_modules:\n for source in ext.sources:\n (base, file_ext) = os.path.splitext(source)\n if file_ext == \".pyf\": # f2py interface file\n return 1\n return 0\n \n def has_f_libraries(self):\n if self.fortran_libraries and len(self.fortran_libraries) > 0:\n return 1\n return self.has_f2py_sources() # f2py might generate fortran sources.\n\n if hasattr(self,'_been_here_has_f_libraries'):\n return 0\n if self.has_ext_modules():\n # extension module sources may contain fortran files,\n # extract them to fortran_libraries.\n for ext in self.ext_modules:\n self.fortran_sources_to_flib(ext)\n self._been_here_has_f_libraries = None\n return self.fortran_libraries and len(self.fortran_libraries) > 0\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n for file in ext.sources:\n if match(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.fortran_libraries is None:\n self.fortran_libraries = []\n\n name = ext.name\n flib = None\n for n,d in self.fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {'sources':[]}\n self.fortran_libraries.append((name,flib))\n\n flib['sources'].extend(f_files)\n\n def check_data_file_list(self):\n \"\"\"Ensure that the list of data_files (presumably provided as a\n command option 'data_files') is valid, i.e. it is a list of\n 2-tuples, where the tuples are (name, list_of_libraries).\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\"\"\"\n print 'check_data_file_list'\n if type(self.data_files) is not ListType:\n raise DistutilsSetupError, \\\n \"'data_files' option must be a list of tuples\"\n\n for lib in self.data_files:\n if type(lib) is not TupleType and len(lib) != 2:\n raise DistutilsSetupError, \\\n \"each element of 'data_files' must a 2-tuple\"\n\n if type(lib[0]) is not StringType:\n raise DistutilsSetupError, \\\n \"first element of each tuple in 'data_files' \" + \\\n \"must be a string (the package with the data_file)\"\n\n if type(lib[1]) is not ListType:\n raise DistutilsSetupError, \\\n \"second element of each tuple in 'data_files' \" + \\\n \"must be a list of files.\"\n # for lib\n\n # check_data_file_list ()\n \n def get_data_files (self):\n print 'get_data_files'\n self.check_data_file_list()\n filenames = []\n \n # Gets data files specified\n for ext in self.data_files:\n filenames.extend(ext[1])\n\n return filenames\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , attrs = None )", "filename": "dist.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self", "attrs" ], "start_line": 8, "end_line": 10, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "dist.py", "nloc": 8, "complexity": 5, "token_count": 49, "parameters": [ "self" ], "start_line": 12, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "dist.py", "nloc": 4, "complexity": 3, "token_count": 27, "parameters": [ "self" ], "start_line": 21, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_data_file_list", "long_name": "check_data_file_list( self )", "filename": "dist.py", "nloc": 17, "complexity": 7, "token_count": 92, "parameters": [ "self" ], "start_line": 26, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_data_files", "long_name": "get_data_files( self )", "filename": "dist.py", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [ "self" ], "start_line": 55, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , attrs = None )", "filename": "dist.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self", "attrs" ], "start_line": 8, "end_line": 10, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "dist.py", "nloc": 8, "complexity": 5, "token_count": 49, "parameters": [ "self" ], "start_line": 12, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "dist.py", "nloc": 11, "complexity": 7, "token_count": 75, "parameters": [ "self" ], "start_line": 21, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "dist.py", "nloc": 24, "complexity": 8, "token_count": 141, "parameters": [ "self", "ext" ], "start_line": 36, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "check_data_file_list", "long_name": "check_data_file_list( self )", "filename": "dist.py", "nloc": 17, "complexity": 7, "token_count": 92, "parameters": [ "self" ], "start_line": 69, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_data_files", "long_name": "get_data_files( self )", "filename": "dist.py", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [ "self" ], "start_line": 98, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "dist.py", "nloc": 24, "complexity": 8, "token_count": 141, "parameters": [ "self", "ext" ], "start_line": 36, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "dist.py", "nloc": 11, "complexity": 7, "token_count": 75, "parameters": [ "self" ], "start_line": 21, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 } ], "nloc": 44, "complexity": 18, "token_count": 259, "diff_parsed": { "added": [], "deleted": [ " if hasattr(self,'_been_here_has_f_libraries'):", " return 0", " if self.has_ext_modules():", " # extension module sources may contain fortran files,", " # extract them to fortran_libraries.", " for ext in self.ext_modules:", " self.fortran_sources_to_flib(ext)", " self._been_here_has_f_libraries = None", " return self.fortran_libraries and len(self.fortran_libraries) > 0", "", " def fortran_sources_to_flib(self, ext):", " \"\"\"", " Extract fortran files from ext.sources and append them to", " fortran_libraries item having the same name as ext.", " \"\"\"", " sources = []", " f_files = []", " match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match", " for file in ext.sources:", " if match(file):", " f_files.append(file)", " else:", " sources.append(file)", " if not f_files:", " return", "", " ext.sources = sources", "", " if self.fortran_libraries is None:", " self.fortran_libraries = []", "", " name = ext.name", " flib = None", " for n,d in self.fortran_libraries:", " if n == name:", " flib = d", " break", " if flib is None:", " flib = {'sources':[]}", " self.fortran_libraries.append((name,flib))", "", " flib['sources'].extend(f_files)", "" ] } }, { "old_path": "scipy_distutils/misc_util.py", "new_path": "scipy_distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -97,7 +97,7 @@ def update_version(release_level='alpha',\n print 'updating version in %s' % version_file\n version_file = os.path.abspath(version_file)\n f = open(version_file,'w')\n- f.write('# This file is automatically updated with get_version\\n'\\\n+ f.write('# This file is automatically updated with update_version\\n'\\\n '# function from scipy_distutils.misc_utils.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n", "added_lines": 1, "deleted_lines": 1, "source_code": "import os,sys,string\n\ndef update_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n overwrite_version_py = 1):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . If the version information is different from the one\n found in the /__version__.py file, update_version updates\n the file automatically. The version information will be always\n increasing in time.\n If CVS tree does not exist (e.g. as in distribution packages),\n return the version string found from /__version__.py.\n If no version information is available, return None.\n\n Default version string is in the form\n\n ..--\n\n The items have the following meanings:\n\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n\n \"\"\"\n # Open issues:\n # *** Recommend or not to add __version__.py file to CVS\n # repository? If it is in CVS, then when commiting, the\n # version information will change, but __version__.py\n # is commited with old version information to CVS. To get\n # __version__.py also up to date in CVS repository, \n # a second commit of the __version__.py file is required.\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version_dict = {'major':major,'minor':minor,'micro':micro,\n 'release_level':release_level,'serial':serial\n }\n version = version_template % version_dict\n\n if version != old_version:\n print 'version increase detected: %s -> %s'%(old_version,version)\n version_file = os.path.join(path,'__version__.py')\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n % (version_file)\n return version\n print 'updating version in %s' % version_file\n version_file = os.path.abspath(version_file)\n f = open(version_file,'w')\n f.write('# This file is automatically updated with update_version\\n'\\\n '# function from scipy_distutils.misc_utils.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n ):\n return update_version(release_level = release_level,path = path,\n version_template = version_template,\n major = major,overwrite_version_py = 0)\n\n\ndef get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n d1,d2 = map(eval,string.split(items[2],'.')[-2:])\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\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 #import scipy_distutils.setup\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\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() file 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():\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n return d\n\ndef merge_config_dicts(config_list):\n result = default_config_dict() \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 pyf_extensions(parent_package = '',\n sources = [],\n include_dirs = [],\n define_macros = [],\n undef_macros = [],\n library_dirs = [],\n libraries = [],\n runtime_library_dirs = [],\n extra_objects = [],\n extra_compile_args = [],\n extra_link_args = [],\n export_symbols = [],\n f2py_options = [],\n f2py_wrap_functions = 1,\n f2py_debug_capi = 0,\n f2py_build_dir = '.',\n ):\n \"\"\" Return a list of Extension instances defined by .pyf files listed\n in sources list.\n \n f2py_opts is a list of options passed to the f2py runner.\n Option --no-setup is forced. Other possible options are\n --build-dir \n --[no-]wrap-functions\n \n Note: This requires that f2py2e is installed on your machine\n \"\"\"\n from scipy_distutils.core import Extension\n import f2py2e \n \n if parent_package:\n parent_package = parent_package + '.' \n \n f2py_opts = f2py_options or []\n if not f2py_wrap_functions:\n f2py_opts.append('--no-wrap-functions')\n if f2py_debug_capi:\n f2py_opts.append('--debug-capi')\n if '--setup' not in f2py_opts:\n f2py_opts.append('--no-setup')\n f2py_opts.extend(['--build-dir',f2py_build_dir])\n\n pyf_files, sources = f2py2e.f2py2e.filter_files('(?i)','[.]pyf',sources)\n\n pyf = f2py2e.run_main(pyf_files+f2py_opts)\n\n include_dirs = include_dirs + pyf.get_include_dirs()\n ext_modules = []\n\n for name in pyf.get_names():\n ext = Extension(parent_package+name,\n pyf.get_sources(name) + sources,\n include_dirs = include_dirs,\n library_dirs = library_dirs,\n libraries = libraries,\n define_macros = define_macros,\n undef_macros = undef_macros,\n extra_objects = extra_objects,\n extra_compile_args = extra_compile_args,\n extra_link_args = extra_link_args,\n export_symbols = export_symbols,\n )\n ext_modules.append(ext)\n\n return ext_modules\n", "source_code_before": "import os,sys,string\n\ndef update_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n overwrite_version_py = 1):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . If the version information is different from the one\n found in the /__version__.py file, update_version updates\n the file automatically. The version information will be always\n increasing in time.\n If CVS tree does not exist (e.g. as in distribution packages),\n return the version string found from /__version__.py.\n If no version information is available, return None.\n\n Default version string is in the form\n\n ..--\n\n The items have the following meanings:\n\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n\n \"\"\"\n # Open issues:\n # *** Recommend or not to add __version__.py file to CVS\n # repository? If it is in CVS, then when commiting, the\n # version information will change, but __version__.py\n # is commited with old version information to CVS. To get\n # __version__.py also up to date in CVS repository, \n # a second commit of the __version__.py file is required.\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version_dict = {'major':major,'minor':minor,'micro':micro,\n 'release_level':release_level,'serial':serial\n }\n version = version_template % version_dict\n\n if version != old_version:\n print 'version increase detected: %s -> %s'%(old_version,version)\n version_file = os.path.join(path,'__version__.py')\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n % (version_file)\n return version\n print 'updating version in %s' % version_file\n version_file = os.path.abspath(version_file)\n f = open(version_file,'w')\n f.write('# This file is automatically updated with get_version\\n'\\\n '# function from scipy_distutils.misc_utils.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n ):\n return update_version(release_level = release_level,path = path,\n version_template = version_template,\n major = major,overwrite_version_py = 0)\n\n\ndef get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n d1,d2 = map(eval,string.split(items[2],'.')[-2:])\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\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 #import scipy_distutils.setup\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\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() file 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():\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n return d\n\ndef merge_config_dicts(config_list):\n result = default_config_dict() \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 pyf_extensions(parent_package = '',\n sources = [],\n include_dirs = [],\n define_macros = [],\n undef_macros = [],\n library_dirs = [],\n libraries = [],\n runtime_library_dirs = [],\n extra_objects = [],\n extra_compile_args = [],\n extra_link_args = [],\n export_symbols = [],\n f2py_options = [],\n f2py_wrap_functions = 1,\n f2py_debug_capi = 0,\n f2py_build_dir = '.',\n ):\n \"\"\" Return a list of Extension instances defined by .pyf files listed\n in sources list.\n \n f2py_opts is a list of options passed to the f2py runner.\n Option --no-setup is forced. Other possible options are\n --build-dir \n --[no-]wrap-functions\n \n Note: This requires that f2py2e is installed on your machine\n \"\"\"\n from scipy_distutils.core import Extension\n import f2py2e \n \n if parent_package:\n parent_package = parent_package + '.' \n \n f2py_opts = f2py_options or []\n if not f2py_wrap_functions:\n f2py_opts.append('--no-wrap-functions')\n if f2py_debug_capi:\n f2py_opts.append('--debug-capi')\n if '--setup' not in f2py_opts:\n f2py_opts.append('--no-setup')\n f2py_opts.extend(['--build-dir',f2py_build_dir])\n\n pyf_files, sources = f2py2e.f2py2e.filter_files('(?i)','[.]pyf',sources)\n\n pyf = f2py2e.run_main(pyf_files+f2py_opts)\n\n include_dirs = include_dirs + pyf.get_include_dirs()\n ext_modules = []\n\n for name in pyf.get_names():\n ext = Extension(parent_package+name,\n pyf.get_sources(name) + sources,\n include_dirs = include_dirs,\n library_dirs = library_dirs,\n libraries = libraries,\n define_macros = define_macros,\n undef_macros = undef_macros,\n extra_objects = extra_objects,\n extra_compile_args = extra_compile_args,\n extra_link_args = extra_link_args,\n export_symbols = export_symbols,\n )\n ext_modules.append(ext)\n\n return ext_modules\n", "methods": [ { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 65, "complexity": 12, "token_count": 351, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 3, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 103, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 44, "parameters": [ "release_level", "path", "major" ], "start_line": 107, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 17, "complexity": 9, "token_count": 170, "parameters": [ "path" ], "start_line": 118, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 143, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 161, "end_line": 163, "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": 165, "end_line": 168, "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": 170, "end_line": 171, "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": 173, "end_line": 187, "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": 189, "end_line": 199, "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": 201, "end_line": 213, "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( )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 34, "parameters": [], "start_line": 220, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 226, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "pyf_extensions", "long_name": "pyf_extensions( parent_package = '' , sources = [ ] , include_dirs = [ ] , define_macros = [ ] , undef_macros = [ ] , library_dirs = [ ] , libraries = [ ] , runtime_library_dirs = [ ] , extra_objects = [ ] , extra_compile_args = [ ] , extra_link_args = [ ] , export_symbols = [ ] , f2py_options = [ ] , f2py_wrap_functions = 1 , f2py_debug_capi = 0 , f2py_build_dir = '.' , )", "filename": "misc_util.py", "nloc": 48, "complexity": 7, "token_count": 254, "parameters": [ "parent_package", "sources", "include_dirs", "define_macros", "undef_macros", "library_dirs", "libraries", "runtime_library_dirs", "extra_objects", "extra_compile_args", "extra_link_args", "export_symbols", "f2py_options", "f2py_wrap_functions", "f2py_debug_capi", "f2py_build_dir" ], "start_line": 235, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 0 } ], "methods_before": [ { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 65, "complexity": 12, "token_count": 351, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 3, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 103, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 44, "parameters": [ "release_level", "path", "major" ], "start_line": 107, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 17, "complexity": 9, "token_count": 170, "parameters": [ "path" ], "start_line": 118, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 143, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 161, "end_line": 163, "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": 165, "end_line": 168, "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": 170, "end_line": 171, "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": 173, "end_line": 187, "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": 189, "end_line": 199, "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": 201, "end_line": 213, "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( )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 34, "parameters": [], "start_line": 220, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 226, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "pyf_extensions", "long_name": "pyf_extensions( parent_package = '' , sources = [ ] , include_dirs = [ ] , define_macros = [ ] , undef_macros = [ ] , library_dirs = [ ] , libraries = [ ] , runtime_library_dirs = [ ] , extra_objects = [ ] , extra_compile_args = [ ] , extra_link_args = [ ] , export_symbols = [ ] , f2py_options = [ ] , f2py_wrap_functions = 1 , f2py_debug_capi = 0 , f2py_build_dir = '.' , )", "filename": "misc_util.py", "nloc": 48, "complexity": 7, "token_count": 254, "parameters": [ "parent_package", "sources", "include_dirs", "define_macros", "undef_macros", "library_dirs", "libraries", "runtime_library_dirs", "extra_objects", "extra_compile_args", "extra_link_args", "export_symbols", "f2py_options", "f2py_wrap_functions", "f2py_debug_capi", "f2py_build_dir" ], "start_line": 235, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 65, "complexity": 12, "token_count": 351, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 3, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 103, "top_nesting_level": 0 } ], "nloc": 193, "complexity": 49, "token_count": 1245, "diff_parsed": { "added": [ " f.write('# This file is automatically updated with update_version\\n'\\" ], "deleted": [ " f.write('# This file is automatically updated with get_version\\n'\\" ] } } ] }, { "hash": "16b78c20541053ec7d1eb202bb88471363375413", "msg": "version update", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-01-09T20:13:15+00:00", "author_timezone": 0, "committer_date": "2002-01-09T20:13:15+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "7e0eac3f6ac7372c18dd0b629e56e6b7fc42175f" ], "project_name": "repo_copy", "project_path": "/tmp/tmplijk_wg1/repo_copy", "deletions": 3, "insertions": 3, "lines": 6, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/__version__.py", "new_path": "scipy_distutils/__version__.py", "filename": "__version__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n-# This file is automatically updated with get_version\n+# This file is automatically updated with update_version\n # function from scipy_distutils.misc_utils.py\n-version = '0.6.23-alpha-72'\n-version_info = (0, 6, 23, 'alpha', 72)\n+version = '0.6.23-alpha-81'\n+version_info = (0, 6, 23, 'alpha', 81)\n", "added_lines": 3, "deleted_lines": 3, "source_code": "# This file is automatically updated with update_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.6.23-alpha-81'\nversion_info = (0, 6, 23, 'alpha', 81)\n", "source_code_before": "# This file is automatically updated with get_version\n# function from scipy_distutils.misc_utils.py\nversion = '0.6.23-alpha-72'\nversion_info = (0, 6, 23, 'alpha', 72)\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 2, "complexity": 0, "token_count": 16, "diff_parsed": { "added": [ "# This file is automatically updated with update_version", "version = '0.6.23-alpha-81'", "version_info = (0, 6, 23, 'alpha', 81)" ], "deleted": [ "# This file is automatically updated with get_version", "version = '0.6.23-alpha-72'", "version_info = (0, 6, 23, 'alpha', 72)" ] } } ] } ]